xmlBlaster 2.2.0 API

org.xmlBlaster.util.context
Class ContextNode

java.lang.Object
  extended by org.xmlBlaster.util.context.ContextNode

public final class ContextNode
extends java.lang.Object

This represents one node in the administrative hierarchy, and is a linked list to its parent and its childs.

Author:
xmlBlaster@marcelruff.info
See Also:
The admin.commands requirement

Field Summary
private  java.util.Map childs
           
private  java.lang.String className
           
static java.lang.String CLUSTER_MARKER_TAG
          Use to mark a cluster node name
static java.lang.String CLUSTERCONF_MARKER_TAG
          Use to mark a remote cluster node configuration
static java.lang.String CLUSTERMASTER_MARKER_TAG
          Use to mark a remote cluster node configuration
static java.lang.String CONNECTION_MARKER_TAG
          Use for client side XmlBlasterAccess
static java.lang.String CONTRIB_MARKER_TAG
          Use to mark a contrib
static java.lang.String EVENT_MARKER_TAG
          Use to mark event methods
private  java.lang.String instanceName
           
private static java.util.logging.Logger log
           
static java.lang.String LOGGING_MARKER_TAG
          Use to mark logging settings
static java.lang.String MAP_MARKER_TAG
          Use to mark a message store map
private  ContextNode parent
           
static java.lang.String PROTOCOL_MARKER_TAG
          Use to mark a protocol plugin like XMLRPC or email
static java.lang.String QUEUE_MARKER_TAG
          Use to mark a queue
static char QUOTE
           
static java.lang.String ROOT_MARKER_TAG
           
static ContextNode ROOT_NODE
           
static java.lang.String RUNLEVEL_PLUGIN_MARKER_TAG
          Use to mark a plugin inside the RunlevelManager (xmlBlasterPlugins.xml)
static java.lang.String SCHEMA_JMX
          For JMX conforming ObjectName string
static java.lang.String SCHEMA_JMX_DOMAIN
          For JMX conforming ObjectName string, "org.xmlBlaster:" is our JMX domain
static java.lang.String SCHEMA_URL
          For URL conforming string
static java.lang.String SCHEMA_XPATH
          For XPath conforming query
static java.lang.String SEP
          Name for logging output
static java.lang.String SERVICE_MARKER_TAG
          Use to mark a service
static java.lang.String SESSION_MARKER_TAG
          Use to mark a login session
static java.lang.String SUBJECT_MARKER_TAG
          Use to mark a client
static java.lang.String SUBSCRIPTION_MARKER_TAG
          Use to mark a subscription
static java.lang.String SYSPROP_MARKER_TAG
          Use to mark a system and configuration properties and command line arguments
static java.lang.String TOPIC_MARKER_TAG
          Use to mark a topic
 
Constructor Summary
ContextNode(Global glob, java.lang.String className, java.lang.String instanceName, ContextNode parent)
          Deprecated. Use constructor without global
ContextNode(java.lang.String className, java.lang.String instanceName, ContextNode parent)
           
 
Method Summary
 boolean addChild(ContextNode child)
          Add the given child, it exists already nothing happens.
 boolean addChild(ContextNode child, boolean doClone)
          Add the given child, it exists already nothing happens.
 void changeParentName(ContextNode newParentNode)
          Walk up the hierarchy until we find the given className and rename the instance name.
 void changeParentName(java.lang.String className, java.lang.String instanceName)
          Walk up the hierarchy until we find the given className and rename the instance name.
 boolean equalsAbsolute(ContextNode contextNode)
          Compare the absolute name.
 boolean equalsRelative(ContextNode contextNode)
           
 java.lang.String getAbsoluteName()
          Access the absolute name in standard notation
 java.lang.String getAbsoluteName(java.lang.String schema)
          Access the absolute name in standard notation
protected  ContextNode getChild(ContextNode node, java.lang.String className, java.lang.String instanceName)
          Recursive search
 ContextNode getChild(java.lang.String className)
          Search down the children tree for the given className.
 ContextNode getChild(java.lang.String className, java.lang.String instanceName)
          Search down the children tree for the given className and instanceName.
 ContextNode[] getChildren()
           
 java.lang.String getClassName()
           
 ContextNode getClone()
           
 java.lang.String getInstanceName()
           
 java.lang.String getInstanceNameNotNull()
           
 ContextNode getParent()
           
 ContextNode getParent(java.lang.String className)
          Walk up the hierarchy and return the matching ContextNode.
 java.lang.String getRelativeName()
           
 java.lang.String getRelativeName(java.lang.String schema)
           
 java.lang.String getSessionNameCompatible()
          Access the absolute name but without root tag /xmlBlaster.
 boolean isOfClass(java.lang.String className)
           
static void main(java.lang.String[] args)
          Method for testing only.

Invoke: java -Djava.compiler= org.xmlBlaster.util.context.ContextNode

 ContextNode mergeChildTree(ContextNode child)
          Merges the given child, it exists already nothing happens.
private  java.lang.String quote(java.lang.String value)
           
 boolean removeChild(ContextNode child)
          Remove a child.
 void setInstanceName(java.lang.String instanceName)
           
 java.lang.String toString()
           
 java.lang.String toXml()
          Dump state of this object into XML.
 java.lang.String toXml(java.lang.String extraOffset)
          Dump state of this object into XML.
static ContextNode valueOf(java.lang.String url)
          Parse the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

SEP

public static final java.lang.String SEP
Name for logging output

See Also:
Constant Field Values

ROOT_MARKER_TAG

public static final java.lang.String ROOT_MARKER_TAG
See Also:
Constant Field Values

CLUSTER_MARKER_TAG

public static final java.lang.String CLUSTER_MARKER_TAG
Use to mark a cluster node name

See Also:
Constant Field Values

SUBJECT_MARKER_TAG

public static final java.lang.String SUBJECT_MARKER_TAG
Use to mark a client

See Also:
Constant Field Values

CONTRIB_MARKER_TAG

public static final java.lang.String CONTRIB_MARKER_TAG
Use to mark a contrib

See Also:
Constant Field Values

SESSION_MARKER_TAG

public static final java.lang.String SESSION_MARKER_TAG
Use to mark a login session

See Also:
Constant Field Values

CONNECTION_MARKER_TAG

public static final java.lang.String CONNECTION_MARKER_TAG
Use for client side XmlBlasterAccess

See Also:
Constant Field Values

QUEUE_MARKER_TAG

public static final java.lang.String QUEUE_MARKER_TAG
Use to mark a queue

See Also:
Constant Field Values

SERVICE_MARKER_TAG

public static final java.lang.String SERVICE_MARKER_TAG
Use to mark a service

See Also:
Constant Field Values

RUNLEVEL_PLUGIN_MARKER_TAG

public static final java.lang.String RUNLEVEL_PLUGIN_MARKER_TAG
Use to mark a plugin inside the RunlevelManager (xmlBlasterPlugins.xml)

See Also:
Constant Field Values

PROTOCOL_MARKER_TAG

public static final java.lang.String PROTOCOL_MARKER_TAG
Use to mark a protocol plugin like XMLRPC or email

See Also:
Constant Field Values

MAP_MARKER_TAG

public static final java.lang.String MAP_MARKER_TAG
Use to mark a message store map

See Also:
Constant Field Values

TOPIC_MARKER_TAG

public static final java.lang.String TOPIC_MARKER_TAG
Use to mark a topic

See Also:
Constant Field Values

SUBSCRIPTION_MARKER_TAG

public static final java.lang.String SUBSCRIPTION_MARKER_TAG
Use to mark a subscription

See Also:
Constant Field Values

EVENT_MARKER_TAG

public static final java.lang.String EVENT_MARKER_TAG
Use to mark event methods

See Also:
Constant Field Values

SYSPROP_MARKER_TAG

public static final java.lang.String SYSPROP_MARKER_TAG
Use to mark a system and configuration properties and command line arguments

See Also:
Constant Field Values

LOGGING_MARKER_TAG

public static final java.lang.String LOGGING_MARKER_TAG
Use to mark logging settings

See Also:
Constant Field Values

CLUSTERCONF_MARKER_TAG

public static final java.lang.String CLUSTERCONF_MARKER_TAG
Use to mark a remote cluster node configuration

See Also:
Constant Field Values

CLUSTERMASTER_MARKER_TAG

public static final java.lang.String CLUSTERMASTER_MARKER_TAG
Use to mark a remote cluster node configuration

See Also:
Constant Field Values

SCHEMA_XPATH

public static final java.lang.String SCHEMA_XPATH
For XPath conforming query

See Also:
Constant Field Values

SCHEMA_JMX

public static final java.lang.String SCHEMA_JMX
For JMX conforming ObjectName string

See Also:
Constant Field Values

SCHEMA_JMX_DOMAIN

public static final java.lang.String SCHEMA_JMX_DOMAIN
For JMX conforming ObjectName string, "org.xmlBlaster:" is our JMX domain

See Also:
Constant Field Values

SCHEMA_URL

public static final java.lang.String SCHEMA_URL
For URL conforming string

See Also:
Constant Field Values

className

private java.lang.String className

instanceName

private java.lang.String instanceName

parent

private ContextNode parent

childs

private java.util.Map childs

QUOTE

public static char QUOTE

ROOT_NODE

public static final ContextNode ROOT_NODE
Constructor Detail

ContextNode

public ContextNode(Global glob,
                   java.lang.String className,
                   java.lang.String instanceName,
                   ContextNode parent)
Deprecated. Use constructor without global


ContextNode

public ContextNode(java.lang.String className,
                   java.lang.String instanceName,
                   ContextNode parent)
Parameters:
className - The tag name like 'node' (ContextNode.CLUSTER_MARKER_TAG) or 'client' (ContextNode.SUBJECT_MARKER_TAG)
instanceName - The instance like 'heron' or 'joe', can be null
parent - The parent node or null if root ContextNode ('node/heron' etc)
Method Detail

getClassName

public java.lang.String getClassName()
Returns:
The tag name like 'node' (ContextNode.CLUSTER_MARKER_TAG) or 'client' (ContextNode.SUBJECT_MARKER_TAG)

isOfClass

public boolean isOfClass(java.lang.String className)
Parameters:
className - The tag name like 'node' (ContextNode.CLUSTER_MARKER_TAG) or 'client' (ContextNode.SUBJECT_MARKER_TAG)

setInstanceName

public void setInstanceName(java.lang.String instanceName)

getInstanceName

public java.lang.String getInstanceName()
Returns:
Can be null

getInstanceNameNotNull

public java.lang.String getInstanceNameNotNull()
Returns:
Is never null

getParent

public ContextNode getParent()
Returns:
The parent node or null

getParent

public ContextNode getParent(java.lang.String className)
Walk up the hierarchy and return the matching ContextNode.

Parameters:
className - The context node to retrieve
Returns:
The parent node or null

changeParentName

public void changeParentName(java.lang.String className,
                             java.lang.String instanceName)
Walk up the hierarchy until we find the given className and rename the instance name. For example rename "org.xmlBlaster:nodeClass=node,node=clientSUB1,clientClass=connection,connection=jack" to "org.xmlBlaster:nodeClass=node,node=heron,clientClass=connection,connection=jack" Checks the current node as well.

Parameters:
className - The class to change, e.g. "node"
instanceName - The new name to use, e.g. "heron"

changeParentName

public void changeParentName(ContextNode newParentNode)
Walk up the hierarchy until we find the given className and rename the instance name. For example rename "org.xmlBlaster:nodeClass=node,node=clientSUB1,clientClass=connection,connection=jack" to "org.xmlBlaster:nodeClass=node,node=heron,clientClass=connection,connection=jack" Checks the current node as well.

Parameters:
newParentNode - The new parent name to use, e.g. "heron"

addChild

public boolean addChild(ContextNode child)
Add the given child, it exists already nothing happens. The child is hold as a weak reference, so you don't need to cleanup.

Parameters:
child - The child to add
Returns:
true if the child was added, the parent of your child is modified! false if it existed already or if you given child is null

addChild

public boolean addChild(ContextNode child,
                        boolean doClone)
Add the given child, it exists already nothing happens. The child is hold as a weak reference, so you don't need to cleanup.

Parameters:
child - The child to add
doClone - If true the given child is not modified if false the given child is changed to have us as a new parent
Returns:
true if the child was added, false if it existed already or if you given child is null

getClone

public ContextNode getClone()

mergeChildTree

public ContextNode mergeChildTree(ContextNode child)
Merges the given child, it exists already nothing happens.

 this = "/node/heron/client/joe"
 child = "/node/xyz/client/joe/session/1"
 results to "/node/heron/client/joe/session/1"
 
 this = "/node/heron/client/joe/session/1"
 child = "/node/xyz/service/Pop3Driver"
 results to "/xmlBlaster/node/heron/client/joe/session/1/service/Pop3Driver"
 

Parameters:
child - The child to add, it is not touched as we take a clone
Returns:
The new leave or null if failed

getChildren

public ContextNode[] getChildren()
Returns:
All children, never null (but empty array)

removeChild

public boolean removeChild(ContextNode child)
Remove a child.

Parameters:
child -
Returns:
true if the child was removed

getChild

public ContextNode getChild(java.lang.String className,
                            java.lang.String instanceName)
Search down the children tree for the given className and instanceName. Only the first match is returned

Parameters:
className - If null only a given instanceName is searched
instanceName - If null only the given className is searched
Returns:
The child, is null if not found

getChild

public ContextNode getChild(java.lang.String className)
Search down the children tree for the given className. Only the first match is returned

Parameters:
className - If null only a given instanceName is searched
Returns:
The child, is null if not found

getChild

protected ContextNode getChild(ContextNode node,
                               java.lang.String className,
                               java.lang.String instanceName)
Recursive search


getAbsoluteName

public java.lang.String getAbsoluteName()
Access the absolute name in standard notation

Returns:
e.g. "/xmlBlaster/node/heron/client/joe/session/2", never null

getSessionNameCompatible

public java.lang.String getSessionNameCompatible()
Access the absolute name but without root tag /xmlBlaster.
Can be parsed by SessionName

Returns:
e.g. "/node/heron/client/joe/session/2", never null

quote

private java.lang.String quote(java.lang.String value)

getAbsoluteName

public java.lang.String getAbsoluteName(java.lang.String schema)
Access the absolute name in standard notation

Parameters:
schema - Currently only "xpath"
Returns:
e.g. "xpath:/xmlBlaster/node[@id='heron']/client[@id='joe']/session[@id='2']", never null

toString

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

getRelativeName

public java.lang.String getRelativeName()
Returns:
e.g. "client/joe", never null

getRelativeName

public java.lang.String getRelativeName(java.lang.String schema)
Parameters:
schema - Currently only "xpath"
Returns:
e.g. "xpath:client[@id='joe']", never null

equalsRelative

public boolean equalsRelative(ContextNode contextNode)
Returns:
true if relative name equals

equalsAbsolute

public boolean equalsAbsolute(ContextNode contextNode)
Compare the absolute name.

Parameters:
contextNode - Returns false if null
Returns:

valueOf

public static ContextNode valueOf(java.lang.String url)
Parse the given string. NOTE: The returned ContextNode is a new instance and NOT the instance from inside a given Global

Parameters:
url - For example "/xmlBlaster/node/heron/client/joe/session/2"
Returns:
The lowest ContextNode instance, you can navigate upwards with getParent() or ContextNode.ROOT_NODE==null.

toXml

public final java.lang.String toXml()
Dump state of this object into XML.

Returns:
XML dump of ContextNode

toXml

public final java.lang.String toXml(java.lang.String extraOffset)
Dump state of this object into XML.

Parameters:
extraOffset - indenting of tags
Returns:
XML dump of ContextNode

main

public static void main(java.lang.String[] args)
Method for testing only.

Invoke: java -Djava.compiler= org.xmlBlaster.util.context.ContextNode


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.