|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.jdmk.comm.CommunicatorServer
com.sun.jdmk.comm.HtmlAdaptorServer
public class 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.jdmk.ServiceName.DOMAIN
and com.sun.jdmk.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[]
e.g. 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[]
com.sun.jdmk.Enumerated
: Supported for readable attributes. As com.sun.jdmk.Enumerated
is an abstract class,
only write-only attributes whose actual subclass is declared in the signature of its setter, can be set through the Html adaptor.
toString()
method is called.
boolean Boolean
byte Byte
char Character
Date
e.g. 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.
Field Summary |
---|
Fields inherited from class com.sun.jdmk.comm.CommunicatorServer |
---|
HTML_TYPE, HTTP_TYPE, HTTPS_TYPE, OFFLINE, ONLINE, RMI_TYPE, SNMP_TYPE, 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(String className,
String parserName,
String loaderName)
Creates and registers in the MBeanServer the HTML parser
MBean used by the HtmlAdaptorServer to parse incoming
requests or build outgoing HTML pages. |
protected void |
doBind()
Binds the HTML protocol adaptor. |
protected void |
doError(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 . |
Object |
getAttribute(String attribute)
Gets the value of a specific attribute of the HTML protocol adaptor. |
AttributeList |
getAttributes(String[] attributes)
Gets the values of several attributes of the HTML server. |
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. |
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. |
Object |
invoke(String actionName,
Object[] params,
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(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 |
---|
addNotificationListener, getHost, getMBeanServer, getNotificationInfo, getPort, getState, getStateString, isActive, removeNotificationListener, run, setMBeanServer, 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.jdmk.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 registered in the agent's MBean server.
parser
- the ObjectName
of the HTML parser MBean.
InstanceNotFoundException
- The HTML parser does not exist in the repository.
ServiceNotFoundException
- The requested service is not supported.public ObjectName getParser()
ObjectName
that is the current value of the Parser attribute.public void resetParser()
public void createParser(String className, String parserName, String loaderName) throws MalformedObjectNameException, ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
MBeanServer
the HTML parser
MBean used by the HtmlAdaptorServer
to parse incoming
requests or build outgoing HTML pages.
className
- the class that contains the parsing proceduresparserName
- the String used as an object name to register
the parser into the MBeanServer
loaderName
- the loader user to obtain the class of the
parser
MalformedObjectNameException
- The string passed in the
parameters does not have the right format.
ReflectionException
- Wraps a ClassNotFoundException
or a Exception
that occurred when trying
to invoke the MBean's constructor.
InstanceAlreadyExistsException
- The MBean is already under
the control of the MBeanServer
.
MBeanRegistrationException
- The preRegister
(MBeanRegistration
interface) method of the
MBean has thrown an exception. The MBean will not be
registered.
MBeanException
- The constructor of the MBean has
thrown an exception.
InstanceNotFoundException
- The specified class loader is
not registered in the MBeanServer
.
NotCompliantMBeanException
public String getLastConnectedClient()
InetAddress
public String getProtocol()
HtmlAdaptorServer
.
getProtocol
in interface CommunicatorServerMBean
getProtocol
in class CommunicatorServer
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 IllegalStateException
HtmlAdaptorServer
can process concurrently.
c
- The number of clients.
IllegalStateException
- This method has been invoked
while the communicator was ONLINE or STARTING.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()
Has no effect if this SNMP protocol adaptor is OFFLINE
or
STOPPING
.
stop
in interface CommunicatorServerMBean
stop
in class CommunicatorServer
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
If no object name is provided, the server will use a default object name (defaultDomain:name=HtmlAdaptorServer).
preRegister
in interface MBeanRegistration
preRegister
in class CommunicatorServer
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).
java.langException
- This exception should be caught by the MBeanServer
and re-thrown
as an MBeanRegistrationException
.
Exception
- This exception should be caught by
the MBeanServer
and re-thrown
as an MBeanRegistrationException
.public void postRegister(Boolean registrationDone)
MBeanRegistration
interface.
postRegister
in interface MBeanRegistration
postRegister
in class CommunicatorServer
registrationDone
- Indicates whether or not the MBean has been
successfully registered in the MBeanServer
.
The value false means that the registration phase has failed.public void preDeregister() throws Exception
preDeregister
in interface MBeanRegistration
preDeregister
in class CommunicatorServer
Exception
- This exception should be caught by the MBeanServer and re-thrown
as an MBeanRegistrationException.public void postDeregister()
MBeanRegistration
interface.
postDeregister
in interface MBeanRegistration
postDeregister
in class CommunicatorServer
public MBeanInfo getMBeanInfo()
getMBeanInfo
in interface DynamicMBean
public Object getAttribute(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. |
getAttribute
in interface DynamicMBean
attribute
- The name of the attribute to be retrieved
AttributeNotFoundException
- The specified attribute does not exist or cannot be retrieved.
MBeanException
- Wraps an exception thrown by the MBean's getter.
ReflectionException
- Wraps an java.lang.Exception thrown while trying to invoke the getter.public AttributeList getAttributes(String[] attributes)
For a list of possible attributes look at the method getAttribute
.
getAttributes
in interface DynamicMBean
attributes
- Enables the values of several attributes of the Dynamic MBean.
public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException
Invokes the following operations of the HTML protocol adaptor:
Name | Signature | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
resetParser | () | Remove the customization from HtmlAdaptorServer by resetting 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. |
invoke
in interface DynamicMBean
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.
MBeanException
- Wraps an exception thrown by the MBean's invoked method.
ReflectionException
- Wraps an java.lang.Exception thrown while trying to invoke the methodpublic 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. |
setAttribute
in interface DynamicMBean
attribute
- The identification of the attribute to
be set and the value it is to be set to.
AttributeNotFoundException
- The specified attribute does not exist or cannot be retrieved.
InvalidAttributeValueException
- The specified value is not a valid value for the attribute.
MBeanException
- Wraps an exception thrown by the MBean's setter.
ReflectionException
- Wraps an exception thrown while trying to invoke the MBean's setter.public AttributeList setAttributes(AttributeList attributes)
For a list of possible attributes look at the method setAttribute
.
setAttributes
in interface DynamicMBean
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(Exception e) throws CommunicationException
doError
in class CommunicatorServer
CommunicationException
protected void doBind() throws CommunicationException, InterruptedException
Create a socket listener.
doBind
in class CommunicatorServer
CommunicationException
- Communication problem while creating listener socket.
InterruptedException
- Creating listener socket was interrupted.protected void doUnbind() throws CommunicationException, InterruptedException
Close the socket listener.
doUnbind
in class CommunicatorServer
CommunicationException
- Communication problem while closing listener socket.
InterruptedException
- Closing listener socket was interrupted.protected void doReceive() throws CommunicationException, InterruptedException
doReceive
in class CommunicatorServer
CommunicationException
- Communication problem while receiving request.
InterruptedException
- Receiving request was interrupted.protected void doProcess() throws CommunicationException, InterruptedException
doProcess
in class CommunicatorServer
CommunicationException
- Communication problem while processing request.
InterruptedException
- Request processing was interrupted.
|
Open Source build 02 opendmk-1.0-b02 2007.10.01_19:17:46_MEST |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |