xmlBlaster 2.2.0 client API

org.xmlBlaster.util
Class SessionName

java.lang.Object
  extended by org.xmlBlaster.util.SessionName
All Implemented Interfaces:
java.io.Serializable

public final class SessionName
extends java.lang.Object
implements java.io.Serializable

Handles unified naming convention of login names and user sessions. Instances are immutable.

Author:
xmlBlaster@marcelruff.info
See Also:
org.xmlBlaster.test.classtest.SessionNameTest, The client.failsafe requirement, Serialized Form

Field Summary
static java.lang.String ROOT_MARKER_TAG
           
static java.lang.String SEPERATOR
           
static java.lang.String SUBJECT_MARKER_TAG
           
 
Constructor Summary
SessionName(Global glob, NodeId nodeId, java.lang.String name)
           
SessionName(Global glob, NodeId nodeId, java.lang.String subjectId, long pubSessionId)
           
SessionName(Global glob, SessionName sessionName, long pubSessionId)
          Create a new instance based on the given sessionName but with added/changed pubSessionId
SessionName(Global glob, java.lang.String name)
          Create and parse a unified name.
 
Method Summary
 boolean equalsAbsolute(SessionName sessionName)
           
 boolean equalsRelative(SessionName sessionName)
           
 java.lang.String getAbsoluteName()
           
 java.lang.String getAbsoluteName(boolean forceSessionMarker)
          If the nodeId is not known, the relative name is returned
 java.lang.String getAbsoluteSubjectName()
          If the nodeId is not known, the relative name is returned a possible session is ommitted
 java.lang.String getLoginName()
           
 NodeId getNodeId()
           
 java.lang.String getNodeIdStr()
           
 long getPublicSessionId()
           
 java.lang.String getRelativeName()
           
 java.lang.String getRelativeName(boolean forceSessionMarker)
           
 java.lang.String getRelativeNameWithoutSessionMarker()
           
 java.lang.String getRelativePubSessionIdWildcard()
          Note: no blanks in the example below are allowed, we need to write it like this to distinguish it from a java comment
 java.lang.String getRelativeSubjectIdWildcard()
          Note: no blanks in the example below are allowed, we need to write it like this to distinguish it from a java comment
 java.lang.String getRelativeWildcard()
          Note: no blanks in the example below are allowed, we need to write it like this to distinguish it from a java comment
static SessionName guessSessionName(Global glob, java.lang.String nodeId, java.lang.String queueName)
          Guess a SessionName from given callback queueName of old xb_entries (was created from Global.getStrippedId)
static SessionName guessSessionName(Global glob, java.lang.String nodeId, java.lang.String queueName, boolean limitPositivePubToOneDigit)
          Not reliable.
 boolean isCoreInternalLoginName()
           
 boolean isInternalLoginName()
           
 boolean isNodeIdExplicitlyGiven()
          Check if the address string given to our constructor had an explicit specified nodeId
 boolean isPluginInternalLoginName()
           
 boolean isPubSessionIdInternal()
           
 boolean isPubSessionIdUser()
           
 boolean isSession()
          Check if we hold a session or a subject
static void main(java.lang.String[] args)
          Method for testing only.
 boolean matchRelativeName(java.lang.String pattern)
          Check matching name, the subjectId or pubSessionId can be a wildcard "*" (note: no blanks in the example below are allowed, we need to write it like this to distinguish it from a java comment)
 java.lang.String toString()
           
 java.lang.String toXml()
          Dump state of this object into a XML ASCII string.
 java.lang.String toXml(java.lang.String extraOffset)
          Dump state of this object into a XML ASCII string.
static boolean useSessionMarker()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEPERATOR

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

ROOT_MARKER_TAG

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

SUBJECT_MARKER_TAG

public static final java.lang.String SUBJECT_MARKER_TAG
See Also:
Constant Field Values
Constructor Detail

SessionName

public SessionName(Global glob,
                   java.lang.String name)
Create and parse a unified name.

Parameters:
name - Examples:
  /node/heron/client/joe/2
  client/joe/2
  joe/2
  joe
  /node/heron/client/joe/session/2
  client/joe/session/2
  joe/session/2
 
Throws:
java.lang.IllegalArgumentException - if your name can't be parsed

SessionName

public SessionName(Global glob,
                   NodeId nodeId,
                   java.lang.String subjectId,
                   long pubSessionId)

SessionName

public SessionName(Global glob,
                   NodeId nodeId,
                   java.lang.String name)
Parameters:
nodeId - if not null it has precedence to the nodeId which is probably found in name
name - Examples:
  /node/heron/client/joe/2
  client/joe/2
  joe/2
  joe
 
The EventPlugin supports wildcard '*' as sessionNumber, to be able to use this parser we map it to Long.MIN_VALUE
Throws:
java.lang.IllegalArgumentException - if your name can't be parsed

SessionName

public SessionName(Global glob,
                   SessionName sessionName,
                   long pubSessionId)
Create a new instance based on the given sessionName but with added/changed pubSessionId

Method Detail

useSessionMarker

public static boolean useSessionMarker()

getAbsoluteName

public java.lang.String getAbsoluteName()

getAbsoluteName

public java.lang.String getAbsoluteName(boolean forceSessionMarker)
If the nodeId is not known, the relative name is returned

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

getAbsoluteSubjectName

public java.lang.String getAbsoluteSubjectName()
If the nodeId is not known, the relative name is returned a possible session is ommitted

Returns:
e.g. "/node/heron/client/joe", 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/session/2" or "client/joe", never null

getRelativeName

public java.lang.String getRelativeName(boolean forceSessionMarker)
Parameters:
forceSessionMarker - If false the configured syntax is chosen, if true wie force the /session/ markup
Returns:
e.g. "client/joe/session/2" or "client/joe", never null

getRelativeNameWithoutSessionMarker

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

isNodeIdExplicitlyGiven

public boolean isNodeIdExplicitlyGiven()
Check if the address string given to our constructor had an explicit specified nodeId


getNodeId

public NodeId getNodeId()
Returns:
e.g. "heron", or null

getNodeIdStr

public java.lang.String getNodeIdStr()
Returns:
e.g. "heron", or null

getLoginName

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

isInternalLoginName

public final boolean isInternalLoginName()

isPluginInternalLoginName

public final boolean isPluginInternalLoginName()

isCoreInternalLoginName

public final boolean isCoreInternalLoginName()

getPublicSessionId

public long getPublicSessionId()
Returns:
The public session identifier e.g. "2" or 0 if in subject context

isSession

public boolean isSession()
Check if we hold a session or a subject


isPubSessionIdInternal

public boolean isPubSessionIdInternal()
Returns:
true it publicSessionId is given by xmlBlaster server (if < 0)

isPubSessionIdUser

public boolean isPubSessionIdUser()
Returns:
true it publicSessionId is given by user/client (if > 0)

equalsRelative

public boolean equalsRelative(SessionName sessionName)
Returns:
true if relative name equals

equalsAbsolute

public boolean equalsAbsolute(SessionName sessionName)

guessSessionName

public static SessionName guessSessionName(Global glob,
                                           java.lang.String nodeId,
                                           java.lang.String queueName)
Guess a SessionName from given callback queueName of old xb_entries (was created from Global.getStrippedId)
 callback_nodeheronclientjack1   /node/frodo/client/jack/session/1
 clientsubscriber71              /node/frodo/client/subscriber/session/71
 clientsubscriber7-1             /node/frodo/client/subscriber7/session/-1
 
With limitPositivePubToOneDigit==true:
 clientsubscriber71 / node / heron / client / subscriber7 / session / -1
 
Is not bullet proof:
 clientpublisher-222   Could be publisher-22/session/2
 clientsubscriber7777  Could be subscriber77/session/77
 

Parameters:
glob -
nodeId - The Node to use
queueName - Only for client names, can fail if subjectId ends with number and has positive session id!
Returns:

guessSessionName

public static SessionName guessSessionName(Global glob,
                                           java.lang.String nodeId,
                                           java.lang.String queueName,
                                           boolean limitPositivePubToOneDigit)
Not reliable.

Parameters:
glob -
nodeId - If null is extracted from queueName
queueName - e.g. "connection_nodefrodoclientjack1" or "connection_clientjack1"
limitPositivePubToOneDigit -
Returns:
null if no useful arguments

matchRelativeName

public boolean matchRelativeName(java.lang.String pattern)
Check matching name, the subjectId or pubSessionId can be a wildcard "*" (note: no blanks in the example below are allowed, we need to write it like this to distinguish it from a java comment)

Parameters:
pattern - for example "client/ * /session/ *", ""client/ * /session/1", "client/joe/session/ *", "client/joe/session/1"
Returns:
true if wildcard matches or exact match

getRelativeSubjectIdWildcard

public java.lang.String getRelativeSubjectIdWildcard()
Note: no blanks in the example below are allowed, we need to write it like this to distinguish it from a java comment

Returns:
e.g. "client/ * /session/2"

getRelativePubSessionIdWildcard

public java.lang.String getRelativePubSessionIdWildcard()
Note: no blanks in the example below are allowed, we need to write it like this to distinguish it from a java comment

Returns:
e.g. "client/joe/session/ *

getRelativeWildcard

public java.lang.String getRelativeWildcard()
Note: no blanks in the example below are allowed, we need to write it like this to distinguish it from a java comment

Returns:
"client/* /session/*

toXml

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

Returns:
internal state of SessionName as a XML ASCII string

toXml

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

Parameters:
extraOffset - indenting of tags for nice output
Returns:
internal state of SessionName as a XML ASCII string

main

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

Invoke: java -Djava.compiler= org.xmlBlaster.util.SessionName -name client/jack/1


xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.