001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.mina.core.filterchain;
021
022import org.apache.mina.core.session.IdleStatus;
023import org.apache.mina.core.session.IoSession;
024import org.apache.mina.core.write.WriteRequest;
025
026/**
027 * An adapter class for {@link IoFilter}.  You can extend
028 * this class and selectively override required event filter methods only.  All
029 * methods forwards events to the next filter by default.
030 *
031 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
032 */
033public class IoFilterAdapter implements IoFilter {
034    /**
035     * {@inheritDoc}
036     */
037    public void init() throws Exception {
038    }
039
040    /**
041     * {@inheritDoc}
042     */
043    public void destroy() throws Exception {
044    }
045
046    /**
047     * {@inheritDoc}
048     */
049    public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception {
050    }
051
052    /**
053     * {@inheritDoc}
054     */
055    public void onPostAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception {
056    }
057
058    /**
059     * {@inheritDoc}
060     */
061    public void onPreRemove(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception {
062    }
063
064    /**
065     * {@inheritDoc}
066     */
067    public void onPostRemove(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception {
068    }
069
070    /**
071     * {@inheritDoc}
072     */
073    public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception {
074        nextFilter.sessionCreated(session);
075    }
076
077    /**
078     * {@inheritDoc}
079     */
080    public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception {
081        nextFilter.sessionOpened(session);
082    }
083
084    /**
085     * {@inheritDoc}
086     */
087    public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception {
088        nextFilter.sessionClosed(session);
089    }
090
091    /**
092     * {@inheritDoc}
093     */
094    public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception {
095        nextFilter.sessionIdle(session, status);
096    }
097
098    /**
099     * {@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}