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  
21  package org.apache.mina.api;
22  
23  import org.apache.mina.filterchain.ReadFilterChainController;
24  import org.apache.mina.filterchain.WriteFilterChainController;
25  import org.apache.mina.session.WriteRequest;
26  
27  /**
28   * Filter are interceptors/processors for incoming data received/sent.
29   * 
30   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
31   */
32  public interface IoFilter {
33  
34      /**
35       * Invoked when a connection has been opened.
36       * 
37       * @param session {@link IoSession} associated with the invocation
38       */
39      void sessionOpened(IoSession session);
40  
41      /**
42       * Invoked when a connection is closed.
43       * 
44       * @param session {@link IoSession} associated with the invocation
45       */
46      void sessionClosed(IoSession session);
47  
48      /**
49       * Invoked with the related {@link IdleStatus} when a connection becomes idle.
50       * 
51       * @param session {@link IoSession} associated with the invocation
52       */
53      void sessionIdle(IoSession session, IdleStatus status);
54  
55      /**
56       * Invoked when a message is received.
57       * 
58       * @param session {@link IoSession} associated with the invocation
59       * @param message the incoming message to process
60       */
61      void messageReceived(IoSession session, Object message, ReadFilterChainController controller);
62  
63      /**
64       * Invoked when a message is under writing. The filter is supposed to apply the needed transformation.
65       * 
66       * @param session {@link IoSession} associated with the invocation
67       * @param message the message to process before writing
68       */
69      void messageWriting(IoSession session, WriteRequest message, WriteFilterChainController controller);
70  
71      /**
72       * Invoked when a high level message was written to the low level O/S buffer.
73       * 
74       * @param session {@link IoSession} associated with the invocation
75       * @param message the incoming message to process
76       */
77      void messageSent(IoSession session, Object message);
78  }