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 The Apache MINA Project (dev@mina.apache.org)
32   * @version $Rev: 591770 $, $Date: 2007-11-04 13:22:44 +0100 (Sun, 04 Nov 2007) $
33   */
34  public class IoFilterAdapter implements IoFilter {
35      /**
36       * {@inheritDoc}
37       */
38      public void init() throws Exception {
39      }
40  
41      /**
42       * {@inheritDoc}
43       */
44      public void destroy() throws Exception {
45      }
46  
47      /**
48       * {@inheritDoc}
49       */
50      public void onPreAdd(IoFilterChain parent, String name,
51          NextFilter nextFilter) throws Exception {
52      }
53  
54      /**
55       * {@inheritDoc}
56       */
57      public void onPostAdd(IoFilterChain parent, String name,
58          NextFilter nextFilter) throws Exception {
59      }
60  
61      /**
62       * {@inheritDoc}
63       */
64      public void onPreRemove(IoFilterChain parent, String name,
65          NextFilter nextFilter) throws Exception {
66      }
67  
68      /**
69       * {@inheritDoc}
70       */
71      public void onPostRemove(IoFilterChain parent, String name,
72          NextFilter nextFilter) throws Exception {
73      }
74  
75      /**
76       * {@inheritDoc}
77       */
78      public void sessionCreated(NextFilter nextFilter, IoSession session)
79              throws Exception {
80          nextFilter.sessionCreated(session);
81      }
82  
83      /**
84       * {@inheritDoc}
85       */
86      public void sessionOpened(NextFilter nextFilter, IoSession session)
87              throws Exception {
88          nextFilter.sessionOpened(session);
89      }
90  
91      /**
92       * {@inheritDoc}
93       */
94      public void sessionClosed(NextFilter nextFilter, IoSession session)
95              throws Exception {
96          nextFilter.sessionClosed(session);
97      }
98  
99      /**
100      * {@inheritDoc}
101      */
102     public void sessionIdle(NextFilter nextFilter, IoSession session,
103             IdleStatus status) throws Exception {
104         nextFilter.sessionIdle(session, status);
105     }
106 
107     /**
108      * {@inheritDoc}
109      */
110     public void exceptionCaught(NextFilter nextFilter, IoSession session,
111             Throwable cause) throws Exception {
112         nextFilter.exceptionCaught(session, cause);
113     }
114 
115     /**
116      * {@inheritDoc}
117      */
118     public void messageReceived(NextFilter nextFilter, IoSession session,
119             Object message) throws Exception {
120         nextFilter.messageReceived(session, message);
121     }
122 
123     /**
124      * {@inheritDoc}
125      */
126     public void messageSent(NextFilter nextFilter, IoSession session,
127             WriteRequest writeRequest) throws Exception {
128         nextFilter.messageSent(session, writeRequest);
129     }
130 
131     /**
132      * {@inheritDoc}
133      */
134     public void filterWrite(NextFilter nextFilter, IoSession session,
135             WriteRequest writeRequest) throws Exception {
136         nextFilter.filterWrite(session, writeRequest);
137     }
138 
139     /**
140      * {@inheritDoc}
141      */
142     public void filterClose(NextFilter nextFilter, IoSession session)
143             throws Exception {
144         nextFilter.filterClose(session);
145     }
146     
147     public String toString() {
148     	return this.getClass().getSimpleName();
149     }
150 }