1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.handler.multiton;
21
22 import org.apache.mina.core.service.IoHandler;
23 import org.apache.mina.core.session.AttributeKey;
24 import org.apache.mina.core.session.IdleStatus;
25 import org.apache.mina.core.session.IoSession;
26 import org.apache.mina.filter.FilterEvent;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 @Deprecated
44 public class SingleSessionIoHandlerDelegate implements IoHandler {
45
46
47
48
49 public static final AttributeKeyributeKey.html#AttributeKey">AttributeKey HANDLER = new AttributeKey(SingleSessionIoHandlerDelegate.class, "handler");
50
51
52
53
54
55 private final SingleSessionIoHandlerFactory factory;
56
57
58
59
60
61
62
63
64 public SingleSessionIoHandlerDelegate(SingleSessionIoHandlerFactory factory) {
65 if (factory == null) {
66 throw new IllegalArgumentException("factory");
67 }
68 this.factory = factory;
69 }
70
71
72
73
74
75 public SingleSessionIoHandlerFactory getFactory() {
76 return factory;
77 }
78
79
80
81
82
83
84
85
86 @Override
87 public void sessionCreated(IoSession session) throws Exception {
88 SingleSessionIoHandler handler = factory.getHandler(session);
89 session.setAttribute(HANDLER, handler);
90 handler.sessionCreated();
91 }
92
93
94
95
96
97
98
99
100 @Override
101 public void sessionOpened(IoSession session) throws Exception {
102 SingleSessionIoHandlerg/apache/mina/handler/multiton/SingleSessionIoHandler.html#SingleSessionIoHandler">SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
103 handler.sessionOpened();
104 }
105
106
107
108
109
110
111
112
113 @Override
114 public void sessionClosed(IoSession session) throws Exception {
115 SingleSessionIoHandlerg/apache/mina/handler/multiton/SingleSessionIoHandler.html#SingleSessionIoHandler">SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
116 handler.sessionClosed();
117 }
118
119
120
121
122
123
124
125
126 @Override
127 public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
128 SingleSessionIoHandlerg/apache/mina/handler/multiton/SingleSessionIoHandler.html#SingleSessionIoHandler">SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
129 handler.sessionIdle(status);
130 }
131
132
133
134
135
136
137
138
139 @Override
140 public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
141 SingleSessionIoHandlerg/apache/mina/handler/multiton/SingleSessionIoHandler.html#SingleSessionIoHandler">SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
142 handler.exceptionCaught(cause);
143 }
144
145
146
147
148
149
150
151
152 @Override
153 public void messageReceived(IoSession session, Object message) throws Exception {
154 SingleSessionIoHandlerg/apache/mina/handler/multiton/SingleSessionIoHandler.html#SingleSessionIoHandler">SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
155 handler.messageReceived(message);
156 }
157
158
159
160
161
162
163
164
165 @Override
166 public void messageSent(IoSession session, Object message) throws Exception {
167 SingleSessionIoHandlerg/apache/mina/handler/multiton/SingleSessionIoHandler.html#SingleSessionIoHandler">SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
168 handler.messageSent(message);
169 }
170
171
172
173
174 @Override
175 public void inputClosed(IoSession session) throws Exception {
176 SingleSessionIoHandlerg/apache/mina/handler/multiton/SingleSessionIoHandler.html#SingleSessionIoHandler">SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
177 handler.inputClosed(session);
178 }
179
180
181
182
183
184
185
186
187 @Override
188 public void event(IoSession session, FilterEvent event) throws Exception {
189 SingleSessionIoHandlerg/apache/mina/handler/multiton/SingleSessionIoHandler.html#SingleSessionIoHandler">SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
190 handler.event(event);
191 }
192 }