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 * @version $Rev: 671827 $, $Date: 2008-06-26 10:49:48 +0200 (jeu, 26 jun 2008) $
32 */
33 public class SingleSessionIoHandlerAdapter implements SingleSessionIoHandler {
34
35 /**
36 * The session to which the handler is assigned.
37 */
38 private final IoSession session;
39
40 /**
41 * Creates a new instance that is assigned to the passed in session.
42 *
43 * @param session the session to which the handler is assigned
44 */
45 public SingleSessionIoHandlerAdapter(IoSession session) {
46 if (session == null) {
47 throw new NullPointerException("session");
48 }
49 this.session = session;
50 }
51
52 /**
53 * Retrieves the session to which this handler is assigned.
54 *
55 * @return the session
56 */
57 protected IoSession getSession() {
58 return session;
59 }
60
61 public void exceptionCaught(Throwable th) throws Exception {
62 }
63
64 public void messageReceived(Object message) throws Exception {
65 }
66
67 public void messageSent(Object message) throws Exception {
68 }
69
70 public void sessionClosed() throws Exception {
71 }
72
73 public void sessionCreated() throws Exception {
74 }
75
76 public void sessionIdle(IdleStatus status) throws Exception {
77 }
78
79 public void sessionOpened() throws Exception {
80 }
81 }