KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jmx > snmp > daemon > CommunicatorServerMBean


1 /*
2  * @(#)file CommunicatorServerMBean.java
3  * @(#)author Sun Microsystems, Inc.
4  * @(#)version 1.25
5  * @(#)lastedit 03/12/19
6  *
7  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
8  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
9  *
10  */

11
12
13 package com.sun.jmx.snmp.daemon;
14
15
16
17 /**
18  * Defines generic behaviour for the server
19  * part of a connector or an adaptor. Most connectors or adaptors extend <CODE>CommunicatorServer</CODE>
20  * and inherit this behaviour. Connectors or adaptors that do not fit into this model do not extend
21  * <CODE>CommunicatorServer</CODE>.
22  * <p>
23  * An <CODE>CommunicatorServer</CODE> is an active object, it listens for client requests
24  * and processes them in its own thread. When necessary, a <CODE>CommunicatorServer</CODE>
25  * creates other threads to process multiple requests concurrently.
26  * <p>
27  * A <CODE>CommunicatorServer</CODE> object can be stopped by calling the <CODE>stop</CODE>
28  * method. When it is stopped, the <CODE>CommunicatorServer</CODE> no longer listens to client
29  * requests and no longer holds any thread or communication resources.
30  * It can be started again by calling the <CODE>start</CODE> method.
31  * <p>
32  * A <CODE>CommunicatorServer</CODE> has a <CODE>state</CODE> property which reflects its
33  * activity.
34  * <p>
35  * <TABLE>
36  * <TR><TH>CommunicatorServer</TH> <TH>State</TH></TR>
37  * <TR><TD><CODE>stopped</CODE></TD> <TD><CODE>OFFLINE</CODE></TD></TR>
38  * <TR><TD><CODE>starting</CODE></TD> <TD><CODE>STARTING</CODE></TD></TR>
39  * <TR><TD><CODE>running</CODE></TD> <TD><CODE>ONLINE</CODE></TD></TR>
40  * <TR><TD><CODE>stopping</CODE></TD> <TD><CODE>STOPPING</CODE></TD></TR>
41  * </TABLE>
42  * <p>
43  * The <CODE>STARTING</CODE> state marks the transition from <CODE>OFFLINE</CODE> to
44  * <CODE>ONLINE</CODE>.
45  * <p>
46  * The <CODE>STOPPING</CODE> state marks the transition from <CODE>ONLINE</CODE> to
47  * <CODE>OFFLINE</CODE>. This occurs when the <CODE>CommunicatorServer</CODE> is
48  * finishing or interrupting active requests.
49  * <p>
50  * A <CODE>CommunicatorServer</CODE> may serve several clients concurrently. The
51  * number of concurrent clients can be limited using the property
52  * <CODE>maxActiveClientCount</CODE>. The default value of this property is
53  * defined by the subclasses.
54  * <p>
55  * When a <CODE>CommunicatorServer</CODE> is unregistered from the MBeanServer,
56  * it is stopped automatically.
57  *
58  * <p><b>This API is a Sun Microsystems internal API and is subject
59  * to change without notice.</b></p>
60  * @version 1.25 12/19/03
61  * @author Sun Microsystems, Inc
62  */

63
64 public interface CommunicatorServerMBean {
65
66     /**
67      * Starts this <CODE>CommunicatorServer</CODE>.
68      * <p>
69      * Has no effect if this <CODE>CommunicatorServer</CODE> is <CODE>ONLINE</CODE> or
70      * <CODE>STOPPING</CODE>.
71      */

72     public void start() ;
73
74     /**
75      * Stops this <CODE>CommunicatorServer</CODE>.
76      * <p>
77      * Has no effect if this <CODE>CommunicatorServer</CODE> is <CODE>OFFLINE</CODE> or
78      * <CODE>STOPPING</CODE>.
79      */

80     public void stop() ;
81
82     /**
83      * Tests if the <CODE>CommunicatorServer</CODE> is active.
84      *
85      * @return True if connector is <CODE>ONLINE</CODE>; false otherwise.
86      */

87     public boolean isActive() ;
88
89     /**
90      * Waits untill either the State attribute of this MBean equals the specified <VAR>state</VAR> parameter,
91      * or the specified <VAR>timeOut</VAR> has elapsed. The method <CODE>waitState</CODE> returns with a boolean value indicating whether
92      * the specified <VAR>state</VAR> parameter equals the value of this MBean's State attribute at the time the method terminates.
93      *
94      * Two special cases for the <VAR>timeOut</VAR> parameter value are:
95      * <UL><LI> if <VAR>timeOut</VAR> is negative then <CODE>waitState</CODE> returns immediately (i.e. does not wait at all),</LI>
96      * <LI> if <VAR>timeOut</VAR> equals zero then <CODE>waitState</CODE> waits untill the value of this MBean's State attribute
97      * is the same as the <VAR>state</VAR> parameter (i.e. will wait indefinitely if this condition is never met).</LI></UL>
98      *
99      * @param state The value of this MBean's State attribute
100      * to wait for. <VAR>state</VAR> can be one of:
101      * <ul>
102      * <li><CODE>CommunicatorServer.OFFLINE</CODE>,</li>
103      * <li><CODE>CommunicatorServer.ONLINE</CODE>,</li>
104      * <li><CODE>CommunicatorServer.STARTING</CODE>,</li>
105      * <li><CODE>CommunicatorServer.STOPPING</CODE>.</li>
106      * </ul>
107      * @param timeOut The maximum time to wait for, in
108      * milliseconds, if positive.
109      * Infinite time out if 0, or no waiting at all if negative.
110      *
111      * @return true if the value of this MBean's State attribute is the
112      * same as the <VAR>state</VAR> parameter; false otherwise.
113      */

114     public boolean waitState(int state , long timeOut) ;
115
116     /**
117      * Gets the state of this <CODE>CommunicatorServer</CODE> as an integer.
118      *
119      * @return <CODE>ONLINE</CODE>, <CODE>OFFLINE</CODE>, <CODE>STARTING</CODE> or <CODE>STOPPING</CODE>.
120      */

121     public int getState() ;
122
123     /**
124      * Gets the state of this <CODE>CommunicatorServer</CODE> as a string.
125      *
126      * @return One of the strings "ONLINE", "OFFLINE", "STARTING" or "STOPPING".
127      */

128     public String JavaDoc getStateString() ;
129
130     /**
131      * Gets the host name used by this <CODE>CommunicatorServer</CODE>.
132      *
133      * @return The host name used by this <CODE>CommunicatorServer</CODE>.
134      */

135     public String JavaDoc getHost() ;
136
137     /**
138      * Gets the port number used by this <CODE>CommunicatorServer</CODE>.
139      *
140      * @return The port number used by this <CODE>CommunicatorServer</CODE>.
141      */

142     public int getPort() ;
143
144     /**
145      * Sets the port number used by this <CODE>CommunicatorServer</CODE>.
146      *
147      * @param port The port number used by this <CODE>CommunicatorServer</CODE>.
148      *
149      * @exception java.lang.IllegalStateException This method has been invoked
150      * while the communicator was ONLINE or STARTING.
151      */

152     public void setPort(int port) throws java.lang.IllegalStateException JavaDoc ;
153
154     /**
155      * Gets the protocol being used by this <CODE>CommunicatorServer</CODE>.
156      * @return The protocol as a string.
157      */

158     public abstract String JavaDoc getProtocol() ;
159 }
160
Popular Tags