Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jdmk.comm
Class HtmlAdaptorServer

    java.lang.Object
      |
      +--com.sun.jdmk.comm.CommunicatorServer
            |
            +--com.sun.jdmk.comm.HtmlAdaptorServer

public class HtmlAdaptorServer
extends CommunicatorServer
implements MBeanRegistration, DynamicMBean

This class 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:

http://host:port

where:

- host is the host name of the machine on which the agent is running.
- port is the port number used by the HTML server in the agent.

The HTML protocol adaptor provides the following main HTML pages for managing MBeans in an agent:

- Agent View: Provides a list of object names of all the MBeans registered in the agent.
- Agent Administration: Registers and unregisters MBeans in the agent.
- MBean View: Reads and writes MBean attributes and perform operations on MBeans in the agent.

The HTML protocol adaptor goes ONLINE at preregistration. During preregistration it will create a TCP/IP socket and listen for client connections. 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:

- Reload period is at least 5 seconds.
- Only types that returns a valid (not null) string when `toString()` is called are displayed.
- Array of class are always displayed in read only mode.
- Arrays of dimension 2 and higher are not fully expanded.
- Only supported types (listed below) are supported as parameters of operations.
- List of supported types (for reading and writing):
  - `boolean Boolean Boolean[]`
  - `byte byte[] Byte Byte[]`
  - `char char[] Character Character[]`
  - `Date Date[]`
  - `double double[] Double Double[]`
  - `float float[] Float Float[]`
  - `int int[] Integer Integer[]`
  - `long long[] Long Long[]`
  - `Number`
  - `javax.management.ObjectName javax.management.ObjectName[]`
  - `short Short Short[]`
  - `String String[]`
  Note: 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.

See Also:
  Serialized Form

Fields inherited from class com.sun.jdmk.comm.CommunicatorServer
`dbgTag, host, HTML_TYPE, HTTP_TYPE, HTTPS_TYPE, infoType, maxActiveClientCount, mbs, objectName, OFFLINE, ONLINE, port, RMI_TYPE, servedClientCount, SNMP_TYPE, STARTING, state, STOPPING`

Constructor Summary
`HtmlAdaptorServer()` Constructs an `HtmlAdaptorServer` that will use the default port (8082).
`HtmlAdaptorServer(int p)` Constructs the `HtmlAdaptorServer` that will use the specified port.

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` | `doProcess()` Handles the requests recieved.
`protected void` | `doReceive()` Collects incoming requests.
`protected void` | `doUnbind()` Unbinds the HTML protocol adaptor.
`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()` Returns the name of the last connected client.
`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`.
`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` | `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
`changeState, debug, debug, debug, debug, getActiveClientCount, getHost, getMaxActiveClientCount, getMBeanServer, getObjectName, getPort, getServedClientCount, getState, getStateString, isActive, isDebugOn, isTraceOn, makeDebugTag, makeThreadName, run, setMaxActiveClientCount, setPort, start, trace, trace, waitState`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### HtmlAdaptorServer

    public HtmlAdaptorServer()

  Constructs an `HtmlAdaptorServer` that will use the default port (8082).

### HtmlAdaptorServer

    public HtmlAdaptorServer(int p)

  Constructs the `HtmlAdaptorServer` that will use the specified port.
  Parameters:
    `p` - An integer representing a valid port number.

Method Detail

### setParser

    public void setParser(ObjectName parser)
                   throws InstanceNotFoundException,
                          ServiceNotFoundException

  Sets the MBean that will be used to parse the incoming HTML requests or to built the outgoing HTML pages. This MBean must implement HtmlParser and must already be regitered in the agent's MBean server.
  Parameters:
    `parser` - the ObjectName of the HTML parser MBean.
  Throws:
    InstanceNotFoundException - The HTML parser does not exist in the repository.
    ServiceNotFoundException - The requested service is not supported.

### getParser

    public ObjectName getParser()

  Returns the ObjectName of the currently designated HTML parser MBean.
  Returns:
    The ObjectName thet is the current value of the Parser attribute.

### resetParser

    public void resetParser()

  Sets the ObjectName of the Parser attribute to null

### createParser

    public void createParser(java.lang.String className,
                             java.lang.String parserName,
                             java.lang.String loaderName)
                      throws MalformedObjectNameException,
                             ReflectionException,
                             InstanceAlreadyExistsException,
                             MBeanRegistrationException,
                             MBeanException,
                             NotCompliantMBeanException,
                             InstanceNotFoundException

  Creates and registers in the MBeanServer the HTML parser MBean used by the HtmlAdaptorServer to parse incomming requests or build outgoing HTML pages
  Parameters:
    `className` - the class that contains the parsing procedures
    `parserObjectName` - the String used as an object name to register the parser into the MBeanServer
    `loaderObjectName` - the loader user to obtain the class of the parser
  Throws:
    MalformedObjectNameException - the string passed in parameter does not have the right format.
    ReflectionException - Wraps Wraps a ClassNotFoundException or a java.lang.Exception that occured 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.

### getLastConnectedClient

    public java.lang.String getLastConnectedClient()

  Returns the name of the last connected client.
  Returns:
    The IP address of the last connected client.

### getProtocol

    public java.lang.String getProtocol()

  Returns the protocol of this `HtmlAdaptorServer`.
  Returns:
    The string "html".
  Overrides:
    getProtocol in class CommunicatorServer

### addUserAuthenticationInfo

    public void addUserAuthenticationInfo(AuthInfo authinfo)

  Adds the authentication information of the user to be authenticated by this server. In order to populate the list of users supported by this server invoke this method for each user you want to add.
  Parameters:
    `authinfo` - the user authentication information.

### removeUserAuthenticationInfo

    public void removeUserAuthenticationInfo(AuthInfo authinfo)

  Removes the authentication information of the given user from the list of users authenticated by this server.
  Parameters:
    `authinfo` - the user authentication information.

### isAuthenticationOn

    public boolean isAuthenticationOn()

  Returns true if the list of users supported by this server is not empty.
  Returns:
    True, if the list of users supported by this server is not empty. False, if the list of supported users is empty so no authentication is performed by this server.

### stop

    public void stop()

  Stops the HTML protocol adaptor.
  Overrides:
    stop in class CommunicatorServer

### preRegister

    public ObjectName preRegister(MBeanServer server,
                                  ObjectName name)
                           throws java.lang.Exception

  Creates a TCP/IP connection to listen for client connections.

  If no object name is provided, the server will use a default object name (defaultDomain:name=HtmlAdaptorServer).

  Specified by:
    preRegister in interface MBeanRegistration
  Parameters:
    `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).
  Returns:
    The name of the HTML protocol adaptor registered.
  Throws:
    java.langException - This exception should be caught by the MBeanServer and re-thrown as an MBeanRegistrationException.
  Overrides:
    preRegister in class CommunicatorServer

### postRegister

    public void postRegister(java.lang.Boolean registrationDone)

  Does nothing, needed for `MBeanRegistration` interface.
  Specified by:
    postRegister in interface MBeanRegistration
  Overrides:
    postRegister in class CommunicatorServer

### preDeregister

    public void preDeregister()
                       throws java.lang.Exception

  Interrupts all the current HTTP connections and close the TCP/IP socket.
  Specified by:
    preDeregister in interface MBeanRegistration
  Throws:
    java.lang.Exception - This exception should be caught by the MBeanServer and re-thrown as an MBeanRegistrationException.
  Overrides:
    preDeregister in class CommunicatorServer

### postDeregister

    public void postDeregister()

  Does nothing, needed for `MBeanRegistration` interface.
  Specified by:
    postDeregister in interface MBeanRegistration
  Overrides:
    postDeregister in class CommunicatorServer

### getMBeanInfo

    public MBeanInfo getMBeanInfo()

  Gets the exposed attributes and actions of the HTML protocol adaptor.
  Specified by:
    getMBeanInfo in interface DynamicMBean
  Returns:
    An instance of MBeanInfo containing all attributes and actions exposed by the HTML protocol adaptor.

### getAttribute

    public java.lang.Object getAttribute(java.lang.String attribute)
                                  throws AttributeNotFoundException,
                                         MBeanException,
                                         ReflectionException

  Gets the value of a specific attribute of the HTML protocol adaptor.
  Specified by:
    getAttribute in interface DynamicMBean
  Parameters:
    `attribute` - The name of the attribute to be retrieved
  Returns:
    The value of the specified attribute
  Throws:
    AttributeNotFoundException -
    MBeanException - Wraps an exception thrown by the MBean's getter.
    ReflectionException - Wraps an java.lang.Exception thrown while trying to invoke the getter.

### getAttributes

    public AttributeList getAttributes(java.lang.String[] attributes)

  Gets the values of several attributes of the HTML server.
  Specified by:
    getAttributes in interface DynamicMBean
  Parameters:
    `attributes` - Enables the values of several attributes of the Dynamic MBean.
  Returns:
    The list of retrieved attributes.

### invoke

    public java.lang.Object invoke(java.lang.String actionName,
                                   java.lang.Object[] params,
                                   java.lang.String[] signature)
                            throws MBeanException,
                                   ReflectionException

  Invokes a specific operation on the HTML protocol adaptor.
  Specified by:
    invoke in interface DynamicMBean
  Parameters:
    `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.
  Returns:
    The result returned by the specific action.
  Throws:
    MBeanException - Wraps an exception thrown by the MBean's invoked method.
    ReflectionException - Wraps an java.lang.Exception thrown while trying to invoke the method

### setAttribute

    public void setAttribute(Attribute attribute)
                      throws AttributeNotFoundException,
                             InvalidAttributeValueException,
                             MBeanException,
                             ReflectionException

  Sets the value of a specific attribute of the HTML protocol adaptor.
  Specified by:
    setAttribute in interface DynamicMBean
  Parameters:
    `attribute` - The identification of the attribute to be set and the value it is to be set to.
  Throws:
    AttributeNotFoundException -
    InvalidAttributeValueException -
    MBeanException - Wraps an exception thrown by the MBean's setter.
    ReflectionException - Wraps an exception thrown while trying to invoke the MBean's setter.

### setAttributes

    public AttributeList setAttributes(AttributeList attributes)

  Sets the values of several attributes of the HTML protocol adaptor.
  Specified by:
    setAttributes in interface DynamicMBean
  Parameters:
    `attributes` - A list of attributes: The identification of the attributes to be set and the values they are to be set to.
  Returns:
    The list of attributes that were set, with their new values.

### doBind

    protected void doBind()
                   throws CommunicationException,
                          java.lang.InterruptedException

  Binds the HTML protocol adaptor.

  Create a socket listener.

  Overrides:
    doBind in class CommunicatorServer

### doUnbind

    protected void doUnbind()
                     throws CommunicationException,
                            java.lang.InterruptedException

  Unbinds the HTML protocol adaptor.

  Close the socket listener.

  Overrides:
    doUnbind in class CommunicatorServer

### doReceive

    protected void doReceive()
                      throws CommunicationException,
                             java.lang.InterruptedException

  Collects incoming requests.
  Overrides:
    doReceive in class CommunicatorServer

### doProcess

    protected void doProcess()
                      throws CommunicationException,
                             java.lang.InterruptedException

  Handles the requests recieved.
  Overrides:
    doProcess in class CommunicatorServer

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD