KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xsocket > IDispatcher


1 // $Id: IDispatcher.java 1281 2007-05-29 19:48:07Z grro $
2
/*
3  * Copyright (c) xsocket.org, 2006 - 2007. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Please refer to the LGPL license at: http://www.gnu.org/copyleft/lesser.txt
20  * The latest copy of this software may be found on http://www.xsocket.org/
21  */

22
23 package org.xsocket;
24
25 import java.io.Closeable JavaDoc;
26 import java.io.IOException JavaDoc;
27 import java.util.Set JavaDoc;
28
29
30
31
32 /**
33  * A Dispatcher encapsulates an underlying Selector. It is responsible
34  * for the channel handle management. If a readiness event occurs, the
35  * assigned {@link IEventHandler} will be called.
36  *
37  * @author grro@xsocket.org
38  */

39 public interface IDispatcher<T extends IHandle> extends Runnable JavaDoc, Closeable JavaDoc {
40
41     /**
42      * get the event handler of this dispatcher <br><br>.
43      *
44      * This method is thread save
45      *
46      * @return the event handler
47      */

48     public IEventHandler<T> getEventHandler();
49
50     
51     
52     /**
53      * register a new handle. <br><br>.
54      *
55      * This method is thread save
56      *
57      * @param handle the handle to register
58      * @param ops the interest set
59      * @throws IOException If some I/O error occurs
60      */

61     public void register(T handle, int ops) throws IOException JavaDoc;
62     
63     
64     /**
65      * deregister a handle. <br> <br>
66      *
67      * This method is thread save
68      *
69      * @param handle the handle to deregister
70      * @throws IOException If some I/O error occurs
71      */

72     public void deregister(final T handle) throws IOException JavaDoc;
73
74     
75     /**
76      * return the registered handles
77      *
78      * @return a list of the registered handles
79      */

80     public Set JavaDoc<T> getRegistered();
81     
82     
83     /**
84      * announce a write for he given handle. <br><br>
85      *
86      * This method is thread save
87      *
88      * @param handle the handle for the write need
89      * @param ops the interest set
90      * @throws IOException if the given hnadle is invalid
91      */

92     public void updateInterestSet(T handle, int ops) throws IOException JavaDoc;
93     
94     
95     /**
96      * get the number of handled registractions
97      *
98      * @return the number of handled registractions
99      */

100     public long getNumberOfHandledRegistrations();
101     
102
103     /**
104      * get the number of handled reads
105      *
106      * @return the number of handled reads
107      */

108     public long getNumberOfHandledReads();
109
110     
111     /**
112      * get the number of handled writes
113      *
114      * @return the number of handled writes
115      */

116     public long getNumberOfHandledWrites();
117 }
118
Popular Tags