com.adventnet.services.discovery
Class DiscoveryService

java.lang.Object
  extended by com.adventnet.services.discovery.DiscoveryService
All Implemented Interfaces:
javax.management.DynamicMBean, javax.management.MBeanRegistration

public class DiscoveryService
extends java.lang.Object
implements javax.management.DynamicMBean, javax.management.MBeanRegistration

The DiscoveryService is the mbean responds to the discovery requests. JMX agent that needs to be discovered must instantiate and register this mbean. When startService is called it broadcasts discoveryPacket in the multicast group


Field Summary
(package private)  DiscoverySocket dsock
           
(package private)  javax.management.MBeanServer server
          the MBeanServer
(package private)  java.util.Properties userData
           
 
Constructor Summary
DiscoveryService()
          Default constructor
DiscoveryService(java.lang.String multicastGroup, int multicastPort)
          Constructor which takes multicast group and multicast port as parameters
DiscoveryService(java.lang.String multicastGroup, int multicastPort, java.lang.String hostName)
          Constructor which takes multicast group , multicast port and hostName as parameters
 
Method Summary
 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 getMulticastGroup()
          Gets the multicast group.
 int getMulticastPort()
          gets the multicast port used by this discovery service.
 java.lang.Integer getState()
          Returns the state, whether ON_STATE/OFF_STATE, of this service.
 int getTimeToLive()
          Gets the time to live (hop count).
 java.util.Properties getUserData()
          Gets the user defined data which will be sent in the discovery packet
 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.
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
           
 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 setHostAddress(java.lang.String host)
          This method is used to set the host address on which this service is running.
 void setMulticastGroup(java.lang.String multicastGroup)
          Sets the multicast group.
 void setMulticastPort(int multicastPort)
          sets the multicast port used by this discovery service.
 void setMulticastPort(java.lang.Integer multicastPort)
          sets the multicast port used by this discovery service.
 void setTimeToLive(int timeToLive)
          Sets the time to live.
 void setTimeToLive(java.lang.Integer timeToLive)
          Sets the time to live.
 void setUserData(java.util.Properties userData)
          Sets the user defined data which will be sent in the discovery packet
 void startService()
          Allows the service to get started.
 void stopService()
          Allows the service to get stopped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dsock

DiscoverySocket dsock

server

transient javax.management.MBeanServer server
the MBeanServer


userData

java.util.Properties userData
Constructor Detail

DiscoveryService

public DiscoveryService()
Default constructor


DiscoveryService

public DiscoveryService(java.lang.String multicastGroup,
                        int multicastPort)
Constructor which takes multicast group and multicast port as parameters


DiscoveryService

public DiscoveryService(java.lang.String multicastGroup,
                        int multicastPort,
                        java.lang.String hostName)
Constructor which takes multicast group , multicast port and hostName as parameters

Method Detail

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.

setHostAddress

public void setHostAddress(java.lang.String host)
This method is used to set the host address on which this service is running.


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
javax.management.MBeanException
javax.management.ReflectionException

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
javax.management.ReflectionException

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
javax.management.InvalidAttributeValueException
javax.management.MBeanException
javax.management.ReflectionException

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.

getMulticastGroup

public java.lang.String getMulticastGroup()
Gets the multicast group. Default is 225.225.225.225


setMulticastGroup

public void setMulticastGroup(java.lang.String multicastGroup)
                       throws java.lang.Exception
Sets the multicast group.

Throws:
java.lang.Exception

getMulticastPort

public int getMulticastPort()
gets the multicast port used by this discovery service. Default is 8222


setMulticastPort

public void setMulticastPort(int multicastPort)
                      throws java.lang.Exception
sets the multicast port used by this discovery service.

Throws:
java.lang.Exception

setMulticastPort

public void setMulticastPort(java.lang.Integer multicastPort)
                      throws java.lang.Exception
sets the multicast port used by this discovery service.

Throws:
java.lang.Exception

getTimeToLive

public int getTimeToLive()
Gets the time to live (hop count). Default value is 5


setTimeToLive

public void setTimeToLive(int timeToLive)
Sets the time to live.


setTimeToLive

public void setTimeToLive(java.lang.Integer timeToLive)
Sets the time to live.


getUserData

public java.util.Properties getUserData()
Gets the user defined data which will be sent in the discovery packet


setUserData

public void setUserData(java.util.Properties userData)
Sets the user defined data which will be sent in the discovery packet


startService

public void startService()
Allows the service to get started. When started it broadcasts a discovery packet with all the adaptors information


stopService

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


getState

public java.lang.Integer getState()
Returns the state, whether ON_STATE/OFF_STATE, of this service.

See Also:
com.adventnet.adaptors.common.SimpleAdaptor.ON_STATE, com.adventnet.adaptors.common.SimpleAdaptor.OFF_STATE

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName name)
                                        throws java.lang.Exception
Specified by:
preRegister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

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
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.
registrationDone - indicates whether the mbean is registered properly with the server.

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
Throws:
java.langException - This exception should be caught by the MBeanServer and re-thrown as an MBeanRegistrationException.
java.lang.Exception

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