1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.mina.transport.socket.nio; 21 22 import java.nio.channels.ByteChannel; 23 import java.nio.channels.SelectionKey; 24 25 import org.apache.mina.core.service.IoProcessor; 26 import org.apache.mina.core.session.AbstractIoSession; 27 import org.apache.mina.core.session.IoSession; 28 29 /** 30 * An {@link IoSession} which is managed by the NIO transport. 31 * 32 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 33 */ 34 public abstract class NioSession extends AbstractIoSession { 35 /** The NioSession processor */ 36 protected final IoProcessor<NioSession> processor; 37 38 39 /** 40 * 41 * Creates a new instance of NioSession, with its associated IoProcessor. 42 * <br> 43 * This method is only called by the inherited class. 44 * 45 * @param processor The associated IoProcessor 46 */ 47 protected NioSession(IoProcessor<NioSession> processor) { 48 this.processor = processor; 49 } 50 51 /** 52 * @return The ByteChannel associated with this {@link IoSession} 53 */ 54 abstract ByteChannel getChannel(); 55 56 /** 57 * @return The {@link SelectionKey} associated with this {@link IoSession} 58 */ 59 abstract SelectionKey getSelectionKey(); 60 61 /** 62 * Sets the {@link SelectionKey} for this {@link IoSession} 63 * 64 * @param key The new {@link SelectionKey} 65 */ 66 abstract void setSelectionKey(SelectionKey key); 67 68 /** 69 * {@inheritDoc} 70 */ 71 public IoProcessor<NioSession> getProcessor() { 72 return processor; 73 } 74 }