KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xsocket > stream > IServerContext


1 //$Id: IServerContext.java 1423 2007-07-02 06:56:18Z 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 package org.xsocket.stream;
23
24 import java.net.InetAddress JavaDoc;
25 import java.util.concurrent.Executor JavaDoc;
26
27 import org.xsocket.Resource;
28
29
30
31 /**
32  * Represents the handler's server context. The context object will be set by using dependency injection.
33  * To do this the {@link Resource} annotation has to be used.<br>
34  *
35  * E.g.
36  * <pre>
37  * class MyHandler implements IDataHandler {
38  *
39  * &#064Resource
40  * private IServerContext ctx;
41  *
42  * public boolean onData(INonBlockingConnection connection) throws IOException, BufferUnderflowException {
43  * ...
44  * int srvPort = ctx.getLocalePort();
45  * ...
46  *
47  * return true;
48  * }
49  * }
50  * </pre>
51  *
52  * @author grro@xsocket.org
53  */

54 public interface IServerContext {
55
56     /**
57      * get the local server port
58      *
59      * @return the local server port
60      */

61     public int getLocalePort();
62         
63     
64     /**
65      * get the local server address
66      *
67      * @return the local server address
68      */

69     public InetAddress JavaDoc getLocaleAddress();
70     
71     /**
72      * get the number of the open server connections
73      *
74      * @return the number of the open connections
75      */

76     public int getNumberOfOpenConnections();
77         
78
79     /**
80      * return the worker pool
81      *
82      * @return the worker pool
83      */

84     public Executor JavaDoc getWorkerpool();
85 }
86
Popular Tags