Skip navigation links

Package com.caplin.management.jmx.relations

Defines the classes used to represent "to many" relationships within the Caplin JMX implementation.

See: Description

Package com.caplin.management.jmx.relations Description

Defines the classes used to represent "to many" relationships within the Caplin JMX implementation.

A RelationSet contains all the elements that belong to the "to many" side of a relationship. Examples of "to many" relationships are users to user sessions, user sessions to cached objects and cached objects to user sessions.

RelationSet example:

public void getAttribute(ObjectName objectName, String attributeName)
{
   // get the value of a specific attribute for a particular MBean
   Object attributeValue = mbeanServer.getAttribute(objectName, attributeName);
   
   if (attributeValue instanceof RelationSet)
   {
      // if the attribute is a RelationSet, add an update listener and register a notification listener and filter with the server
      RelationSet relationSet = (RelationSet) attributeValue;
         
      relationSet.addUpdateListener(new RelationSetUpdateListenerImpl() {
         public void elementAdded(Object addedElement, String type)
         {
            System.out.println("Element added: " + addedElement);
         }
         
         public void elementRemoved(Object removedElement, String type)
         {
            System.out.println("Element removed: " + removedElement);
         }
      });
          
      mbeanServer.addNotificationListener(objectName, relationSet.getNotificationListener(), relationSet.getNotificationFilter(), null);
   }
   
   // call a method that displays the value of the attribute according to its type
   displayAttributeValue(attributeValue);
}
Skip navigation links

Please send bug reports and comments to Caplin support