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.handler.multiton; 21 22 import java.io.IOException; 23 24 import org.apache.mina.core.service.IoHandler; 25 import org.apache.mina.core.session.IdleStatus; 26 import org.apache.mina.core.session.IoSession; 27 import org.apache.mina.filter.FilterEvent; 28 29 /** 30 * A session handler without an {@link IoSession} parameter for simplicity. 31 * <p> 32 * A {@link SingleSessionIoHandler} is similar to an {@link IoHandler} with 33 * the notable difference that a {@link SingleSessionIoHandler} is used only 34 * by one session at a time. Thus, there is no {@link IoSession} parameter in 35 * the methods of this interface. 36 * </p> 37 * <p> 38 * Because events are passed to the session in order, it is possible to store 39 * conversational state as instance variables in this object. 40 * </p> 41 * 42 * WARNING: This class is badly named as the actual {@link IoHandler} implementor 43 * is in fact the {@link SingleSessionIoHandlerDelegate}. 44 * 45 * @deprecated This class is not to be used anymore 46 * 47 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 48 */ 49 @Deprecated 50 public interface SingleSessionIoHandler { 51 52 /** 53 * Invoked when the session is created. Initialize default socket parameters 54 * and user-defined attributes here. 55 * 56 * @throws Exception If the session can't be created 57 * @see IoHandler#sessionCreated(IoSession) 58 */ 59 void sessionCreated() throws Exception; 60 61 /** 62 * Invoked when the connection is opened. This method is not invoked if the 63 * transport type is UDP. 64 * 65 * @throws Exception If the session can't be opened 66 * @see IoHandler#sessionOpened(IoSession) 67 */ 68 void sessionOpened() throws Exception; 69 70 /** 71 * Invoked when the connection is closed. This method is not invoked if the 72 * transport type is UDP. 73 * 74 * @throws Exception If the session can't be closed 75 * @see IoHandler#sessionClosed(IoSession) 76 */ 77 void sessionClosed() throws Exception; 78 79 /** 80 * Invoked when the connection is idle. Refer to {@link IdleStatus}. This 81 * method is not invoked if the transport type is UDP. 82 * 83 * @param status the type of idleness 84 * @throws Exception If the idle event can't be handled 85 * @see IoHandler#sessionIdle(IoSession, IdleStatus) 86 */ 87 void sessionIdle(IdleStatus status) throws Exception; 88 89 /** 90 * Invoked when any exception is thrown by user {@link IoHandler} 91 * implementation or by MINA. If <code>cause</code> is instanceof 92 * {@link IOException}, MINA will close the connection automatically. 93 * 94 * @param cause the caught exception 95 * @throws Exception If the exception can't be handled 96 * @see IoHandler#exceptionCaught(IoSession, Throwable) 97 */ 98 void exceptionCaught(Throwable cause) throws Exception; 99 100 /** 101 * Invoked when a half-duplex connection is closed 102 * 103 * @param session The current session 104 */ 105 void inputClosed(IoSession session); 106 107 /** 108 * Invoked when protocol message is received. Implement your protocol flow 109 * here. 110 * 111 * @param message the received message 112 * @throws Exception If the received message can't be processed 113 * @see IoHandler#messageReceived(IoSession, Object) 114 */ 115 void messageReceived(Object message) throws Exception; 116 117 /** 118 * Invoked when protocol message that user requested by 119 * {@link IoSession#write(Object)} is sent out actually. 120 * 121 * @param message the sent message 122 * @throws Exception If the sent message can't be processed 123 * @see IoHandler#messageSent(IoSession, Object) 124 */ 125 void messageSent(Object message) throws Exception; 126 127 128 /** 129 * Invoked when a filter event is fired. Each filter might sent a different event, 130 * this is very application specific. 131 * 132 * @param event The event to process 133 * @throws Exception If we get an exception while processing the event 134 */ 135 void event(FilterEvent event) throws Exception; 136 }