1 | /* |
2 | * @(#) $Id: IoSessionManagerFilterChain.java 357871 2005-12-20 01:56:40Z trustin $ |
3 | * |
4 | * Copyright 2004 The Apache Software Foundation |
5 | * |
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * you may not use this file except in compliance with the License. |
8 | * 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, software |
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * See the License for the specific language governing permissions and |
16 | * limitations under the License. |
17 | * |
18 | */ |
19 | package org.apache.mina.io; |
20 | |
21 | import org.apache.mina.common.ByteBuffer; |
22 | import org.apache.mina.common.IdleStatus; |
23 | |
24 | /** |
25 | * An {@link IoFilterChain} that forwards all events |
26 | * except <tt>filterWrite</tt> to the {@link IoSessionFilterChain} |
27 | * of the recipient session. |
28 | * <p> |
29 | * This filter chain is used by implementations of {@link IoSessionManager}s. |
30 | * |
31 | * @author The Apache Directory Project (dev@directory.apache.org) |
32 | * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $ |
33 | */ |
34 | public abstract class IoSessionManagerFilterChain extends AbstractIoFilterChain { |
35 | |
36 | private final IoSessionManager manager; |
37 | |
38 | protected IoSessionManagerFilterChain( IoSessionManager manager ) |
39 | { |
40 | this.manager = manager; |
41 | } |
42 | |
43 | public IoSessionManager getManager() |
44 | { |
45 | return manager; |
46 | } |
47 | |
48 | protected IoFilter createTailFilter() |
49 | { |
50 | return new IoFilter() |
51 | { |
52 | public void sessionOpened( NextFilter nextFilter, IoSession session ) throws Exception |
53 | { |
54 | ( ( IoSessionFilterChain ) session.getFilterChain() ).sessionOpened( session ); |
55 | } |
56 | |
57 | public void sessionClosed( NextFilter nextFilter, IoSession session ) throws Exception |
58 | { |
59 | ( ( IoSessionFilterChain ) session.getFilterChain() ).sessionClosed( session ); |
60 | } |
61 | |
62 | public void sessionIdle( NextFilter nextFilter, IoSession session, |
63 | IdleStatus status ) throws Exception |
64 | { |
65 | ( ( IoSessionFilterChain ) session.getFilterChain() ).sessionIdle( session, status ); |
66 | } |
67 | |
68 | public void exceptionCaught( NextFilter nextFilter, |
69 | IoSession session, Throwable cause ) throws Exception |
70 | { |
71 | ( ( IoSessionFilterChain ) session.getFilterChain() ).exceptionCaught( session, cause ); |
72 | } |
73 | |
74 | public void dataRead( NextFilter nextFilter, IoSession session, |
75 | ByteBuffer buf ) throws Exception |
76 | { |
77 | ( ( IoSessionFilterChain ) session.getFilterChain() ).dataRead( session, buf ); |
78 | } |
79 | |
80 | public void dataWritten( NextFilter nextFilter, IoSession session, |
81 | Object marker ) throws Exception |
82 | { |
83 | ( ( IoSessionFilterChain ) session.getFilterChain() ).dataWritten( session, marker ); |
84 | } |
85 | |
86 | public void filterWrite( NextFilter nextFilter, |
87 | IoSession session, ByteBuffer buf, Object marker ) throws Exception |
88 | { |
89 | nextFilter.filterWrite( session, buf, marker ); |
90 | } |
91 | }; |
92 | } |
93 | } |