org.jmx4odp.j4oNet
Class JmxServiceObj

java.lang.Object
  extended by org.jmx4odp.j4oNet.JmxServiceObj
All Implemented Interfaces:
java.io.Serializable

public class JmxServiceObj
extends java.lang.Object
implements java.io.Serializable

This is an object that represents a JMX accesable service: MBean or Agent This data container holds all the data needed to locate a JMX server or any of it's MBean services. All the data is stored in a Hashtable, using keys suffixed with "_jso" Additional data can be stored via the generic put and get methods, but it should use a different suffix for name space. The basic information for a MBean is server address:rmi port:ObjectName with the attributes of NetworkDomain, NameSpace, and Class. This is the data the the Resolvers will use match and route request.

Author:
Lucas McGregor
See Also:
Serialized Form

Constructor Summary
JmxServiceObj()
          Creates new JmxServiceObj
 
Method Summary
 java.lang.Object clone()
           
 boolean containsKey(java.lang.String key)
           
 void fromDataString(java.lang.String data)
          Will configure this JSO from a data string
 java.lang.Object get(java.lang.String key)
           
 java.util.Hashtable getAttributes()
          get the entire attribute set as a hashtable
 java.lang.String getClassName()
           
 java.lang.Object getDirectReference()
           
 java.net.InetAddress getInetAddress(java.lang.String key)
          return an attribute cast as an InetAddress
 int getInt(java.lang.String key)
          return an attribute cast as an int, return -1 if there is an error or no such attribute
 javax.management.MBeanServer getMBeanServer()
           
 java.net.InetAddress getMultiCastGroup()
           
 int getMultiCastListenPort()
           
 java.lang.String getNameSpace()
           
 java.lang.String getNetworkDomain()
           
 javax.management.ObjectInstance getObjectInstance()
           
 javax.management.ObjectName getObjectName()
           
 int getRating()
          The rating of this JSO agent
 java.lang.String getRemoteAdaptorAddress()
           
 int getRemoteAdaptorPort()
           
 java.lang.String getRemoteAdaptorProtocol()
           
 java.lang.String getRemoteAdaptorUrl()
          If the JSO is a remote service, this url should point to its agent If this has been explicitly set, it will return the explictly set one.
 java.lang.String getString(java.lang.String key)
          return an attribute cast as an String
 int getType()
          The code for this type of JSO agent
 boolean isAgent()
          returns true if ObjectName and ClassName are null, meaning that this is an agentID and not an MBeanID
 void put(java.lang.String key, java.lang.Object obj)
          Put an attribute with this key If the attribute is null, then make sure to remove it from the hashmap
 java.lang.Object remove(java.lang.String key)
          removes the keyed object from the attributes
 void setAttributes(java.util.Hashtable ht)
          set the entire attribute set as a hashtable.
 void setClassName(java.lang.String className)
          The class name of the object that serves this JSO
 void setDirectReference(java.lang.Object obj)
          Some objects may set a JSO with a direct refence to it's object.
 void setMBeanServer(javax.management.MBeanServer mbs)
          A reference to the MBeanServer that serves this JSO
 void setMultiCastGroup(java.net.InetAddress ia)
          Set the Multicast group address of this JSO service
 void setMultiCastGroup(java.lang.String s)
           
 void setMultiCastListenPort(int i)
          Set the Multicast group port of this JSO service
 void setNameSpace(java.lang.String s)
          This is the name space that the MBeanServer lives in.
 void setNetworkDomain(java.lang.String s)
          This defines a single network unit that should be all able to talk to each other over the multicast group.
 void setObjectInstance(javax.management.ObjectInstance oi)
          When setting this value, it will over write and ObjectName that has already been set with the one in the ObjectInstance
 void setObjectName(javax.management.ObjectName on)
          The Object Name of the MBean serving this JSO
 void setRating(int i)
           
 void setRemoteAdaptorAddress(java.lang.String s)
          Set the JMX service address for this JSO
 void setRemoteAdaptorPort(int i)
          Set the JMX service port for this JSO
 void setRemoteAdaptorProtocol(java.lang.String s)
          Set the JMX service protocol for this JSO
 void setRemoteAdaptorUrl(java.lang.String url)
          If the JSO is a remote service, this url should point to its agent If this has been explicitly set, it will return the explictly set one.
 void setType(int i)
           
 java.lang.String toDataString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JmxServiceObj

public JmxServiceObj()
Creates new JmxServiceObj

Method Detail

setDirectReference

public void setDirectReference(java.lang.Object obj)
Some objects may set a JSO with a direct refence to it's object. This refence is a WeakReference, so it will not prevent the garbage collection of the referenced object. So there is no gauarntee that the object refeneced will exist by the time the JSO is read. The WeakReference is also marked transient as to prevent serialization problems. So it is a good idea to use the DirectReference to provide for possible optimization, but the ObjectName should also be set, in case the reference is claimed, or cannot be serialized.


getDirectReference

public java.lang.Object getDirectReference()

getAttributes

public java.util.Hashtable getAttributes()
get the entire attribute set as a hashtable


setAttributes

public void setAttributes(java.util.Hashtable ht)
set the entire attribute set as a hashtable. This remove any attributes already set in the object and repopulate the attributes with this hashtable


isAgent

public boolean isAgent()
returns true if ObjectName and ClassName are null, meaning that this is an agentID and not an MBeanID


setRemoteAdaptorUrl

public void setRemoteAdaptorUrl(java.lang.String url)
If the JSO is a remote service, this url should point to its agent If this has been explicitly set, it will return the explictly set one. Else, it will attempt to use the getRemoteAdaptorAddress, getRemoteAdapatorPort, and getRemoteAdaptorProtocol to try and create one.


getRemoteAdaptorUrl

public java.lang.String getRemoteAdaptorUrl()
If the JSO is a remote service, this url should point to its agent If this has been explicitly set, it will return the explictly set one. Else, it will attempt to use the getRemoteAdaptorAddress, getRemoteAdapatorPort, and getRemoteAdaptorProtocol to try and create one.


setRemoteAdaptorProtocol

public void setRemoteAdaptorProtocol(java.lang.String s)
Set the JMX service protocol for this JSO


getRemoteAdaptorProtocol

public java.lang.String getRemoteAdaptorProtocol()

setRemoteAdaptorAddress

public void setRemoteAdaptorAddress(java.lang.String s)
Set the JMX service address for this JSO


getRemoteAdaptorAddress

public java.lang.String getRemoteAdaptorAddress()

setRemoteAdaptorPort

public void setRemoteAdaptorPort(int i)
Set the JMX service port for this JSO


getRemoteAdaptorPort

public int getRemoteAdaptorPort()

setObjectName

public void setObjectName(javax.management.ObjectName on)
The Object Name of the MBean serving this JSO


getObjectName

public javax.management.ObjectName getObjectName()

setMBeanServer

public void setMBeanServer(javax.management.MBeanServer mbs)
A reference to the MBeanServer that serves this JSO


getMBeanServer

public javax.management.MBeanServer getMBeanServer()

setNameSpace

public void setNameSpace(java.lang.String s)
This is the name space that the MBeanServer lives in. This may span networks. I.E. the "admin" name space might be all the admin mbean servers that run across serveral networks. This is a heirarchical attribute that is seperated on the "." Thus admin.westcost is a child of admin


getNameSpace

public java.lang.String getNameSpace()

setNetworkDomain

public void setNetworkDomain(java.lang.String s)
This defines a single network unit that should be all able to talk to each other over the multicast group. Their is a seperate attribute because two different networks might use the same multicast address and port, but be on seperate network segments, thus even though these attrubutes are the same, they are not part of the same NetworkDomain


getNetworkDomain

public java.lang.String getNetworkDomain()

setClassName

public void setClassName(java.lang.String className)
The class name of the object that serves this JSO


getClassName

public java.lang.String getClassName()

setMultiCastGroup

public void setMultiCastGroup(java.net.InetAddress ia)
Set the Multicast group address of this JSO service


setMultiCastGroup

public void setMultiCastGroup(java.lang.String s)
                       throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

getMultiCastGroup

public java.net.InetAddress getMultiCastGroup()

setMultiCastListenPort

public void setMultiCastListenPort(int i)
Set the Multicast group port of this JSO service


getMultiCastListenPort

public int getMultiCastListenPort()

setObjectInstance

public void setObjectInstance(javax.management.ObjectInstance oi)
When setting this value, it will over write and ObjectName that has already been set with the one in the ObjectInstance


getObjectInstance

public javax.management.ObjectInstance getObjectInstance()

getType

public int getType()
The code for this type of JSO agent


setType

public void setType(int i)

getRating

public int getRating()
The rating of this JSO agent


setRating

public void setRating(int i)

getInt

public int getInt(java.lang.String key)
return an attribute cast as an int, return -1 if there is an error or no such attribute


getString

public java.lang.String getString(java.lang.String key)
return an attribute cast as an String


getInetAddress

public java.net.InetAddress getInetAddress(java.lang.String key)
return an attribute cast as an InetAddress


put

public void put(java.lang.String key,
                java.lang.Object obj)
Put an attribute with this key If the attribute is null, then make sure to remove it from the hashmap


get

public java.lang.Object get(java.lang.String key)
Returns:
the attribute with this key

containsKey

public boolean containsKey(java.lang.String key)
Returns:
true if the attributes has an object by this key

remove

public java.lang.Object remove(java.lang.String key)
removes the keyed object from the attributes


clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toDataString

public java.lang.String toDataString()
Returns:
a data string that serializes the configuration of this JSO

fromDataString

public void fromDataString(java.lang.String data)
                    throws java.lang.Exception
Will configure this JSO from a data string

Throws:
java.lang.Exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object