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 org.apache.mina.core.session.IdleStatus;
23  import org.apache.mina.core.session.IoSession;
24  
25  /**
26   * Adapter class for implementors of the {@link SingleSessionIoHandler}
27   * interface. The session to which the handler is assigned is accessible
28   * through the {@link #getSession()} method.
29   *
30   * @author The Apache MINA Project (dev@mina.apache.org)
31   */
32  public class SingleSessionIoHandlerAdapter implements SingleSessionIoHandler {
33  
34      /**
35       * The session to which the handler is assigned.
36       */
37      private final IoSession session;
38  
39      /**
40       * Creates a new instance that is assigned to the passed in session.
41       *
42       * @param session the session to which the handler is assigned
43       */
44      public SingleSessionIoHandlerAdapter(IoSession session) {
45          if (session == null) {
46              throw new NullPointerException("session");
47          }
48          this.session = session;
49      }
50  
51      /**
52       * Retrieves the session to which this handler is assigned.
53       *
54       * @return the session
55       */
56      protected IoSession getSession() {
57          return session;
58      }
59  
60      public void exceptionCaught(Throwable th) throws Exception {
61          // Do nothing
62      }
63  
64      public void messageReceived(Object message) throws Exception {
65          // Do nothing
66      }
67  
68      public void messageSent(Object message) throws Exception {
69          // Do nothing
70      }
71  
72      public void sessionClosed() throws Exception {
73          // Do nothing
74      }
75  
76      public void sessionCreated() throws Exception {
77          // Do nothing
78      }
79  
80      public void sessionIdle(IdleStatus status) throws Exception {
81          // Do nothing
82      }
83  
84      public void sessionOpened() throws Exception {
85          // Do nothing
86      }
87  }