|
"WEBNMS_5 API Docs" | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.tree.DefaultTreeModel
com.adventnet.nms.topodb.DefaultTopoSubscriber
public class DefaultTopoSubscriber
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
}
}
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 |
|---|
public DefaultTopoSubscriber(java.lang.String objectName)
objectName - The Container object that is to be registered for receiving updates.
public DefaultTopoSubscriber(java.lang.String objectName,
java.lang.String hostname)
throws java.rmi.RemoteException
objectName - The Container object that is to be registered for receiving updates.hostname - Host name where the server is running.
java.rmi.RemoteException - if the object does not exist or cannot be found.
public DefaultTopoSubscriber(java.lang.String objectName,
java.lang.String hostname,
int port)
throws java.rmi.RemoteException
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.
java.rmi.RemoteException - if the object does not exist or cannot be found.| Method Detail |
|---|
public void initialize(NmsTreeNode initNode)
throws java.rmi.RemoteException
com.adventnet.nms.topodb.NmsTreeNode.
initialize in interface TopoSubscriberinitNode - This is the root node which contains all the objects including direct
and indirect children of the object which has been registered.
java.rmi.RemoteException - if the root node does not exist or cannot be foundNmsTreeNode
public void update(java.lang.String type,
ManagedObject obj,
java.lang.String[] treePath)
throws java.rmi.RemoteException
com.adventnet.nms.topodb.TopoSubscriber.
update in interface TopoSubscribertype - 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.
java.rmi.RemoteException - in case of error.TopoSubscriber.update(String, ManagedObject, String[])
public void deregister()
throws java.rmi.RemoteException
java.rmi.RemoteException - if the object does not exist or cannot be found.
protected javax.swing.tree.DefaultMutableTreeNode createNode(javax.swing.tree.DefaultMutableTreeNode parentNode,
ManagedObject mobj)
mobj as its user object, and also notifies its
listeners.
parentNode - node to which the child is to be added.mobj - ManagedObject for which the child has to be created.
protected boolean deleteNode(ManagedObject mobj)
mobj - the ManagedObject for which the node to be deleted.
protected boolean updateNode(ManagedObject mobj)
mobj - the ManagedObject for which the node is to be updated.
public javax.swing.tree.DefaultMutableTreeNode getNode(java.lang.String nodename)
nodename - name of the node that is needed.
|
"WEBNMS_5 API Docs" | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||