XMOJO 5 API Docs

com.adventnet.adaptors.html
Class HtmlAdaptor

java.lang.Object
  |
  +--com.adventnet.adaptors.AbstractAdaptor
        |
        +--com.adventnet.adaptors.html.HtmlAdaptor
All Implemented Interfaces:
Adaptor, DynamicMBean, java.util.EventListener, MBeanRegistration, NotificationBroadcaster, NotificationFilter, NotificationListener, java.io.Serializable

public class HtmlAdaptor
extends AbstractAdaptor
implements DynamicMBean, NotificationListener, NotificationFilter, MBeanRegistration

This class acts as a JMX adaptor for HTTP access to mbeans.

It itself acts as a mbean for exposing the http properties. This class extends the AbstractAdaptor which provides the implementation of ServiceInfo interface and acts as the web-server.

For example, to start the web-server at 8050, you can specify the following object name:

  • DefaultDomain:type=HtmlAdaptor

    See Also:
    Serialized Form

    Field Summary
    static com.adventnet.adaptors.html.HtmlAuthTable htmlAuth
               
    static boolean readFromJarFile
              Specifies whether read from Jar File is enabled; the default is false.
     
    Fields inherited from class com.adventnet.adaptors.AbstractAdaptor
    port, state
     
    Constructor Summary
    HtmlAdaptor()
              The NoArg constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    HtmlAdaptor(boolean isJarFile)
              This constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    HtmlAdaptor(int portNum)
              This constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    HtmlAdaptor(java.lang.Integer portNum)
               
    HtmlAdaptor(java.lang.Integer portNum, MBeanServer MBServer)
              This constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    HtmlAdaptor(java.lang.Integer portNum, MBeanServer MBServer, boolean isJarFile)
              This constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    HtmlAdaptor(java.lang.String homeDir)
              This constructor will be used to initialize the HtmlAdaptor (when the application is started from a different application directory) in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
     
    Method Summary
     void addHttpServerInterface(HttpServerInterface httpIntf)
              Adds HttpServerInterface for controlling WebServer.
     void addHttpServerListener(java.lang.Object l)
              Deprecated. Now the HttpServerInterface is used to plug-in WebServers to HTML Adaptor.
     void bind()
              Must be used to bind to a naming service or to bind to a ServerSocket
    static void deleteClientInfo(java.lang.String id, java.lang.String user)
               
     void destroyAdaptor()
              This method is used to destroy the adaptor
     void disableAllTypes()
              Disables all types of notifications
     void disableType(java.lang.String prefix)
              Disables the type of notification in the parameter
     void enableAuthentication(boolean authFlag)
              enables the authentication feature of the adaptor.
     void enableAuthorisation(boolean authFlag)
              enables the authorisation feature of the adaptor.
     void enableType(java.lang.String prefix)
              Enables the type of notification in the parameter
     ObjectName getAdaptorObjectName()
              Gets the ObjectName of this adaptor with which it has been registered with the MBeanServer.
     java.lang.Object getAttribute(java.lang.String attribute)
              Gets the value of a specific attribute of this MBean.
     AttributeList getAttributes(java.lang.String[] attributes)
              Enables the values of several attributes of this MBean.
     boolean getAuthentication()
              Gets the authentication feature of the User.
    static java.util.Hashtable getConfTable()
               
     java.util.Vector getEnabledTypes()
              Gets all the enabled notifications
    static com.adventnet.adaptors.html.HtmlAuthTable getHtmlAuth()
               
    static HtmlPageProp getHtmlPageProp(java.lang.String userName)
               
     MBeanInfo getMBeanInfo()
              This method discovers the attributes and operations this MBean exposes for management.
    static MBeanServer getMBeanServer()
              Getter for MBean server.
    static java.util.ArrayList getNotificationList()
               
     java.lang.String getObjectName()
              Gets the ObjectName which are registered with the MBeanServer.
    static java.lang.String getParentDirectory()
              Gets the parent directory for this adaptor
     java.lang.String getProtocol()
              Gets the protocol supported by this adaptor.
    static java.lang.String getUserName(java.lang.String id)
               
    static com.adventnet.adaptors.html.UserViewInterface getUserViewIntf()
              Gets the values of UserviewInterface.
     void handleNotification(Notification notification, java.lang.Object handback)
              Invoked when an JMX notification occurs.
     void instantiateAdaptor()
              Must be implemented by the adaptor and should be used to instantiate itsefl
     java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
              Invokes an action on this MBean.
    static boolean isAuthenticated()
              Gets the authentication feature of the User.
     boolean isAuthenticationEnabled()
               
     boolean isNotificationEnabled(Notification notification)
              Invoked before sending the specified notification to the listener
     boolean isNotificationEnabled(Notification notification, NotificationListener listener, java.lang.Object handback)
               
    static boolean isValidUser(java.lang.String userName, java.lang.String password)
               
     void postDeregister()
              Allows this MBean to perform any operations needed after having been de-registered in the MBeanServer.
     void postRegister(java.lang.Boolean registrationDone)
              Allows this MBean to perform any operations needed after having been registered in the MBeanServer or after the registration has failed.
     void preDeregister()
              Allows this MBean to perform any operations it needs before being de-registered by the MBeanServer.
     ObjectName preRegister(MBeanServer server, ObjectName name)
              This method is an implementation of MBeanRegistration interface.
     void processClientRequests()
               
     void registerAuthentication()
              This method enable the Authentication Support.
     void restartHttpServer()
              Restarts the WebServer.
     void setAttribute(Attribute attribute)
              Sets the value of a specific attribute of this MBean.
     AttributeList setAttributes(AttributeList attributes)
              Sets the values of several attributes of this MBean.
     void setHtmlAuth(com.adventnet.adaptors.html.HtmlAuthTable htmlAuth)
               
    static void setHtmlPageProp(java.lang.String userName, HtmlPageProp htmlPageProp)
               
     void setLogFile(java.lang.String fileName)
              Sets the logfile with the given filename parameter
     void setMaxNotifFileCount(int count)
              Sets the maximum number of notification file
     void setNotifFileSize(long size)
              Sets the notification file size
    static void setParentDir(java.lang.String dirName)
              Sets the parents diectory for this adaptor
     void setPort(java.lang.Integer portNum)
              This function is used to set the port of HtmlAdaptor.
     void setUserView(com.adventnet.adaptors.html.UserViewInterface userIntf)
              Sets the values of UserviewInterface.
     void startHttpServer()
              Starts the WebServer by calling the HttpServerInterface's startHttpServer method.
     void startService()
              Allows the web-server to get started.
     void stopHttpServer()
              Method to stop the http server.
     void stopService()
              Allows the web-server to get stopped.
     void unbind()
              Must be used to unbind from a naming service or to relese a ServerSocket
    static boolean updateClientInfo(java.lang.String id, java.lang.String user, java.lang.String passwd)
               
     
    Methods inherited from class com.adventnet.adaptors.AbstractAdaptor
    addNotificationListener, changeState, getAdaptorVersion, getHost, getNotificationInfo, getPort, getState, getStateInString, isActive, isSecure, removeNotificationListener, setPort
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    htmlAuth

    public static com.adventnet.adaptors.html.HtmlAuthTable htmlAuth

    readFromJarFile

    public static boolean readFromJarFile
    Specifies whether read from Jar File is enabled; the default is false.
    Constructor Detail

    HtmlAdaptor

    public HtmlAdaptor()
    The NoArg constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    See Also:

    HtmlAdaptor

    public HtmlAdaptor(java.lang.String homeDir)
    This constructor will be used to initialize the HtmlAdaptor (when the application is started from a different application directory) in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    Parameters:
    homeDir -  
    See Also:

    HtmlAdaptor

    public HtmlAdaptor(int portNum)
    This constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    Parameters:
    port - number
    See Also:

    HtmlAdaptor

    public HtmlAdaptor(java.lang.Integer portNum)

    HtmlAdaptor

    public HtmlAdaptor(java.lang.Integer portNum,
                       MBeanServer MBServer)
    This constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    Parameters:
    port - number
    server - The MBeanServer in which the MBean will be registered.
    See Also:

    HtmlAdaptor

    public HtmlAdaptor(boolean isJarFile)
    This constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    Parameters:
    isJarFile - Boolean value to indicate whether HtmlAdaptor.prp is in jar or not.
    See Also:

    HtmlAdaptor

    public HtmlAdaptor(java.lang.Integer portNum,
                       MBeanServer MBServer,
                       boolean isJarFile)
    This constructor used to initialize the HtmlAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServerFactory.findMBeanServer(..) method.
    Parameters:
    port - number
    server - The MBeanServer in which the MBean will be registered.
    isJarFile - Boolean value to indicate whether HtmlAdaptor.prp is in jar or not.
    See Also:
    Method Detail

    setPort

    public void setPort(java.lang.Integer portNum)
                 throws java.lang.Exception
    This function is used to set the port of HtmlAdaptor.
    Parameters:
    port - number

    isAuthenticationEnabled

    public boolean isAuthenticationEnabled()

    setUserView

    public void setUserView(com.adventnet.adaptors.html.UserViewInterface userIntf)
    Sets the values of UserviewInterface.
    Parameters:
    UserviewInterface -  

    getUserViewIntf

    public static com.adventnet.adaptors.html.UserViewInterface getUserViewIntf()
    Gets the values of UserviewInterface.
    Returns:
    UserviewInterface

    instantiateAdaptor

    public void instantiateAdaptor()
                            throws java.lang.InstantiationException
    Description copied from class: AbstractAdaptor
    Must be implemented by the adaptor and should be used to instantiate itsefl
    Overrides:
    instantiateAdaptor in class AbstractAdaptor

    bind

    public void bind()
    Description copied from class: AbstractAdaptor
    Must be used to bind to a naming service or to bind to a ServerSocket
    Overrides:
    bind in class AbstractAdaptor

    unbind

    public void unbind()
    Description copied from class: AbstractAdaptor
    Must be used to unbind from a naming service or to relese a ServerSocket
    Overrides:
    unbind in class AbstractAdaptor

    registerAuthentication

    public void registerAuthentication()
    This method enable the Authentication Support.

    getAdaptorObjectName

    public ObjectName getAdaptorObjectName()
    Gets the ObjectName of this adaptor with which it has been registered with the MBeanServer.
    Overrides:
    getAdaptorObjectName in class AbstractAdaptor
    Returns:
    the ObjectName

    getObjectName

    public java.lang.String getObjectName()
    Gets the ObjectName which are registered with the MBeanServer.
    Returns:
    the String

    destroyAdaptor

    public void destroyAdaptor()
    This method is used to destroy the adaptor
    Overrides:
    destroyAdaptor in class AbstractAdaptor

    processClientRequests

    public void processClientRequests()

    getConfTable

    public static java.util.Hashtable getConfTable()

    getMBeanInfo

    public MBeanInfo getMBeanInfo()
    This method discovers the attributes and operations this MBean exposes for management.
    Specified by:
    getMBeanInfo in interface DynamicMBean
    Returns:
    An instance of MBeanInfo allowing to retrieve all attributes and operations of this MBean.

    getAttribute

    public java.lang.Object getAttribute(java.lang.String attribute)
                                  throws AttributeNotFoundException,
                                         MBeanException,
                                         ReflectionException
    Gets the value of a specific attribute of this MBean.
    Specified by:
    getAttribute in interface DynamicMBean
    Parameters:
    attribute - A String specifying the name of the attribute to be retrieved.
    Returns:
    The value of the retrieved attribute.
    Throws:
    AttributeNotFoundException - The specified attribute is not accessible in the MBean.
    MBeanException - The constructor of the MBean has thrown an exception
    ReflectionException - Wraps a ClassNotFoundException or a java.lang.Exception that occured trying to invoke the MBean's constructor.
    See Also:

    getAttributes

    public AttributeList getAttributes(java.lang.String[] attributes)
    Enables the values of several attributes of this MBean.
    Specified by:
    getAttributes in interface DynamicMBean
    Parameters:
    attributes - A list of attributes to be retrieved.
    Returns:
    The value of the retrieved attributes as attributeList.
    See Also:

    invoke

    public java.lang.Object invoke(java.lang.String actionName,
                                   java.lang.Object[] params,
                                   java.lang.String[] signature)
                            throws MBeanException,
                                   ReflectionException
    Invokes an action on this MBean.
    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 using the same class loader as the one used for loading the MBean on which the action was invoked.
    Returns:
    The object returned by the action, which represents the result ofinvoking the action on the specified MBean.
    Throws:
    MBeanException - The constructor of the MBean has thrown an exception
    ReflectionException - Wraps a ClassNotFoundException or a java.lang.Exception that occured trying to invoke the MBean's constructor.

    setAttribute

    public void setAttribute(Attribute attribute)
                      throws AttributeNotFoundException,
                             InvalidAttributeValueException,
                             MBeanException,
                             ReflectionException
    Sets the value of a specific attribute of this MBean.
    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 - The specified attribute is not accessible in the MBean.
    InvalidAttributeValueException - The specified value for the attribute is not valid.
    MBeanException - The constructor of the MBean has thrown an exception
    ReflectionException - Wraps a ClassNotFoundException or a java.lang.Exception that occured trying to invoke the MBean's constructor.
    See Also:

    setAttributes

    public AttributeList setAttributes(AttributeList attributes)
    Sets the values of several attributes of this MBean.
    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.
    See Also:

    preRegister

    public ObjectName preRegister(MBeanServer server,
                                  ObjectName name)
                           throws java.lang.Exception
    This method is an implementation of MBeanRegistration interface. Allows this MBean to perform any operations it needs before being registered in the MBeanServer. If the name of the MBean is not specified, the MBean can provide a name for its registration. If any exception is raised, the MBean will not be registered with the MBeanServer.

    This method is called by the MBeanServer before this mbean getting registered with the server. If the passed objectName is invalid, the returned objectName is taken as valid name to get registered with the server.

    The service gets actually started only inside this method at the specified port mentioned in the key "port". If the key "port" is absent, then the service(http web-server) gets started at the default port 8030.

    Specified by:
    preRegister in interface MBeanRegistration
    Overrides:
    preRegister in class AbstractAdaptor
    Parameters:
    server - The MBeanServer in which the MBean will be registered.
    name - The object name of the MBean.
    Returns:
    The name of the MBean registered.
    Throws:
    java.lang.Exception - This exception should be caught by the MBeanServer and re-thrown as an MBeanRegistrationException.

    postRegister

    public void postRegister(java.lang.Boolean registrationDone)
    Allows this MBean to perform any operations needed after having been registered in the MBeanServer or after the registration has failed.
    Specified by:
    postRegister in interface MBeanRegistration
    Overrides:
    postRegister in class AbstractAdaptor
    Parameters:
    registrationDone - Indicates whether or not the MBean has been successfully registered in the MBeanServer. The value false means that either the registration phase has failed.

    preDeregister

    public void preDeregister()
                       throws java.lang.Exception
    Allows this MBean to perform any operations it needs before being de-registered by the MBeanServer.
    Specified by:
    preDeregister in interface MBeanRegistration
    Overrides:
    preDeregister in class AbstractAdaptor
    Throws:
    java.langException - This exception should be caught by the MBeanServer and re-thrown as an MBeanRegistrationException.

    postDeregister

    public void postDeregister()
    Allows this MBean to perform any operations needed after having been de-registered in the MBeanServer.
    Specified by:
    postDeregister in interface MBeanRegistration
    Overrides:
    postDeregister in class AbstractAdaptor

    handleNotification

    public void handleNotification(Notification notification,
                                   java.lang.Object handback)
    Invoked when an JMX notification occurs.
    Specified by:
    handleNotification in interface NotificationListener
    Parameters:
    notification - - The notification.
    handback - - An opaque object which helps the listener to associate information regarding the MBean emitter. This object was passed to the MBean during the addListener call and resend, without modification, to the listener. The MBean object should to use or modify the object.

    setNotifFileSize

    public void setNotifFileSize(long size)
    Sets the notification file size
    Parameters:
    size - of the file in long

    setMaxNotifFileCount

    public void setMaxNotifFileCount(int count)
    Sets the maximum number of notification file
    Parameters:
    number - of files in int

    setLogFile

    public void setLogFile(java.lang.String fileName)
    Sets the logfile with the given filename parameter
    Parameters:
    fileName - String name of the file

    getNotificationList

    public static java.util.ArrayList getNotificationList()

    isNotificationEnabled

    public boolean isNotificationEnabled(Notification notification,
                                         NotificationListener listener,
                                         java.lang.Object handback)

    isNotificationEnabled

    public boolean isNotificationEnabled(Notification notification)
    Invoked before sending the specified notification to the listener
    Specified by:
    isNotificationEnabled in interface NotificationFilter
    Parameters:
    notification - - The notification to be sent.
    Returns:
    True if the notification has to be sent to the listener, false otherwise

    disableAllTypes

    public void disableAllTypes()
    Disables all types of notifications

    disableType

    public void disableType(java.lang.String prefix)
    Disables the type of notification in the parameter
    Parameters:
    prefix - Notification type

    enableType

    public void enableType(java.lang.String prefix)
    Enables the type of notification in the parameter
    Parameters:
    prefix - Notification type

    getEnabledTypes

    public java.util.Vector getEnabledTypes()
    Gets all the enabled notifications
    Returns:
    Vector The enabled notifications

    startService

    public void startService()
                      throws java.lang.IllegalStateException,
                             java.lang.Exception
    Allows the web-server to get started. exception IllegalStateException
    Overrides:
    startService in class AbstractAdaptor
    Following copied from class: com.adventnet.adaptors.AbstractAdaptor
    Throws:
    java.lang.IllegalStateException - when the adaptor is in STARTED or STARTING state

    stopService

    public void stopService()
                     throws java.lang.IllegalStateException
    Allows the web-server to get stopped.
    Overrides:
    stopService in class AbstractAdaptor
    Following copied from class: com.adventnet.adaptors.AbstractAdaptor
    Throws:
    java.lang.IllegalStateException - when the adaptor is in STOPPED or STOPPING state

    getAuthentication

    public boolean getAuthentication()
    Gets the authentication feature of the User.
    Returns:
    true if the authentication enabled else false.

    isAuthenticated

    public static boolean isAuthenticated()
    Gets the authentication feature of the User.
    Returns:
    true if the authentication enabled else false.

    enableAuthentication

    public void enableAuthentication(boolean authFlag)
    enables the authentication feature of the adaptor.
    Overrides:
    enableAuthentication in class AbstractAdaptor
    Returns:
    void.

    enableAuthorisation

    public void enableAuthorisation(boolean authFlag)
    enables the authorisation feature of the adaptor.
    Overrides:
    enableAuthorisation in class AbstractAdaptor
    Returns:
    void.

    getMBeanServer

    public static MBeanServer getMBeanServer()
    Getter for MBean server.
    Returns:
    the MBean server reference.

    addHttpServerListener

    public void addHttpServerListener(java.lang.Object l)
    Deprecated. Now the HttpServerInterface is used to plug-in WebServers to HTML Adaptor.

    Add the specified HttpServerListener to receive the event HttpServerEvent from this HtmlAdaptor class. The event is passed when HttpServer is started. If listener is null no exception is thrown and no action is performed.
    Since:
    AdventNet Agent Toolkit (Java Edition) 4.2 release.

    startHttpServer

    public void startHttpServer()
                         throws java.lang.Exception
    Starts the WebServer by calling the HttpServerInterface's startHttpServer method.
    See Also:
    stopHttpServer

    stopHttpServer

    public void stopHttpServer()
                        throws java.lang.Exception
    Method to stop the http server.
    See Also:
    startHttpServer

    restartHttpServer

    public void restartHttpServer()
                           throws java.lang.Exception
    Restarts the WebServer.
    Throws:
    on - error while restarting WebServer.
    Since:
    AdventNet Agent Toolkit (Java Edition) 4.2 release.
    See Also:

    getProtocol

    public java.lang.String getProtocol()
    Gets the protocol supported by this adaptor.
    Overrides:
    getProtocol in class AbstractAdaptor
    Returns:
    The protocol supported by this adaptor.

    addHttpServerInterface

    public void addHttpServerInterface(HttpServerInterface httpIntf)
    Adds HttpServerInterface for controlling WebServer. Users can add their implementation of HttpServerInterface to plug-in other webserver.
    Parameters:
    httpIntf - The HttpServerInterface of the user.

    setParentDir

    public static void setParentDir(java.lang.String dirName)
    Sets the parents diectory for this adaptor
    Parameters:
    dirName - String name of the parent directory

    getParentDirectory

    public static java.lang.String getParentDirectory()
    Gets the parent directory for this adaptor
    Returns:
    The parent directory

    setHtmlAuth

    public void setHtmlAuth(com.adventnet.adaptors.html.HtmlAuthTable htmlAuth)

    getHtmlAuth

    public static com.adventnet.adaptors.html.HtmlAuthTable getHtmlAuth()

    getHtmlPageProp

    public static HtmlPageProp getHtmlPageProp(java.lang.String userName)

    getUserName

    public static java.lang.String getUserName(java.lang.String id)

    setHtmlPageProp

    public static void setHtmlPageProp(java.lang.String userName,
                                       HtmlPageProp htmlPageProp)

    isValidUser

    public static boolean isValidUser(java.lang.String userName,
                                      java.lang.String password)

    updateClientInfo

    public static boolean updateClientInfo(java.lang.String id,
                                           java.lang.String user,
                                           java.lang.String passwd)

    deleteClientInfo

    public static void deleteClientInfo(java.lang.String id,
                                        java.lang.String user)

    XMOJO 5 API Docs

    Copyright ©2003 XMOJO.org. All Rights Reserved.