查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
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, NextFilter nextFilter) throws Exception {
50      }
51  
52      /**
53       * {@inheritDoc}
54       */
55      public void onPostAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception {
56      }
57  
58      /**
59       * {@inheritDoc}
60       */
61      public void onPreRemove(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception {
62      }
63  
64      /**
65       * {@inheritDoc}
66       */
67      public void onPostRemove(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception {
68      }
69  
70      /**
71       * {@inheritDoc}
72       */
73      public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception {
74          nextFilter.sessionCreated(session);
75      }
76  
77      /**
78       * {@inheritDoc}
79       */
80      public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception {
81          nextFilter.sessionOpened(session);
82      }
83  
84      /**
85       * {@inheritDoc}
86       */
87      public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception {
88          nextFilter.sessionClosed(session);
89      }
90  
91      /**
92       * {@inheritDoc}
93       */
94      public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception {
95          nextFilter.sessionIdle(session, status);
96      }
97  
98      /**
99       * {@inheritDoc}
100      */
101     public void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable cause) throws Exception {
102         nextFilter.exceptionCaught(session, cause);
103     }
104 
105     /**
106      * {@inheritDoc}
107      */
108     public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception {
109         nextFilter.messageReceived(session, message);
110     }
111 
112     /**
113      * {@inheritDoc}
114      */
115     public void messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception {
116         nextFilter.messageSent(session, writeRequest);
117     }
118 
119     /**
120      * {@inheritDoc}
121      */
122     public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception {
123         nextFilter.filterWrite(session, writeRequest);
124     }
125 
126     /**
127      * {@inheritDoc}
128      */
129     public void filterClose(NextFilter nextFilter, IoSession session) throws Exception {
130         nextFilter.filterClose(session);
131     }
132 
133     /**
134      * {@inheritDoc}
135      */
136     public void inputClosed(NextFilter nextFilter, IoSession session) throws Exception {
137         nextFilter.inputClosed(session);
138     }
139 
140     public String toString() {
141         return this.getClass().getSimpleName();
142     }
143 }