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   * @deprecated This class is not to be used anymore
45   * 
46   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
47   */
48  @Deprecated
49  public interface SingleSessionIoHandler {
50  
51      /**
52       * Invoked when the session is created. Initialize default socket parameters
53       * and user-defined attributes here.
54       *
55       * @throws Exception If the session can't be created
56       * @see IoHandler#sessionCreated(IoSession)
57       */
58      void sessionCreated() throws Exception;
59  
60      /**
61       * Invoked when the connection is opened. This method is not invoked if the
62       * transport type is UDP.
63       *
64       * @throws Exception If the session can't be opened
65       * @see IoHandler#sessionOpened(IoSession)
66       */
67      void sessionOpened() throws Exception;
68  
69      /**
70       * Invoked when the connection is closed. This method is not invoked if the
71       * transport type is UDP.
72       *
73       * @throws Exception If the session can't be closed
74       * @see IoHandler#sessionClosed(IoSession)
75       */
76      void sessionClosed() throws Exception;
77  
78      /**
79       * Invoked when the connection is idle. Refer to {@link IdleStatus}. This
80       * method is not invoked if the transport type is UDP.
81       *
82       * @param status the type of idleness
83       * @throws Exception If the idle event can't be handled
84       * @see IoHandler#sessionIdle(IoSession, IdleStatus)
85       */
86      void sessionIdle(IdleStatus status) throws Exception;
87  
88      /**
89       * Invoked when any exception is thrown by user {@link IoHandler}
90       * implementation or by MINA. If <code>cause</code> is instanceof
91       * {@link IOException}, MINA will close the connection automatically.
92       *
93       * @param cause the caught exception
94       * @throws Exception If the exception can't be handled
95       * @see IoHandler#exceptionCaught(IoSession, Throwable)
96       */
97      void exceptionCaught(Throwable cause) throws Exception;
98  
99      /**
100      * Invoked when a half-duplex connection is closed
101      * 
102      * @param session The current session
103      */
104     void inputClosed(IoSession session);
105 
106     /**
107      * Invoked when protocol message is received. Implement your protocol flow
108      * here.
109      *
110      * @param message the received message
111      * @throws Exception If the received message can't be processed
112      * @see IoHandler#messageReceived(IoSession, Object)
113      */
114     void messageReceived(Object message) throws Exception;
115 
116     /**
117      * Invoked when protocol message that user requested by
118      * {@link IoSession#write(Object)} is sent out actually.
119      *
120      * @param message the sent message
121      * @throws Exception If the sent message can't be processed
122      * @see IoHandler#messageSent(IoSession, Object)
123      */
124     void messageSent(Object message) throws Exception;
125 }