XMOJO 5 API Docs

com.adventnet.adaptors.rmi
Class RMIAdaptor

java.lang.Object
  |
  +--com.adventnet.adaptors.AbstractAdaptor
        |
        +--com.adventnet.adaptors.rmi.RMIAdaptor
All Implemented Interfaces:
Adaptor, DynamicMBean, MBeanRegistration, NotificationBroadcaster, java.io.Serializable

public class RMIAdaptor
extends AbstractAdaptor
implements DynamicMBean

This class acts as a JMX adaptor for RMI protocol.

It itself acts as a mbean for exposing the RMI properties. This class extends the SimpleAdaptor which provides the implementation of ServiceInfo interface and acts as the RMI server.

The port number of the service can be specified in the ObjectName with key-value pair as, port=1099(by default)

For example, to start the RMI server at 1150, you can specify the following object name:

  • DefaultDomain:type=com.adventnet.adaptors.rmi.RMIAdaptor,protocol=rmi,port=1150

    See Also:
    Serialized Form

    Field Summary
     java.rmi.registry.Registry registry
               
     
    Fields inherited from class com.adventnet.adaptors.AbstractAdaptor
    port, state
     
    Constructor Summary
    RMIAdaptor()
              The NoArg constructor used to initialize the RMIAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServer.findJMXAgent(...) method.
     
    Method Summary
     void addUser(com.adventnet.agent.security.UserContext userContext)
              Adds the users specified in the UserContext to the Authentication List of the Adaptor
     void bind()
              Binds the rmi server at the specified port
     void destroyAdaptor()
              Removes the RemoteMBeanServerImpl from the RMI runtime
     void enableAuthentication(boolean authenticate)
              Enables Authentication for the RMI Adaptor
     void enableAuthorisation(boolean authorise)
              Enables Authorisation for the RMI Adaptor
     ObjectName getAdaptorObjectName()
              Returns 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.
     MBeanInfo getMBeanInfo()
              This method discovers the attributes and operations this MBean exposes for management.
     java.lang.String getObjectName()
              Returns the ObjectName of this adaptor with which it has been registered with the MBeanServer.
     java.lang.String getPersistantName()
              Returns the name of the serialized file in which the User Context details are stored.
     java.lang.String getProtocol()
              Gets the protocol supported by this adaptor.
     void instantiateAdaptor()
              Instantiates the RMI Adaptor
     java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
              Invokes an action on the original MBean associated with this MBean.
     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 removeUser(com.adventnet.agent.security.UserContext userContext)
              Removes the users specified in the UserContext from the Authentication List of the Adaptor
     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 setPersistantName(java.lang.String fileName)
              Sets the name of the serialized file in which the User Context details are stored
     void setPort(java.lang.Integer port)
               
     java.rmi.registry.Registry startRegistry(int port)
              Starts the RMI Registry at the specified port.
     void unbind()
              Allows the service to get stopped.
     
    Methods inherited from class com.adventnet.adaptors.AbstractAdaptor
    addNotificationListener, changeState, getAdaptorVersion, getHost, getNotificationInfo, getPort, getState, getStateInString, isActive, isSecure, removeNotificationListener, setPort, startService, stopService
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    registry

    public java.rmi.registry.Registry registry
    Constructor Detail

    RMIAdaptor

    public RMIAdaptor()
    The NoArg constructor used to initialize the RMIAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServer.findJMXAgent(...) method.
    See Also:
    Method Detail

    setPort

    public void setPort(java.lang.Integer port)
                 throws java.lang.Exception

    setPersistantName

    public void setPersistantName(java.lang.String fileName)
    Sets the name of the serialized file in which the User Context details are stored
    Parameters:
    fileName - The name of the file in which the User Context details are to be stored

    getPersistantName

    public java.lang.String getPersistantName()
    Returns the name of the serialized file in which the User Context details are stored.
    Returns:
    The name of the serialized file in which the User Context details are stored

    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.

    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.

    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 the original MBean associated with 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.
    Returns:
    The value of the attribute that has been set.
    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.

    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.

    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(RMI) gets started at the default port 1099. The rmiregistry gets created here. If suppose the port is already occupied, the server creation gets failed. If registry is started already in the same port, inorder to use it ,the already started registry should have the classpath to the rmi skeleton files.

    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.

    instantiateAdaptor

    public void instantiateAdaptor()
                            throws java.lang.InstantiationException
    Instantiates the RMI Adaptor
    Overrides:
    instantiateAdaptor in class AbstractAdaptor

    bind

    public void bind()
    Binds the rmi server at the specified port
    Overrides:
    bind in class AbstractAdaptor

    startRegistry

    public java.rmi.registry.Registry startRegistry(int port)
                                             throws java.rmi.RemoteException
    Starts the RMI Registry at the specified port.
    Parameters:
    port - The port at which the RMI Registry has to be started
    Throws:
    java.rmi.RemoteException - when the

    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.
    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.
    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.
    Overrides:
    postDeregister in class AbstractAdaptor

    unbind

    public void unbind()
    Allows the service to get stopped.
    Overrides:
    unbind in class AbstractAdaptor

    getAdaptorObjectName

    public ObjectName getAdaptorObjectName()
    Returns 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()
    Returns the ObjectName of this adaptor with which it has been registered with the MBeanServer.
    Returns:
    the ObjectName

    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.

    enableAuthentication

    public void enableAuthentication(boolean authenticate)
    Enables Authentication for the RMI Adaptor
    Overrides:
    enableAuthentication in class AbstractAdaptor
    Parameters:
    authenticate - Enables Authentication if the value is true

    enableAuthorisation

    public void enableAuthorisation(boolean authorise)
    Enables Authorisation for the RMI Adaptor
    Overrides:
    enableAuthorisation in class AbstractAdaptor
    Parameters:
    authorise - Enables Authentication if the value is true

    addUser

    public void addUser(com.adventnet.agent.security.UserContext userContext)
    Adds the users specified in the UserContext to the Authentication List of the Adaptor
    Parameters:
    userContext - The UserContext which has to be added

    removeUser

    public void removeUser(com.adventnet.agent.security.UserContext userContext)
    Removes the users specified in the UserContext from the Authentication List of the Adaptor
    Parameters:
    userContext - The UserContext which has to be removed

    destroyAdaptor

    public void destroyAdaptor()
    Removes the RemoteMBeanServerImpl from the RMI runtime
    Overrides:
    destroyAdaptor in class AbstractAdaptor
    See Also:
    RemoteMBeanServerImpl

    XMOJO 5 API Docs

    Copyright ©2003 XMOJO.org. All Rights Reserved.