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  package org.apache.mina.api;
20  
21  import org.slf4j.Logger;
22  import org.slf4j.LoggerFactory;
23  
24  /**
25   * A convenient {@link IoHandler} implementation to be sub-classed for easier {@link IoHandler} implementation.
26   * 
27   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
28   */
29  public abstract class AbstractIoHandler implements IoHandler {
30  
31      private static final Logger LOG = LoggerFactory.getLogger(AbstractIoHandler.class);
32  
33      /**
34       * {@inheritDoc}
35       */
36      @Override
37      public void sessionOpened(final IoSession session) {
38      }
39  
40      /**
41       * {@inheritDoc}
42       */
43      @Override
44      public void sessionClosed(final IoSession session) {
45      }
46  
47      /**
48       * {@inheritDoc}
49       */
50      @Override
51      public void sessionIdle(final IoSession session, final IdleStatus status) {
52      }
53  
54      /**
55       * {@inheritDoc}
56       */
57      @Override
58      public void messageReceived(final IoSession session, final Object message) {
59      }
60  
61      /**
62       * {@inheritDoc}
63       */
64      @Override
65      public void messageSent(final IoSession session, final Object message) {
66      }
67  
68      /**
69       * {@inheritDoc}
70       */
71      @Override
72      public void serviceActivated(final IoService service) {
73      }
74  
75      /**
76       * {@inheritDoc}
77       */
78      @Override
79      public void serviceInactivated(final IoService service) {
80      }
81  
82      /**
83       * {@inheritDoc}
84       */
85      @Override
86      public void exceptionCaught(final IoSession session, final Exception cause) {
87          LOG.error("Unexpected exception, we close the session : ", cause);
88          session.close(true);
89      }
90  }