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.service;
021
022import java.util.EventListener;
023
024import org.apache.mina.core.session.IdleStatus;
025import org.apache.mina.core.session.IoSession;
026
027/**
028 * Listens to events related to an {@link IoService}.
029 *
030 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
031 */
032public interface IoServiceListener extends EventListener {
033    /**
034     * Invoked when a new service is activated by an {@link IoService}.
035     *
036     * @param service the {@link IoService}
037     * @throws Exception if an error occurred while the service is being activated
038     */
039    void serviceActivated(IoService service) throws Exception;
040
041    /**
042     * Invoked when a service is idle.
043     * 
044     * @param service the {@link IoService}
045     * @param idleStatus The idle status
046     * @throws Exception if an error occurred while the service is being idled
047     */
048    void serviceIdle(IoService service, IdleStatus idleStatus) throws Exception;
049
050    /**
051     * Invoked when a service is deactivated by an {@link IoService}.
052     *
053     * @param service the {@link IoService}
054     * @throws Exception if an error occurred while the service is being deactivated
055     */
056    void serviceDeactivated(IoService service) throws Exception;
057
058    /**
059     * Invoked when a new session is created by an {@link IoService}.
060     *
061     * @param session the new session
062     * @throws Exception if an error occurred while the session is being created
063     */
064    void sessionCreated(IoSession session) throws Exception;
065
066    /**
067     * Invoked when a new session is closed by an {@link IoService}.
068     * 
069     * @param session the new session
070     * @throws Exception if an error occurred while the session is being closed
071     */
072    void sessionClosed(IoSession session) throws Exception;
073
074    /**
075     * Invoked when a session is being destroyed by an {@link IoService}.
076     * 
077     * @param session the session to be destroyed
078     * @throws Exception if an error occurred while the session is being destroyed
079     */
080    void sessionDestroyed(IoSession session) throws Exception;
081}