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
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       * @see IoHandler#sessionOpened(IoSession)
63       */
64      void sessionOpened() throws Exception;
65  
66      /**
67       * Invoked when the connection is closed. This method is not invoked if the
68       * transport type is UDP.
69       *
70       * @see IoHandler#sessionClosed(IoSession)
71       */
72      void sessionClosed() throws Exception;
73  
74      /**
75       * Invoked when the connection is idle. Refer to {@link IdleStatus}. This
76       * method is not invoked if the transport type is UDP.
77       *
78       * @param status the type of idleness
79       * @see IoHandler#sessionIdle(IoSession, IdleStatus)
80       */
81      void sessionIdle(IdleStatus status) throws Exception;
82  
83      /**
84       * Invoked when any exception is thrown by user {@link IoHandler}
85       * implementation or by MINA. If <code>cause</code> is instanceof
86       * {@link IOException}, MINA will close the connection automatically.
87       *
88       * @param cause the caught exception
89       * @see IoHandler#exceptionCaught(IoSession, Throwable)
90       */
91      void exceptionCaught(Throwable cause) throws Exception;
92  
93      /**
94       * Invoked when protocol message is received. Implement your protocol flow
95       * here.
96       *
97       * @param message the received message
98       * @see IoHandler#messageReceived(IoSession, Object)
99       */
100     void messageReceived(Object message) throws Exception;
101 
102     /**
103      * Invoked when protocol message that user requested by
104      * {@link IoSession#write(Object)} is sent out actually.
105      *
106      * @param message the sent message
107      * @see IoHandler#messageSent(IoSession, Object)
108      */
109     void messageSent(Object message) throws Exception;
110 
111 }