|
The nLeafNode is either a channel or a queue,
and is, as it's name suggests, an end point of a branch
of the namespace tree. An nLeafNode's parent is always
an instance of nContainer. Since nRealmNode is a subclass
of nContainer, sometimes an nLeafNode's parent is also
an instance of an nRealmNode. For example, consider
the following 2 channels within the namespace:
/eur/uk/rates
/rates
The nLeafNode that corresponds to the channel '/eur/uk/rates'
will have a parent which is an instance of nContainer,
and is called 'uk', whereas the nLeafNode that corresponds
to the channel '/rates' has a parent which is also an
instance of nContainer, however is is also an instance
of an nRealmNode (i.e. the namespace root), since it
does not contain any folder information in it's name.
As channels and queues are created, they are added
to the nRealmNode's tree structure as nLeafNodes. This
is all managed for you and does not require you to modify
the structure. However it is possible to be notified
when changes to the namespace occur so that your application
can handle it as you see fit. This is discussed in more
detail in the Management Information section of this
guide.
To determine if an nLeafNode is a channel or a queue,
there are 2 simple methods you can use. The following
code snippet search the namespace and print out whether
each leaf node it finds is a channel or a queue.
Example : Find channels and queues in the
namespace
public void searchNodes(nContainer container)
{
Enumeration children = container.getNodes();
while (children.hasMoreElements()) {
nNode child = (nNode)children.nextElement();
if (child instanceof nContainer) {
searchNodes((nContainer)child);
} else if (child instanceof nLeafNode) {
nLeafNode leaf = (nLeafNode)child;
if (leaf.isChannel) {
System.out.println("Leaf Node "+leaf.getName()+"
is a channel");
} else if (leaf.isQueue()) {
System.out.println("Leaf Node "+leaf.getName()+"
is a queue");
}
}
}
}
In the above code example, by the searchNodes(realm)
method searches the namespace from the realm node,
and this isChannel() and isQueue()
methods are used to determine whether each leaf node
is a queue or a channel.
Associated with each leaf node, is the nChannelAttributes
for the queue
or channel,
this is obtained by using the getAttributes() method,
so it is possible to determine the characteristics of
each leaf node.
Each leaf node also has an associated nACL object that
can be modified to change security permissions for users.
This is discussed in more detail in the security |