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