|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jdmk.comm.CommunicatorServer | +--com.sun.jdmk.comm.HtmlAdaptorServer
Acts as an HTML server which allows an HTML browser to manage all MBeans in the agent. The HTML protocol adaptor is implemented as a dynamic MBean.
To connect a browser to the agent open this page in a web browser:
When the HTML protocol adaptor is started it creates a TCP/IP socket and listens for client connections.
The default port number of the socket is 8082. This default value can be changed by specifying a port number:
setPort
method before starting the adaptor
com.sun.management.jmx.ServiceName.DOMAIN
and com.sun.management.jmx.ServiceName.HTML_ADAPTOR_SERVER
.
If a client tries to connect, the HtmlAdaptorServer
creates a thread
which receives and processes all subsequent requests from this client. The number of
clients is limited by the maxActiveClientCount
property. The default value
of the maxActiveClientCount
is 10.
When an HtmlAdaptorServer
is stopped, all current HTTP connections
are interrupted (some requests may be terminated abruptly), and the TCP/IP
socket is closed.
The HtmlAdaptorServer
can perform user authentication. The add/remove
user authentication info methods can be used to manage users and their corresponding
authentication information. The HTML server uses the 'Basic Authentication Scheme'
(as defined in RFC 1945, section 11.1) to authenticate clients connecting to the server.
Limitations of the HTML protocol adaptor:
boolean boolean[] Boolean Boolean[]
byte Byte Byte[]
char char[] Character Character[]
Date Date[]
eg. September 30, 1999 8:49:04 PM CEST
double double[] Double Double[]
float float[] Float Float[]
int int[] Integer Integer[]
long Long Long[]
Number
javax.management.ObjectName javax.management.ObjectName[]
short Short Short[]
String String[]
toString()
method is called.
boolean Boolean
byte Byte
char Character
Date
eg. September 30, 1999 8:49:04 PM CEST
double Double
float Float
int Integer
long Long
Number
javax.management.ObjectName
short Short
String
Note 1: When reading a value of type Number
the server tries to convert it
first to an Integer, then a Long, then a Float and finally a Double, stopping at the first
which succeeds.
Note 2: Use the "Reload" button displayed in the HTML page of an MBean view rather than the reload button of the web-browser, otherwise you may invoke again the setters of all attributes if this was your last action.
Fields inherited from class com.sun.jdmk.comm.CommunicatorServer |
OFFLINE,
ONLINE,
STARTING,
STOPPING |
Constructor Summary | |
HtmlAdaptorServer()
Constructs an HtmlAdaptorServer that will use the default port (8082). |
|
HtmlAdaptorServer(int port)
Constructs the HtmlAdaptorServer that will use the specified port. |
|
HtmlAdaptorServer(int port,
AuthInfo[] authInfoList)
Constructs the HtmlAdaptorServer that will use the specified port
and user authentication information list. |
Method Summary | |
void |
addUserAuthenticationInfo(AuthInfo authinfo)
Adds the authentication information of the user to be authenticated by this server. |
void |
createParser(java.lang.String className,
java.lang.String parserName,
java.lang.String loaderName)
Creates and registers in the MBeanServer the HTML parser MBean used by the
HtmlAdaptorServer to parse incomming requests or build outgoing HTML pages. |
protected void |
doBind()
Binds the HTML protocol adaptor. |
protected void |
doError(java.lang.Exception e)
|
protected void |
doProcess()
Handles incoming requests. |
protected void |
doReceive()
Collects incoming requests. |
protected void |
doUnbind()
Unbinds the HTML protocol adaptor. |
int |
getActiveClientCount()
Gets the number of clients currently being processed by this HtmlAdaptorServer . |
java.lang.Object |
getAttribute(java.lang.String attribute)
Gets the value of a specific attribute of the HTML protocol adaptor. |
AttributeList |
getAttributes(java.lang.String[] attributes)
Gets the values of several attributes of the HTML server. |
java.lang.String |
getLastConnectedClient()
Gets the IP address of the last connected client. |
int |
getMaxActiveClientCount()
Gets the maximum number of clients that this HtmlAdaptorServer can
process concurrently. |
MBeanInfo |
getMBeanInfo()
Gets the exposed attributes and actions of the HTML protocol adaptor. |
ObjectName |
getParser()
Returns the ObjectName of the currently designated HTML parser MBean. |
java.lang.String |
getProtocol()
Returns the protocol of this HtmlAdaptorServer . |
int |
getServedClientCount()
Gets the number of clients that have been processed by this HtmlAdaptorServer
since its creation. |
java.lang.Object |
invoke(java.lang.String actionName,
java.lang.Object[] params,
java.lang.String[] signature)
Invokes a specific operation on the HTML protocol adaptor. |
boolean |
isAuthenticationOn()
Returns true if the list of users supported by this server is not empty. |
void |
postDeregister()
Does nothing, needed for MBeanRegistration interface. |
void |
postRegister(java.lang.Boolean registrationDone)
Does nothing, needed for MBeanRegistration interface. |
void |
preDeregister()
Interrupts all the current HTTP connections and close the TCP/IP socket. |
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
Creates a TCP/IP connection to listen for client connections. |
void |
removeUserAuthenticationInfo(AuthInfo authinfo)
Removes the authentication information of the given user from the list of users authenticated by this server. |
void |
resetParser()
Sets the ObjectName of the Parser attribute to null |
void |
setAttribute(Attribute attribute)
Sets the value of a specific attribute of the HTML protocol adaptor. |
AttributeList |
setAttributes(AttributeList attributes)
Sets the values of several attributes of the HTML protocol adaptor. |
void |
setMaxActiveClientCount(int c)
Sets the maximum number of clients this HtmlAdaptorServer can
process concurrently. |
void |
setParser(ObjectName parser)
Sets the MBean that will be used to parse the incoming HTML requests or to built the outgoing HTML pages. |
void |
stop()
Stops the HTML protocol adaptor. |
Methods inherited from class com.sun.jdmk.comm.CommunicatorServer |
getHost,
getPort,
getState,
getStateString,
isActive,
run,
setPort,
start,
waitState |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public HtmlAdaptorServer()
HtmlAdaptorServer
that will use the default port (8082).
The default port is defined in com.sun.management.jmx.ServiceName.HTML_ADAPTOR_PORT.
public HtmlAdaptorServer(int port)
HtmlAdaptorServer
that will use the specified port.port
- An integer representing a valid port number.public HtmlAdaptorServer(int port, AuthInfo[] authInfoList)
HtmlAdaptorServer
that will use the specified port
and user authentication information list.port
- An integer representing a valid port number.authInfoList
- The user authentication information list.Method Detail |
public void setParser(ObjectName parser) throws InstanceNotFoundException, ServiceNotFoundException
HtmlParser
and must already
be regitered in the agent's MBean server.parser
- the ObjectName
of the HTML parser MBean.public ObjectName getParser()
ObjectName
thet is the current value of the Parser attribute.public void resetParser()
public void createParser(java.lang.String className, java.lang.String parserName, java.lang.String loaderName) throws MalformedObjectNameException, ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
MBeanServer
the HTML parser MBean used by the
HtmlAdaptorServer
to parse incomming requests or build outgoing HTML pages.className
- the class that contains the parsing proceduresparserObjectName
- the String used as an object name to register the parser into the MBeanServer
loaderObjectName
- the loader user to obtain the class of the parserClassNotFoundException
or a java.lang.Exception
that occurred when trying to invoke the MBean's constructor.MBeanServer
.preRegister
(MBeanRegistration
interface) method of the MBean has thrown an exception. The MBean will not be registered.MBeanServer
.public java.lang.String getLastConnectedClient()
InetAddress
public java.lang.String getProtocol()
HtmlAdaptorServer
.public int getServedClientCount()
HtmlAdaptorServer
since its creation.HtmlAdaptorServer
since its creation. This counter is not reset by the stop
method.public int getActiveClientCount()
HtmlAdaptorServer
.HtmlAdaptorServer
.public int getMaxActiveClientCount()
HtmlAdaptorServer
can
process concurrently.HtmlAdaptorServer
can
process concurrently.public void setMaxActiveClientCount(int c) throws java.lang.IllegalStateException
HtmlAdaptorServer
can
process concurrently.c
- The number of clients.public void addUserAuthenticationInfo(AuthInfo authinfo)
authinfo
- the user authentication information.public void removeUserAuthenticationInfo(AuthInfo authinfo)
authinfo
- the user authentication information.public boolean isAuthenticationOn()
public void stop()
public ObjectName preRegister(MBeanServer server, ObjectName name) throws java.lang.Exception
If no object name is provided, the server will use a default object name (defaultDomain:name=HtmlAdaptorServer).
server
- The MBeanServer in which the HTML protocol adaptor will be registered.name
- The object name of the HTML protocol adaptor or null to specify the default object name
(defaultDomain:name=HtmlAdaptorServer).MBeanServer
and re-thrown
as an MBeanRegistrationException
.public void postRegister(java.lang.Boolean registrationDone)
MBeanRegistration
interface.registrationDone
- Indicates whether or not the MBean has been successfully registered in
the MBean server. The value false means that the registration phase has failed.public void preDeregister() throws java.lang.Exception
public void postDeregister()
MBeanRegistration
interface.public MBeanInfo getMBeanInfo()
public java.lang.Object getAttribute(java.lang.String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException
Gets the values for the following attributes of the HTML protocol adaptor:
Name | Type | Description |
---|---|---|
Active | boolean | True if the HtmlAdaptorServer is in the ONLINE state. |
ActiveClientCount | int | The number of clients being processed currently by the HtmlAdaptorServer. |
AuthenticationOn | boolean | True if the HtmlAdaptorServer requests authentication. |
Host | java.lang.String | Hostname. |
LastConnectedClient | java.lang.String | The IP address of the last connected client. |
MaxActiveClientCount | int | The maximum number of clients the HtmlAdaptorServer can process concurrently. |
Parser | ObjectName | ObjectName of the MBean used to customized HTML pages generated by the HtmlAdaptorServer. |
Port | int | Port number used. |
Protocol | java.lang.String | The communication protocol supported. (html) |
ServedClientCount | int | The number of clients that have been processed by the HtmlAdaptorServer since its creation. |
State | int | State of the HtmlAdaptorServer. |
StateString | java.lang.String | String representation of the HtmlAdaptorServer state. |
attribute
- The name of the attribute to be retrievedpublic AttributeList getAttributes(java.lang.String[] attributes)
For a list of possible attributes look at the method getAttribute
.
attributes
- Enables the values of several attributes of the Dynamic MBean.public java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature) throws MBeanException, ReflectionException
Invokes the following operations of the HTML protocol adaptor:
Name | Signature | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
resetParser | () | Remove the customization from HtmlAdaptorServer by reseting the Parser property to null. | |||||||||
createParser | (java.lang.String, java.lang.String, java.lang.String)
| Create and Register the HTML parser MBean in the MBeanServer and set the Parser attribute with the parser. | |||||||||
waitState | (int, long)
| Waits to be notified of a specific state change in the HtmlAdaptorServer. | |||||||||
stop | () | Stop the HtmlAdaptorServer. | |||||||||
start | () | Start the HtmlAdaptorServer. |
actionName
- The name of the action to be invoked.params
- An array containing the parameters to be set when the action is
invoked.signature
- An array containing the signature of the action. The class objects will
be loaded through the same class loader as the one used for loading the
HTML protocol adaptor.public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
Sets the following attributes of the HTML protocol adaptor:
Name | Type | Description |
---|---|---|
Port | int | Port number used. (NOTE: This can only be changed when the adaptor is OFFLINE) |
MaxActiveClientCount | int | The maximum number of clients the HtmlAdaptorServer can process concurrently. (NOTE: This can only be changed when the adaptor is OFFLINE) |
Parser | ObjectName | ObjectName of the HTML parser MBean used to customize the HTML pages generated by the HtmlAdaptorServer. |
attribute
- The identification of the attribute to
be set and the value it is to be set to.public AttributeList setAttributes(AttributeList attributes)
For a list of possible attributes look at the method setAttribute
.
attributes
- A list of attributes: The identification of the
attributes to be set and the values they are to be set to.protected void doError(java.lang.Exception e) throws CommunicationException
protected void doBind() throws CommunicationException, java.lang.InterruptedException
Create a socket listener.
protected void doUnbind() throws CommunicationException, java.lang.InterruptedException
Close the socket listener.
protected void doReceive() throws CommunicationException, java.lang.InterruptedException
protected void doProcess() throws CommunicationException, java.lang.InterruptedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |