KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > mina > common > IoService


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.common;
21
22 import java.net.SocketAddress JavaDoc;
23 import java.util.Set JavaDoc;
24
25 /**
26  * Base interface for all {@link IoAcceptor}s and {@link IoConnector}s
27  * that provide I/O service and manage {@link IoSession}s.
28  *
29  * @author The Apache Directory Project (mina-dev@directory.apache.org)
30  * @version $Rev: 555855 $, $Date: 2007-07-13 12:19:00 +0900 (금, 13 7월 2007) $
31  */

32 public interface IoService {
33     /**
34      * Adds an {@link IoServiceListener} that listens any events related with
35      * this service.
36      */

37     void addListener(IoServiceListener listener);
38
39     /**
40      * Removed an existing {@link IoServiceListener} that listens any events
41      * related with this service.
42      */

43     void removeListener(IoServiceListener listener);
44
45     /**
46      * Returns all {@link SocketAddress}es this service is managing.
47      * If this service is an {@link IoAcceptor}, a set of bind addresses will
48      * be returned. If this service is an {@link IoConnector}, a set of remote
49      * addresses will be returned.
50      */

51     Set JavaDoc<SocketAddress JavaDoc> getManagedServiceAddresses();
52
53     /**
54      * Returns <tt>true</tt> if this service is managing the specified <tt>serviceAddress</tt>.
55      * If this service is an {@link IoAcceptor}, <tt>serviceAddress</tt> is a bind address.
56      * If this service is an {@link IoConnector}, <tt>serviceAddress</tt> is a remote address.
57      */

58     boolean isManaged(SocketAddress JavaDoc serviceAddress);
59
60     /**
61      * Returns all sessions with the specified remote or local address,
62      * which are currently managed by this service.
63      * {@link IoAcceptor} will assume the specified <tt>address</tt> is a local
64      * address, and {@link IoConnector} will assume it's a remote address.
65      *
66      * @param serviceAddress the address to return all sessions for.
67      * @return the sessions. An empty collection if there's no session.
68      * @throws IllegalArgumentException if the specified <tt>address</tt> has
69      * not been bound.
70      * @throws UnsupportedOperationException if this operation isn't supported
71      * for the particular transport type implemented by this {@link IoService}.
72      */

73     Set JavaDoc<IoSession> getManagedSessions(SocketAddress JavaDoc serviceAddress);
74
75     /**
76      * Returns the default configuration which is used when you didn't specify
77      * any configuration.
78      */

79     IoServiceConfig getDefaultConfig();
80
81     /**
82      * Returns the global {@link IoFilterChainBuilder} which will modify the
83      * {@link IoFilterChain} of all {@link IoSession}s which is managed
84      * by this service.
85      * The default value is an empty {@link DefaultIoFilterChainBuilder}.
86      */

87     IoFilterChainBuilder getFilterChainBuilder();
88
89     /**
90      * Sets the global {@link IoFilterChainBuilder} which will modify the
91      * {@link IoFilterChain} of all {@link IoSession}s which is managed
92      * by this service.
93      * If you specify <tt>null</tt> this property will be set to
94      * an empty {@link DefaultIoFilterChainBuilder}.
95      */

96     void setFilterChainBuilder(IoFilterChainBuilder builder);
97
98     /**
99      * A shortcut for <tt>( ( DefaultIoFilterChainBuilder ) </tt>{@link #getFilterChainBuilder()}<tt> )</tt>.
100      * Please note that the returned object is not a <b>real</b> {@link IoFilterChain}
101      * but a {@link DefaultIoFilterChainBuilder}. Modifying the returned builder
102      * won't affect the existing {@link IoSession}s at all, because
103      * {@link IoFilterChainBuilder}s affect only newly created {@link IoSession}s.
104      *
105      * @throws IllegalStateException if the current {@link IoFilterChainBuilder} is
106      * not a {@link DefaultIoFilterChainBuilder}
107      */

108     DefaultIoFilterChainBuilder getFilterChain();
109 }
110
Popular Tags