"WEBNMS_5 API Docs"

com.adventnet.nms.topodb
Class DefaultTopoSubscriber

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by com.adventnet.nms.topodb.DefaultTopoSubscriber
All Implemented Interfaces:
TopoSubscriber, java.io.Serializable, java.rmi.Remote, javax.swing.tree.TreeModel

Deprecated. From Web NMS 5 as TopoSubcriber has been deprecated.

public class DefaultTopoSubscriber
extends javax.swing.tree.DefaultTreeModel
implements TopoSubscriber

This is the default implementation of the com.adventnet.nms.topodb.TopoSubscriber interface. This class registers itself with the TopoAPI as a TopoSubscriber, receives updates from TopoDB and converts the updates into TreeModelEvents to notify its listeners.

Usage: This class can be used to receive the update notifications for objects in Containment relationship and with parent-child relationship only. For example, if you want to subscribe for a network object named as "xxx.xxx.x.x", you can create an instance of this class as follows.

TopoSubscriber subscriber = new DefaultTopoSubscriber("xxx.xxx.x.x");

OR
TopoSubscriber subscriber = new DefaultTopoSubscriber("xxx.xxx.x.x",hostName); //for RMI

And you can register as a javax.swing.event.TreeModelListener by using the statement

subscriber.addTreeModelListener(classWhichImplementsTreeModelListener);

The following methods of TreeModelListener will be invoked to notify the updates.

treeNodesInserted(TreeModelEvent evt) //for add object
treeNodesRemoved(TreeModelEvent evt) //for delete object
treeNodesChanged(TreeModelEvent evt) //for update object

The ManagedObject which gets updated is stored as a user object of the tree node in the DefaultTreeModel. To retrieve the ManagedObject from the tree node, you can use the code snippet given below.

    Object obj[] = treeModelEvent.getChildren();

    if(obj != null && obj.length > 0)
    {
        for(int i = 0; i < obj.length; i++)
        {
             ManagedObject mobj = (ManagedObject) ((DefaultMutableTreeNode)obj[i]).getUserObject();
            //add  necessary statements here
        }
    }
 

See Also:
TopoSubscriber, NmsTreeNode, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
DefaultTopoSubscriber(java.lang.String objectName)
          Deprecated. This constructor can be used to receive updates on an object from the server in the single JVM environment.
DefaultTopoSubscriber(java.lang.String objectName, java.lang.String hostname)
          Deprecated. This constructor can be used to receive updates on an object from the server in RMI mode.
DefaultTopoSubscriber(java.lang.String objectName, java.lang.String hostname, int port)
          Deprecated. This constructor can be used to receive updates on an object from the server in RMI mode when the RMIRegistry is not started in the default port.
 
Method Summary
protected  javax.swing.tree.DefaultMutableTreeNode createNode(javax.swing.tree.DefaultMutableTreeNode parentNode, ManagedObject mobj)
          Deprecated. This node can be used to create a new node for the managed object.
protected  boolean deleteNode(ManagedObject mobj)
          Deprecated. This node can be used to delete the tree node for the managed object which has been deleted from the server.
 void deregister()
          Deprecated. This method can be used to deregister the TopoSubscriber from the Topo DB.
 javax.swing.tree.DefaultMutableTreeNode getNode(java.lang.String nodename)
          Deprecated. This method takes the node name as its argument and returns the corresponding tree node.
 void initialize(NmsTreeNode initNode)
          Deprecated. This method will be invoked when the TopoSubscriber is instantiated for a Container object.
 void update(java.lang.String type, ManagedObject obj, java.lang.String[] treePath)
          Deprecated. Please refer the javadocs of com.adventnet.nms.topodb.TopoSubscriber.
protected  boolean updateNode(ManagedObject mobj)
          Deprecated. This method takes care of updating the tree node with the new managed object and also changing its parent key.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTopoSubscriber

public DefaultTopoSubscriber(java.lang.String objectName)
Deprecated. 
This constructor can be used to receive updates on an object from the server in the single JVM environment.

Parameters:
objectName - The Container object that is to be registered for receiving updates.

DefaultTopoSubscriber

public DefaultTopoSubscriber(java.lang.String objectName,
                             java.lang.String hostname)
                      throws java.rmi.RemoteException
Deprecated. 
This constructor can be used to receive updates on an object from the server in RMI mode.

Parameters:
objectName - The Container object that is to be registered for receiving updates.
hostname - Host name where the server is running.
Throws:
java.rmi.RemoteException - if the object does not exist or cannot be found.

DefaultTopoSubscriber

public DefaultTopoSubscriber(java.lang.String objectName,
                             java.lang.String hostname,
                             int port)
                      throws java.rmi.RemoteException
Deprecated. 
This constructor can be used to receive updates on an object from the server in RMI mode when the RMIRegistry is not started in the default port.

Parameters:
objectName - The Container object that is to be registered for receiving updates.
hostname - Host name where the server is running.
port - The port at which the RMIRegistry is started.
Throws:
java.rmi.RemoteException - if the object does not exist or cannot be found.
Method Detail

initialize

public void initialize(NmsTreeNode initNode)
                throws java.rmi.RemoteException
Deprecated. 
This method will be invoked when the TopoSubscriber is instantiated for a Container object. It takes care of creating tree nodes based on the objects received from the server through the class com.adventnet.nms.topodb.NmsTreeNode.

Specified by:
initialize in interface TopoSubscriber
Parameters:
initNode - This is the root node which contains all the objects including direct and indirect children of the object which has been registered.
Throws:
java.rmi.RemoteException - if the root node does not exist or cannot be found
See Also:
NmsTreeNode

update

public void update(java.lang.String type,
                   ManagedObject obj,
                   java.lang.String[] treePath)
            throws java.rmi.RemoteException
Deprecated. 
Please refer the javadocs of com.adventnet.nms.topodb.TopoSubscriber.

Specified by:
update in interface TopoSubscriber
Parameters:
type - The type argument is same as the type argument in the method update() of class TopoObserver. Please refer to TopoObserver#update(String,ManagedObject)
obj - The object which received the update.
treePath - The path of the object which gets update. The path contains the parent object names from the root object including the object name which gets update. The first element of the array being the registered Container Object name and the last element being the name of object which gets update.
Throws:
java.rmi.RemoteException - in case of error.
See Also:
TopoSubscriber.update(String, ManagedObject, String[])

deregister

public void deregister()
                throws java.rmi.RemoteException
Deprecated. 
This method can be used to deregister the TopoSubscriber from the Topo DB. The object then stops receiving updates from the server.

Throws:
java.rmi.RemoteException - if the object does not exist or cannot be found.

createNode

protected javax.swing.tree.DefaultMutableTreeNode createNode(javax.swing.tree.DefaultMutableTreeNode parentNode,
                                                             ManagedObject mobj)
Deprecated. 
This node can be used to create a new node for the managed object. This method creates a new DefaultMutableNode, sets mobj as its user object, and also notifies its listeners.

Parameters:
parentNode - node to which the child is to be added.
mobj - ManagedObject for which the child has to be created.
Returns:
DefaultMutableTreeNode created for the managed object.

deleteNode

protected boolean deleteNode(ManagedObject mobj)
Deprecated. 
This node can be used to delete the tree node for the managed object which has been deleted from the server. This method deletes DefaultMutableNode for the ManagedObject, and also notifies its listeners.

Parameters:
mobj - the ManagedObject for which the node to be deleted.
Returns:
true if deleted successfully else return false.

updateNode

protected boolean updateNode(ManagedObject mobj)
Deprecated. 
This method takes care of updating the tree node with the new managed object and also changing its parent key. If there is a change in parent key, the node will be removed from old parent and added to the new parent.

Parameters:
mobj - the ManagedObject for which the node is to be updated.
Returns:
true if updated successfully else return false.

getNode

public javax.swing.tree.DefaultMutableTreeNode getNode(java.lang.String nodename)
Deprecated. 
This method takes the node name as its argument and returns the corresponding tree node. Here node name is equivalent to the ManagedObject name.

Parameters:
nodename - name of the node that is needed.
Returns:
an instance of javax.swing.tree.DefaultMutableTreeNode. Returns null if there is no node with this name.

"WEBNMS_5 API Docs"

Copyright © 2011 ZOHO Corp., All Rights Reserved.