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