com.adventnet.adaptors.rmi
Class RMIAdaptor

java.lang.Object
  extended by com.adventnet.adaptors.AbstractAdaptor
      extended by com.adventnet.adaptors.rmi.RMIAdaptor
All Implemented Interfaces:
Adaptor, java.io.Serializable, java.util.EventListener, javax.management.DynamicMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationFilter, javax.management.NotificationListener

public class RMIAdaptor
extends AbstractAdaptor
implements javax.management.DynamicMBean, javax.management.NotificationListener, javax.management.NotificationFilter

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

    Nested Class Summary
     
    Nested classes/interfaces inherited from class com.adventnet.adaptors.AbstractAdaptor
    AbstractAdaptor.ProcessNotification
     
    Field Summary
     java.rmi.registry.Registry registry
               
     
    Fields inherited from class com.adventnet.adaptors.AbstractAdaptor
    notifications, port, processnotification, 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
     javax.management.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.
     javax.management.AttributeList getAttributes(java.lang.String[] attributes)
              Enables the values of several attributes of this MBean.
     javax.management.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.
     boolean isNotificationEnabled(javax.management.Notification notification)
              Invoked before sending the specified notification to the listener
     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.
     javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
              This method is an implementation of MBeanRegistration interface.
     void processNotification(javax.management.Notification notification, java.lang.Object handback)
              Invoked when an JMX notification occurs.
     void removeUser(com.adventnet.agent.security.UserContext userContext)
              Removes the users specified in the UserContext from the Authentication List of the Adaptor
     void setAttribute(javax.management.Attribute attribute)
              Sets the value of a specific attribute of this MBean.
     javax.management.AttributeList setAttributes(javax.management.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)
               
     void setSSLEnabled(boolean bool)
               
     void setSSLProps(java.util.Hashtable hash)
               
     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, handleNotification, isActive, isSecure, removeNotificationListener, setPort, startService, stopService
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     
    Methods inherited from interface javax.management.NotificationListener
    handleNotification
     

    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:
    preRegister(MBeanServer, ObjectName);
    Method Detail

    setPort

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

    setSSLEnabled

    public void setSSLEnabled(boolean bool)

    setSSLProps

    public void setSSLProps(java.util.Hashtable hash)

    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 javax.management.MBeanInfo getMBeanInfo()
    This method discovers the attributes and operations this MBean exposes for management.

    Specified by:
    getMBeanInfo in interface javax.management.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 javax.management.AttributeNotFoundException,
                                         javax.management.MBeanException,
                                         javax.management.ReflectionException
    Gets the value of a specific attribute of this MBean.

    Specified by:
    getAttribute in interface javax.management.DynamicMBean
    Parameters:
    attribute - A String specifying the name of the attribute to be retrieved.
    Returns:
    The value of the retrieved attribute.
    Throws:
    javax.management.AttributeNotFoundException - The specified attribute is not accessible in the MBean.
    javax.management.MBeanException - The constructor of the MBean has thrown an exception
    javax.management.ReflectionException - Wraps a ClassNotFoundException or a java.lang.Exception that occured trying to invoke the MBean's constructor.

    getAttributes

    public javax.management.AttributeList getAttributes(java.lang.String[] attributes)
    Enables the values of several attributes of this MBean.

    Specified by:
    getAttributes in interface javax.management.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 javax.management.MBeanException,
                                   javax.management.ReflectionException
    Invokes an action on the original MBean associated with this MBean.

    Specified by:
    invoke in interface javax.management.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:
    javax.management.MBeanException - The constructor of the MBean has thrown an exception
    javax.management.ReflectionException - Wraps a ClassNotFoundException or a java.lang.Exception that occured trying to invoke the MBean's constructor.

    setAttribute

    public void setAttribute(javax.management.Attribute attribute)
                      throws javax.management.AttributeNotFoundException,
                             javax.management.InvalidAttributeValueException,
                             javax.management.MBeanException,
                             javax.management.ReflectionException
    Sets the value of a specific attribute of this MBean.

    Specified by:
    setAttribute in interface javax.management.DynamicMBean
    Parameters:
    attribute - The identification of the attribute to be set and the value it is to be set to.
    Throws:
    javax.management.AttributeNotFoundException - The specified attribute is not accessible in the MBean.
    javax.management.InvalidAttributeValueException - The specified value for the attribute is not valid.
    javax.management.MBeanException - The constructor of the MBean has thrown an exception
    javax.management.ReflectionException - Wraps a ClassNotFoundException or a java.lang.Exception that occured trying to invoke the MBean's constructor.

    setAttributes

    public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
    Sets the values of several attributes of this MBean.

    Specified by:
    setAttributes in interface javax.management.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 javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                                   javax.management.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.

    Specified by:
    preRegister in interface javax.management.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.

    instantiateAdaptor

    public void instantiateAdaptor()
                            throws java.lang.InstantiationException
    Instantiates the RMI Adaptor

    Specified by:
    instantiateAdaptor in class AbstractAdaptor
    Throws:
    java.lang.InstantiationException

    bind

    public void bind()
    Binds the rmi server at the specified port

    Specified by:
    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.

    Specified by:
    postRegister in interface javax.management.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 javax.management.MBeanRegistration
    Overrides:
    preDeregister in class AbstractAdaptor
    Throws:
    java.lang.Exception - 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 javax.management.MBeanRegistration
    Overrides:
    postDeregister in class AbstractAdaptor

    unbind

    public void unbind()
    Allows the service to get stopped.

    Specified by:
    unbind in class AbstractAdaptor

    getAdaptorObjectName

    public javax.management.ObjectName getAdaptorObjectName()
    Returns the ObjectName of this adaptor with which it has been registered with the MBeanServer.

    Specified by:
    getAdaptorObjectName in interface Adaptor
    Specified by:
    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.

    Specified by:
    getProtocol in interface Adaptor
    Specified by:
    getProtocol in class AbstractAdaptor
    Returns:
    The protocol supported by this adaptor.

    enableAuthentication

    public void enableAuthentication(boolean authenticate)
    Enables Authentication for the RMI Adaptor

    Specified by:
    enableAuthentication in interface Adaptor
    Specified by:
    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

    Specified by:
    enableAuthorisation in interface Adaptor
    Specified by:
    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

    Specified by:
    destroyAdaptor in class AbstractAdaptor
    See Also:
    RemoteMBeanServerImpl

    isNotificationEnabled

    public boolean isNotificationEnabled(javax.management.Notification notification)
    Invoked before sending the specified notification to the listener

    Specified by:
    isNotificationEnabled in interface javax.management.NotificationFilter
    Parameters:
    notification - - The notification to be sent.
    Returns:
    True if the notification has to be sent to the listener, false otherwise

    processNotification

    public void processNotification(javax.management.Notification notification,
                                    java.lang.Object handback)
    Invoked when an JMX notification occurs.

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