01: /*
02: * Copyright (c) xsocket.org, 2006 - 2008. All rights reserved.
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Please refer to the LGPL license at: http://www.gnu.org/copyleft/lesser.txt
19: * The latest copy of this software may be found on http://www.xsocket.org/
20: */
21: package org.xsocket;
22:
23: import java.io.Closeable;
24: import java.io.IOException;
25: import java.util.Set;
26:
27: /**
28: * A Dispatcher encapsulates an underlying Selector. It is responsible
29: * for the channel handle management. If a readiness event occurs, the
30: * assigned {@link IDispatcherEventHandler} will be called.
31: *
32: * <br/><br/><b>This is a xSocket internal class and subject to change</b>
33: *
34: * @author grro@xsocket.org
35: */
36: public interface IDispatcher<T extends IHandle> extends Runnable,
37: Closeable {
38:
39: /**
40: * get the event handler of this dispatcher <br><br>.
41: *
42: * This method is thread save
43: *
44: * @return the event handler
45: */
46: public IDispatcherEventHandler<T> getEventHandler();
47:
48: /**
49: * register a new handle. <br><br>.
50: *
51: * This method is thread save
52: *
53: * @param handle the handle to register
54: * @param ops the interest set
55: * @throws IOException If some I/O error occurs
56: */
57: public void register(T handle, int ops) throws IOException;
58:
59: /**
60: * deregister a handle. <br> <br>
61: *
62: * This method is thread save
63: *
64: * @param handle the handle to deregister
65: * @throws IOException If some I/O error occurs
66: */
67: public void deregister(final T handle) throws IOException;
68:
69: /**
70: * return the registered handles
71: *
72: * @return a list of the registered handles
73: */
74: public Set<T> getRegistered();
75:
76: /**
77: * announce a write for he given handle. <br><br>
78: *
79: * This method is thread save
80: *
81: * @param handle the handle for the write need
82: * @param ops the interest set
83: * @throws IOException if the given hnadle is invalid
84: */
85: public void updateInterestSet(T handle, int ops) throws IOException;
86: }
|