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.core.filterchain;
21  
22  import org.apache.mina.core.session.IdleStatus;
23  import org.apache.mina.core.session.IoSession;
24  import org.apache.mina.core.write.WriteRequest;
25  
26  /**
27   * An adapter class for {@link IoFilter}.  You can extend
28   * this class and selectively override required event filter methods only.  All
29   * methods forwards events to the next filter by default.
30   *
31   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
32   */
33  public class IoFilterAdapter implements IoFilter {
34      /**
35       * {@inheritDoc}
36       */
37      public void init() throws Exception {
38      }
39  
40      /**
41       * {@inheritDoc}
42       */
43      public void destroy() throws Exception {
44      }
45  
46      /**
47       * {@inheritDoc}
48       */
49      public void onPreAdd(IoFilterChain parent, String name,
50          NextFilter nextFilter) throws Exception {
51      }
52  
53      /**
54       * {@inheritDoc}
55       */
56      public void onPostAdd(IoFilterChain parent, String name,
57          NextFilter nextFilter) throws Exception {
58      }
59  
60      /**
61       * {@inheritDoc}
62       */
63      public void onPreRemove(IoFilterChain parent, String name,
64          NextFilter nextFilter) throws Exception {
65      }
66  
67      /**
68       * {@inheritDoc}
69       */
70      public void onPostRemove(IoFilterChain parent, String name,
71          NextFilter nextFilter) throws Exception {
72      }
73  
74      /**
75       * {@inheritDoc}
76       */
77      public void sessionCreated(NextFilter nextFilter, IoSession session)
78              throws Exception {
79          nextFilter.sessionCreated(session);
80      }
81  
82      /**
83       * {@inheritDoc}
84       */
85      public void sessionOpened(NextFilter nextFilter, IoSession session)
86              throws Exception {
87          nextFilter.sessionOpened(session);
88      }
89  
90      /**
91       * {@inheritDoc}
92       */
93      public void sessionClosed(NextFilter nextFilter, IoSession session)
94              throws Exception {
95          nextFilter.sessionClosed(session);
96      }
97  
98      /**
99       * {@inheritDoc}
100      */
101     public void sessionIdle(NextFilter nextFilter, IoSession session,
102             IdleStatus status) throws Exception {
103         nextFilter.sessionIdle(session, status);
104     }
105 
106     /**
107      * {@inheritDoc}
108      */
109     public void exceptionCaught(NextFilter nextFilter, IoSession session,
110             Throwable cause) throws Exception {
111         nextFilter.exceptionCaught(session, cause);
112     }
113 
114     /**
115      * {@inheritDoc}
116      */
117     public void messageReceived(NextFilter nextFilter, IoSession session,
118             Object message) throws Exception {
119         nextFilter.messageReceived(session, message);
120     }
121 
122     /**
123      * {@inheritDoc}
124      */
125     public void messageSent(NextFilter nextFilter, IoSession session,
126             WriteRequest writeRequest) throws Exception {
127         nextFilter.messageSent(session, writeRequest);
128     }
129 
130     /**
131      * {@inheritDoc}
132      */
133     public void filterWrite(NextFilter nextFilter, IoSession session,
134             WriteRequest writeRequest) throws Exception {
135         nextFilter.filterWrite(session, writeRequest);
136     }
137 
138     /**
139      * {@inheritDoc}
140      */
141     public void filterClose(NextFilter nextFilter, IoSession session)
142             throws Exception {
143         nextFilter.filterClose(session);
144     }
145     
146     public String toString() {
147         return this.getClass().getSimpleName();
148     }
149 }