xmlBlaster 2.2.0 API

org.xmlBlaster.util
Class Global

java.lang.Object
  extended by org.xmlBlaster.util.Global
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
ServerScope

public class Global
extends java.lang.Object
implements java.lang.Cloneable

Global variables to avoid singleton.

Each Global instance holds all configuration and helper objects for exactly one XmlBlasterAccess client instance. It is like a local stack for a connection.

Use one instance of this for each XmlBlasterAccess client connection to xmlBlaster.

A Global instance is still usable after a call to its shutdown() method, it can be used again in another XmlBlasterAccess instance.

See Also:
GlobalTest

Field Summary
protected  java.lang.String addressNormalized
           
protected  Address bootstrapAddress
           
private  java.lang.String buildJavaVendor
          This will be replaced by build.xml with the compiling JDK vendor
private  java.lang.String buildJavaVersion
          This will be replaced by build.xml with the compiling JDK version
private  java.lang.String buildTimestamp
          This will be replaced by build.xml with the build timestamp
protected  Timeout burstModeTimer
           
protected  java.lang.String cbHostname
           
protected  CbServerPluginManager cbServerPluginManager
           
protected  I_Checkpoint checkpointPlugin
          Must be loaded in runlevel 0 or 1 before any access as not synchronized
private  ClassLoaderFactory classLoaderFactory
          The xmlBlaster class loader factory
protected  PluginLoader clientSecurityLoader
           
protected  I_ConnectQosFactory connectQosFactory
           
protected  ContextNode contextNode
           
protected static int counter
           
protected  I_DisconnectQosFactory disconnectQosFactory
           
protected  DispatchPluginManager dispatchPluginManager
           
protected  DispatchWorkerPool dispatchWorkerPool
           
protected  javax.xml.parsers.DocumentBuilderFactory docBuilderFactory
           
protected  I_EntryFactory entryFactory
           
protected  java.lang.String errorText
           
private static Global firstInstance
           
static long heapMemoryUsage
          Number of bytes this JVM can allocate max, the -Xmx???M setting Set by JmxWrappter.java (defaults to Runtime.getRuntime().maxMemory())
private  HttpIORServer httpServer
           
protected  java.lang.String id
           
private  java.lang.String instanceId
           
protected  java.lang.String ip_addr
           
protected  boolean isDoingShutdown
           
protected  Timeout jdbcConnectionPoolTimer
           
private static java.util.logging.Logger log
           
protected  java.util.Hashtable logChannels
           
private static boolean logIsInitialized
           
static long maxFileDescriptorCount
          The max number of file descriptors this JVM may use Set by JmxWrappter.java, else 0
protected  java.lang.String ME
           
protected  Timeout messageTimer
           
protected  I_MsgKeyFactory msgKeyFactory
           
protected  I_MsgQosFactory msgQosFactory
           
protected  java.util.Map nativeCallbackDriverMap
           
protected  java.util.Map objectMap
          Store objects in the scope of one client connection or server instance
 java.lang.Object objectMapMonitor
          Helper to synchronize objectMap access
protected  I_TimeoutManager pingTimer
           
private  PluginManagerBase pluginManager
           
private  PluginRegistry pluginRegistry
           
protected  Property property
           
protected  ProtocolPluginManager protocolPluginManager
           
protected  I_QueryKeyFactory queryKeyFactory
           
protected  I_QueryQosFactory queryQosFactory
           
protected  QueuePluginManager queuePluginManager
           
private  java.lang.String revisionNumber
          This will be replaced by build.xml with the current subversion revision number
protected  javax.xml.parsers.SAXParserFactory saxFactory
           
protected  ContextNode scopeContextNode
           
protected  long sequenceNumber
          JMX notification sequence number.
protected  I_StatusQosFactory statusQosFactory
           
static long totalPhysicalMemorySize
          The amount of physical RAM of this machine.
private  java.lang.String version
          This will be replaced by build.xml with the current version
private  java.lang.String versionDefault
          Version string, please change for new releases (4 digits)
private  java.util.Map weakRegistry
           
protected  boolean wipeOutDB
          set to allow wipe out the persistence on restarts
protected  I_XmlBlasterAccess xmlBlasterAccess
          The client handle to access xmlBlaster
 
Constructor Summary
Global()
          Constructs an initial Global object, same as Global(null, true, true)
Global(java.util.Properties props)
          Constructs an initial Global object which is initialized by your properties (without leading '-'), same as Global(args, true, true)
Global(java.lang.String[] args)
          Constructs an initial Global object which is initialized by your args array (usually the command line args).
Global(java.lang.String[] args, boolean loadPropFile, boolean checkInstance)
           
Global(java.lang.String[] args, boolean loadPropFile, boolean checkInstance, boolean doReplace)
          Constructs an initial Global object which is initialized by your args array (usually the command line args).
 
Method Summary
 java.lang.String accessFromInternalHttpServer(Address address, java.lang.String urlPath, boolean verbose)
          Access the xmlBlaster internal HTTP server and download the requested path.
 void addNativeCallbackDriver(java.lang.String key, I_CallbackDriver driver)
          The key is the protocol and the address to access the callback instance.
 void addObjectEntry(java.lang.String key, java.lang.Object driver)
          Add an object in the scope of an I_XmlBlasterAccess or of one cluster node.
static java.lang.String byteString(long size)
          Build a nice, human readable string for the size in MB/KB/Bytes.
 java.util.logging.Level changeLogLevel(java.lang.String loggerName, java.util.logging.Level level)
          Changes the given logger to given level.
protected  java.lang.Object clone()
          Get a deep clone (everything is independent from the origin).
 DispatchConnectionsHandler createClientDispatchConnectionsHandler(ClientDispatchManager dispatchManager)
          Returns the client access layer implementations 'ClientDispatchConnectionsHandler'
static java.lang.String decode(java.lang.String s, java.lang.String enc)
          This notation is URLDecoder since JDK 1.4.
 void doStorageCleanup(JdbcQueue jdbcQueue)
           
static java.lang.String encode(java.lang.String s, java.lang.String enc)
          This notation is URLEncoder since JDK 1.4.
 void finalize()
           
static void gc(int numGc, long sleep)
          Do some garbage collect attempts
 boolean get(java.lang.String shortKey, boolean defaultValue, java.util.Properties map, I_PluginConfig pluginConfig)
          Checks PluginInfo as well.
 double get(java.lang.String shortKey, double defaultValue, java.util.Properties map, I_PluginConfig pluginConfig)
           
 int get(java.lang.String shortKey, int defaultValue, java.util.Properties map, I_PluginConfig pluginConfig)
           
 long get(java.lang.String shortKey, long defaultValue, java.util.Properties map, I_PluginConfig pluginConfig)
           
 java.lang.String get(java.lang.String shortKey, java.lang.String defaultValue, java.util.Properties map, I_PluginConfig pluginConfig)
          It searches for the given property.
 Address getBootstrapAddress()
          Returns the address of the xmlBlaster internal http server.
 java.lang.String getBuildJavaVendor()
           
 java.lang.String getBuildJavaVersion()
           
 java.lang.String getBuildTimestamp()
          See @build.timestamp@ which will be replaced by build.xml with the current timestamp
 Timeout getBurstModeTimer()
          Access the handle of the burst mode timer thread.
 java.lang.String getCbHostname()
          Returns a local IP or bootstrapHostname as a default setting to use for callback servers.
 java.lang.String getCbHostname(java.lang.String hostname, int port)
          Returns a local IP as a default setting to use for callback servers.
 CbServerPluginManager getCbServerPluginManager()
          Access the handle of the burst mode timer thread.
 I_Checkpoint getCheckpointPlugin()
           
 ClassLoaderFactory getClassLoaderFactory()
          Access the xmlBlaster Classloader.
 PluginLoader getClientSecurityPluginLoader()
          Needed by java client helper classes to load the security plugin
 Global getClone(java.lang.String[] args)
          Get a cloned instance.
 I_ConnectQosFactory getConnectQosFactory()
          Return a factory parsing QoS XML strings from connect() and connect-return messages.
 ContextNode getContextNode()
          The unique name of this instance.
static int getCounter()
           
 java.lang.String getDatabaseNodeStr()
           
 I_DisconnectQosFactory getDisconnectQosFactory()
          Return a factory parsing QoS XML strings from disconnect() requests.
 DispatchPluginManager getDispatchPluginManager()
           
 DispatchWorkerPool getDispatchWorkerPool()
          Access the handle of the callback thread pool.
 javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
          Get the configured DocumentBuilderFactoryFactory.
 I_EntryFactory getEntryFactory()
          The factory creating queue or msgUnitStore entries from persistent store.
 java.lang.String getErrorText()
           
static byte[] getFromClasspath(java.lang.String file, java.lang.Object location)
          Access a file from the CLASSPATH, typically from xmlBlaster.jar It is searched in the directory of the package of the calling java class org.xmlBlaster.util.http => org/xmlBlaster/util/http
 java.lang.Object getFromWeakRegistry(java.lang.Object key)
           
 HttpIORServer getHttpServer()
          Access the http server which allows bootstrapping the CORBA IOR
 java.lang.String getId()
          Access the unique local id (as a String), on client side typically the loginName with the public sessionId, on server side the server instance unique id.
 java.lang.String getInstanceId()
          Unique id of the client, changes on each restart.
static java.lang.String getJavadocUrl(java.lang.String className, java.lang.String methodName)
          http://www.xmlblaster.org/xmlBlaster/doc/api/org/xmlBlaster/util/admin/I_AdminPop3Driver.html#setPollingInterval(long)
 Timeout getJdbcConnectionPoolTimer()
          Access the handle of the jdbcConnectionPool timer (the timer for the polling when the connection has been lost).
static java.lang.String getJmxUsageLinkInfo(java.lang.String className, java.lang.String methodName)
          http://www.xmlblaster.org/xmlBlaster/doc/api/org/xmlBlaster/util/admin/I_AdminPop3Driver.html#setPollingInterval(long)
 JmxWrapper getJmxWrapper()
           
 java.lang.String getLocalIP()
          The IP address where we are running.
 java.util.logging.Level getLogLevel(java.lang.String loggerName)
          Get the current loglevel.
 java.lang.String getLogPrefix()
          Is coded in derived engine.Global
 java.lang.String getLogPrefixDashed()
          Is coded in derived engine.Global
static java.lang.String getMemoryStatistic()
          Access a nice, human readable string with the current RAM memory situation.
 Timeout getMessageTimer()
          Access the handle of the message expiry timer thread.
 I_MsgKeyFactory getMsgKeyFactory()
          Return a factory parsing key XML strings from publish() and update() messages.
 I_MsgQosFactory getMsgQosFactory()
          Return a factory parsing QoS XML strings from publish() and update() messages.
 I_CallbackDriver getNativeCallbackDriver(java.lang.String key)
          The key is the protocol and the address to access the callback instance.
 java.lang.String[] getNativeConnectArgs()
          Convenience method which returns the typical environment settings for a LOCAL connection.
 NodeId getNodeId()
           
 java.lang.Object getObjectEntry(java.lang.String key)
          Get an object in the scope of an xmlBlaster client connection or of one cluster node.
 java.util.Map getPersistentMap(java.lang.String id)
          Returns a persistent map.
 I_TimeoutManager getPingTimer()
          Access the handle of the ping timer thread to test a client or callback connection.
 PluginManagerBase getPluginManager()
          Returns the plugin manager used by the run level manager.
 PluginRegistry getPluginRegistry()
          Returns the plugin registry.
 Property getProperty()
          Access the environment properties, is never null.
 ProtocolPluginManager getProtocolPluginManager()
          Access the handle of the burst mode timer thread.
 I_QueryKeyFactory getQueryKeyFactory()
          Return a factory parsing key XML strings from subscribe() and other query invocations.
 I_QueryQosFactory getQueryQosFactory()
          Return a factory parsing QoS XML strings from publish() and update() messages.
 QueuePluginManager getQueuePluginManager()
           
 java.lang.String getReleaseId()
          Combination from getVersion() and getRevisionNumber().
 java.lang.String getRevisionNumber()
          See @revision.number@ which will be replaced by build.xml with the current subversion revision
 int getRunlevel()
           
 javax.xml.parsers.SAXParserFactory getSAXParserFactory()
          Get the configured SAXParserFactory.
 ContextNode getScopeContextNode()
          Helper for the time being to be used on client side by services like SmtpClient.
static java.lang.String getStackTraceAsString(java.lang.Throwable ex)
          Prints the stack trace as a String so it can be put on the normal logs.
 I_StatusQosFactory getStatusQosFactory()
          Return a factory parsing QoS XML strings from subcribe(), unSubscribe() and erase() returns.
 java.lang.String getStrippedId()
          Same as getId() but all 'special characters' are stripped so you can use it for file names.
static java.lang.String getStrippedString(java.lang.String text)
          Utility method to strip any string, all characters which prevent to be used for e.g.
 java.lang.String getVersion()
          See @version@ which will be replaced by build.xml with the current version
 boolean getWipeOutDB()
          Tells the jdbc queue manager if a cleanup of the DB is necessary
 I_XmlBlasterAccess getXmlBlasterAccess()
          The client handle to access xmlBlaster remotely.
 int init(java.applet.Applet applet)
           
 int init(java.util.Map props)
          Calls init(String[] args), the props keys have no leading "-".
 int init(java.lang.String[] args)
          The args key needs a leading "-".
protected  void initId()
          Our identifier, the cluster node we want connect to
private  java.net.URL initLogManager(java.lang.String[] args)
          Configure JDK 1.4 java.util.logging (only once per JVM-Classloader, multiple Global instances share the same).
private  int initProps(java.lang.String[] args, boolean loadPropFile, boolean doReplace)
          private, called from constructor
static Global instance()
          Global access to the default 'global' instance.
private  boolean isIbmVM()
           
 boolean isJmxActivated()
          Check if JMX is activated.
 boolean isRegisteredMBean(ContextNode ctxNode)
           
 boolean isServerSide()
          Check where we are, on client or on server side? engine.Global overwrites this
static java.lang.String logUsage()
           
static void main(java.lang.String[] args)
          To play with a profiling tool
 java.lang.String[] peekQueueMessagesToFile(I_Queue queue, int numOfEntries, java.lang.String path, java.lang.String label)
          Dumps given amount of messages from queue to file.
 void putInWeakRegistry(java.lang.Object key, java.lang.Object value)
           
 JmxMBeanHandle registerMBean(ContextNode contextNode, java.lang.Object mbean)
          JMX support.
 java.lang.Object removeFromWeakRegistry(java.lang.Object key)
           
 void removeNativeCallbackDriver(java.lang.String key)
          The key is the protocol and the address to access the callback instance.
 void removeObjectEntry(java.lang.String key)
          Remove an object from the scope of an I_XmlBlasterAccess or of one cluster node.
 void resetInstanceId()
          Reset the cached instance id
 void sendNotification(javax.management.NotificationBroadcasterSupport source, java.lang.String msg, java.lang.String attributeName, java.lang.String attributeType, java.lang.Object oldValue, java.lang.Object newValue)
          Send an administrative notification.
 void setBootstrapAddress(Address address)
          Force to use the given bootstrap address, used for cluster connections
 void setCheckpointPlugin(I_Checkpoint checkpointPlugin)
           
 void setContextNode(ContextNode contextNode)
          The unique name of this instance.
 void setId(java.lang.String id)
          Currently set by enging.Global, used server side only.
 void setScopeContextNode(ContextNode contextNode)
           
 void setWipeOutDB(boolean doWipeout)
          Tells the queue manager it should remove all entries from the persisence.
protected  void shallowCopy(Global utilGlob)
           
 void shutdown()
           
 void shutdownHttpServer()
           
 boolean supportJmx()
           
 void unregisterMBean(java.lang.Object objectName)
          Unregister a JMX MBean.
 java.lang.String usage()
          Command line usage.
 java.lang.String validateJmxValue(java.lang.String value)
           
static int waitOnKeyboardHit(java.lang.String str)
          Blocks until a key on the keyboard is hit.
 boolean wantsHelp()
          Allows you to query if user wants help.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

logIsInitialized

private static boolean logIsInitialized

firstInstance

private static volatile Global firstInstance

totalPhysicalMemorySize

public static long totalPhysicalMemorySize
The amount of physical RAM of this machine. Set by JmxWrappter.java, else 0

Since:
JDK 1.5

heapMemoryUsage

public static long heapMemoryUsage
Number of bytes this JVM can allocate max, the -Xmx???M setting Set by JmxWrappter.java (defaults to Runtime.getRuntime().maxMemory())

Since:
JDK 1.5

maxFileDescriptorCount

public static long maxFileDescriptorCount
The max number of file descriptors this JVM may use Set by JmxWrappter.java, else 0

Since:
JDK 1.5

versionDefault

private java.lang.String versionDefault
Version string, please change for new releases (4 digits)


version

private java.lang.String version
This will be replaced by build.xml with the current version


revisionNumber

private java.lang.String revisionNumber
This will be replaced by build.xml with the current subversion revision number


buildTimestamp

private java.lang.String buildTimestamp
This will be replaced by build.xml with the build timestamp


buildJavaVendor

private java.lang.String buildJavaVendor
This will be replaced by build.xml with the compiling JDK vendor


buildJavaVersion

private java.lang.String buildJavaVersion
This will be replaced by build.xml with the compiling JDK version


ME

protected java.lang.String ME

ip_addr

protected java.lang.String ip_addr

id

protected java.lang.String id

instanceId

private volatile java.lang.String instanceId

property

protected volatile Property property

errorText

protected java.lang.String errorText

contextNode

protected ContextNode contextNode

scopeContextNode

protected ContextNode scopeContextNode

cbHostname

protected java.lang.String cbHostname

addressNormalized

protected java.lang.String addressNormalized

classLoaderFactory

private ClassLoaderFactory classLoaderFactory
The xmlBlaster class loader factory


nativeCallbackDriverMap

protected java.util.Map nativeCallbackDriverMap

objectMap

protected java.util.Map objectMap
Store objects in the scope of one client connection or server instance


objectMapMonitor

public final java.lang.Object objectMapMonitor
Helper to synchronize objectMap access


bootstrapAddress

protected volatile Address bootstrapAddress

clientSecurityLoader

protected PluginLoader clientSecurityLoader

queuePluginManager

protected volatile QueuePluginManager queuePluginManager

dispatchPluginManager

protected volatile DispatchPluginManager dispatchPluginManager

protocolPluginManager

protected volatile ProtocolPluginManager protocolPluginManager

cbServerPluginManager

protected volatile CbServerPluginManager cbServerPluginManager

httpServer

private volatile HttpIORServer httpServer

logChannels

protected java.util.Hashtable logChannels

saxFactory

protected javax.xml.parsers.SAXParserFactory saxFactory

docBuilderFactory

protected javax.xml.parsers.DocumentBuilderFactory docBuilderFactory

checkpointPlugin

protected I_Checkpoint checkpointPlugin
Must be loaded in runlevel 0 or 1 before any access as not synchronized


msgKeyFactory

protected volatile I_MsgKeyFactory msgKeyFactory

queryKeyFactory

protected volatile I_QueryKeyFactory queryKeyFactory

connectQosFactory

protected volatile I_ConnectQosFactory connectQosFactory

disconnectQosFactory

protected volatile I_DisconnectQosFactory disconnectQosFactory

msgQosFactory

protected volatile I_MsgQosFactory msgQosFactory

queryQosFactory

protected volatile I_QueryQosFactory queryQosFactory

statusQosFactory

protected volatile I_StatusQosFactory statusQosFactory

pingTimer

protected volatile I_TimeoutManager pingTimer

burstModeTimer

protected volatile Timeout burstModeTimer

messageTimer

protected volatile Timeout messageTimer

jdbcConnectionPoolTimer

protected volatile Timeout jdbcConnectionPoolTimer

dispatchWorkerPool

protected volatile DispatchWorkerPool dispatchWorkerPool

counter

protected static int counter

pluginManager

private volatile PluginManagerBase pluginManager

pluginRegistry

private volatile PluginRegistry pluginRegistry

xmlBlasterAccess

protected volatile I_XmlBlasterAccess xmlBlasterAccess
The client handle to access xmlBlaster


isDoingShutdown

protected boolean isDoingShutdown

wipeOutDB

protected boolean wipeOutDB
set to allow wipe out the persistence on restarts


entryFactory

protected I_EntryFactory entryFactory

sequenceNumber

protected long sequenceNumber
JMX notification sequence number.


weakRegistry

private java.util.Map weakRegistry
Constructor Detail

Global

public Global()
Constructs an initial Global object, same as Global(null, true, true)


Global

public Global(java.util.Properties props)
Constructs an initial Global object which is initialized by your properties (without leading '-'), same as Global(args, true, true)


Global

public Global(java.lang.String[] args)
Constructs an initial Global object which is initialized by your args array (usually the command line args). Same as Global(args, true, true)


Global

public Global(java.lang.String[] args,
              boolean loadPropFile,
              boolean checkInstance)

Global

public Global(java.lang.String[] args,
              boolean loadPropFile,
              boolean checkInstance,
              boolean doReplace)
Constructs an initial Global object which is initialized by your args array (usually the command line args).

By setting loadPropFile to false it is possible to create a Global which does not automatically search out the xmlBlaster.properties file, which is good when you want to start xmlBlaster in an embedded environment.

It is possible to later load the property file if one wants, here is one way to do it:

         Property p = glob.getProperty();
         Properties prop = new Properties();
         FileInfo i = p.findPath("xmlBlaster.properties");
         InputStream is = i.getInputStream();
         prop.load(is);
         String[] ar = Property.propsToArgs(prop);
         p.addArgs2Props( ar != null ? ar : new String[0] );
       

It is also possible to load an entire second property file or find it with some other algorithm byte using the same pattern as above, just don't use findPath, but some other code.

Parameters:
args - args array (usually the command line args).
loadPropFile - if automatic loading of xmlBlaster.properties should be done.
Method Detail

supportJmx

public boolean supportJmx()

getCounter

public static int getCounter()

getJmxWrapper

public final JmxWrapper getJmxWrapper()
                               throws XmlBlasterException
Returns:
the JmxWrapper used to manage the MBean resources
Throws:
XmlBlasterException

isJmxActivated

public boolean isJmxActivated()
Check if JMX is activated.

Returns:
true if JMX is in use

sendNotification

public void sendNotification(javax.management.NotificationBroadcasterSupport source,
                             java.lang.String msg,
                             java.lang.String attributeName,
                             java.lang.String attributeType,
                             java.lang.Object oldValue,
                             java.lang.Object newValue)
Send an administrative notification.


registerMBean

public JmxMBeanHandle registerMBean(ContextNode contextNode,
                                    java.lang.Object mbean)
                             throws XmlBlasterException
JMX support. Start xmlBlaster with java -Dcom.sun.management.jmxremote org.xmlBlaster.Main You can access xmlBlaster from 'jconsole' delivered with JDK1.5 or above. The root node is always the cluster node id.

Parameters:
contextNode - Used to retrieve a unique instance name for the given MBean
mbean - the MBean object instance
Returns:
The object name used to register or null on error
Throws:
XmlBlasterException
Since:
1.0.5
See Also:
http://www.xmlblaster.org/xmlBlaster/doc/requirements/admin.jmx.html

unregisterMBean

public void unregisterMBean(java.lang.Object objectName)
Unregister a JMX MBean. Never throws any exception

Parameters:
objectName - The object you got from registerMBean() of type ObjectName, if null nothing happens

isRegisteredMBean

public boolean isRegisteredMBean(ContextNode ctxNode)
                          throws XmlBlasterException
Throws:
XmlBlasterException

getVersion

public java.lang.String getVersion()
See @version@ which will be replaced by build.xml with the current version

Returns:
e.g. "0.79f"

getRevisionNumber

public java.lang.String getRevisionNumber()
See @revision.number@ which will be replaced by build.xml with the current subversion revision

Returns:
e.g. "12702" or "12702M". If no subversion is available getVersion() is returned

getReleaseId

public java.lang.String getReleaseId()
Combination from getVersion() and getRevisionNumber().

Returns:
e.g. "0.91 #12702"

getBuildTimestamp

public java.lang.String getBuildTimestamp()
See @build.timestamp@ which will be replaced by build.xml with the current timestamp

Returns:
e.g. "06/17/2002 01:38 PM"

getBuildJavaVendor

public java.lang.String getBuildJavaVendor()
Returns:
e.g. "1.3.1-beta"

getBuildJavaVersion

public java.lang.String getBuildJavaVersion()
Returns:
e.g. "1.3.1-beta"

waitOnKeyboardHit

public static int waitOnKeyboardHit(java.lang.String str)
Blocks until a key on the keyboard is hit. Consumes multiple hits (for Windows DOS box)

Parameters:
str - If not null it will be printed on console with System.out
Returns:
The int pressed (for example 49 for '1')

initId

protected void initId()
Our identifier, the cluster node we want connect to


shallowCopy

protected void shallowCopy(Global utilGlob)

initProps

private int initProps(java.lang.String[] args,
                      boolean loadPropFile,
                      boolean doReplace)
private, called from constructor

Parameters:
args - arguments to initilize the property with.
loadPropFile - if loading of xmlBlaster.properties file should be done, if false no loading of the file is done.
Returns:
-1 on error
Throws:
If - no Property instance can be created

initLogManager

private java.net.URL initLogManager(java.lang.String[] args)
                             throws XmlBlasterException
Configure JDK 1.4 java.util.logging (only once per JVM-Classloader, multiple Global instances share the same).

Switch off xmlBlaster specific logging:
 xmlBlaster/java.util.logging=false
 

Lookup a specific logging.properties:
 java.util.logging.config.file=logging.properties
 

Returns:
The used configuration file (can be used for user notification) or null
Throws:
XmlBlasterException - if redirection fails

getLogLevel

public java.util.logging.Level getLogLevel(java.lang.String loggerName)
                                    throws XmlBlasterException
Get the current loglevel.

Parameters:
loggerName - e.g. "logging" or "/node/heron/logging/org.xmlBlaster.util.Timestamp"
Returns:
The logging level, for example "WARNING" or "FINE"
Throws:
XmlBlasterException

changeLogLevel

public java.util.logging.Level changeLogLevel(java.lang.String loggerName,
                                              java.util.logging.Level level)
                                       throws XmlBlasterException
Changes the given logger to given level.

Parameters:
loggerName - e.g. "logging" or "logging/org.xmlBlaster.util.StopWatch"
level - For example "FINE"
Returns:
The set level
Throws:
XmlBlasterException - if your bool is strange

init

public int init(java.util.Map props)
Calls init(String[] args), the props keys have no leading "-".

Returns:
1 Show usage, 0 OK, -1 error

init

public int init(java.lang.String[] args)
The args key needs a leading "-".

Returns:
1 Show usage, 0 OK, -1 error

wantsHelp

public final boolean wantsHelp()
Allows you to query if user wants help.

Returns:
true If '-help' or '-?' was passed to us

getErrorText

public java.lang.String getErrorText()
Returns:
If not null there was an error during construction / initialization

init

public int init(java.applet.Applet applet)
Returns:
1 Show usage, 0 OK

getContextNode

public ContextNode getContextNode()
The unique name of this instance.

Returns:
Can be null during startup

setContextNode

public void setContextNode(ContextNode contextNode)
The unique name of this instance.

Parameters:
contextNode - The new node id

getScopeContextNode

public ContextNode getScopeContextNode()
Helper for the time being to be used on client side by services like SmtpClient. Is filled by XmlBlasterAccess with for example "/node/heron/client/joe/session/1"

Returns:

setScopeContextNode

public void setScopeContextNode(ContextNode contextNode)

doStorageCleanup

public void doStorageCleanup(JdbcQueue jdbcQueue)

isServerSide

public boolean isServerSide()
Check where we are, on client or on server side? engine.Global overwrites this

Returns:
false As we are util.Global and running client side

getNodeId

public NodeId getNodeId()
Returns:
null on client side

getId

public java.lang.String getId()
Access the unique local id (as a String), on client side typically the loginName with the public sessionId, on server side the server instance unique id.

Returns:
""

getStrippedId

public java.lang.String getStrippedId()
Same as getId() but all 'special characters' are stripped so you can use it for file names.

Returns:
""

getDatabaseNodeStr

public java.lang.String getDatabaseNodeStr()
Returns:
for XBSTORE.XBNODE, typically the cluster.node.id

getStrippedString

public static final java.lang.String getStrippedString(java.lang.String text)
Utility method to strip any string, all characters which prevent to be used for e.g. file names are replaced.

This conversion is used for file names and for the administrative hierarchy e.g. "/node/heron/client/joe" is OK but 'http://xy:8080' instead of 'heron' is not

Parameters:
text - e.g. "http://www.xmlBlaster.org:/home\\x"
Returns:
e.g. "http_www_xmlBlaster_org_homex"

validateJmxValue

public final java.lang.String validateJmxValue(java.lang.String value)
See Also:
JmxWrapper.validateJmxValue(String)

setId

public void setId(java.lang.String id)
Currently set by enging.Global, used server side only.

Parameters:
a - unique id

getLogPrefixDashed

public java.lang.String getLogPrefixDashed()
Is coded in derived engine.Global


getLogPrefix

public java.lang.String getLogPrefix()
Is coded in derived engine.Global


instance

public static Global instance()
Global access to the default 'global' instance. If you have parameters (e.g. from the main() mehtod) you should initialize Global first before using instance():
    public static void main(String[] args) {
       new Global(args);
       ...
    }

    //later you can get this initialized instance with:
    Global glob = Global.instance();
    ...
 

Note that you should avoid to use Global.instance() and preferably use the global which describes your current context, e.g. the specific client connection like xmlBlasterAccess.getGlobal(). Use global.getClone(String[]) to create a new Global instance.


getClone

public final Global getClone(java.lang.String[] args)
Get a cloned instance.

Calls clone() and sets the given args thereafter.

This is the preferred way to create a new and independent Global instance for example for another client connection.

Note that Global.instance() will return the original instance even if called on the cloned object (it's a static variable). You should avoid to use Global.instance()

Parameters:
args - Additional configuration parameters

clone

protected java.lang.Object clone()
Get a deep clone (everything is independent from the origin).

The properties and log channels and ContextNode are copied with a deep copy manipulating these will not affect the original Global.
All other attributes are initialized as on startup.

Overrides:
clone in class java.lang.Object

getProperty

public final Property getProperty()
Access the environment properties, is never null.


getCheckpointPlugin

public I_Checkpoint getCheckpointPlugin()
Returns:
the checkpointPlugin

setCheckpointPlugin

public void setCheckpointPlugin(I_Checkpoint checkpointPlugin)
Parameters:
checkpointPlugin - the checkpointPlugin to set

getMsgKeyFactory

public final I_MsgKeyFactory getMsgKeyFactory()
Return a factory parsing key XML strings from publish() and update() messages.


getQueryKeyFactory

public final I_QueryKeyFactory getQueryKeyFactory()
Return a factory parsing key XML strings from subscribe() and other query invocations.


getConnectQosFactory

public final I_ConnectQosFactory getConnectQosFactory()
Return a factory parsing QoS XML strings from connect() and connect-return messages.


getDisconnectQosFactory

public final I_DisconnectQosFactory getDisconnectQosFactory()
Return a factory parsing QoS XML strings from disconnect() requests.


getMsgQosFactory

public final I_MsgQosFactory getMsgQosFactory()
Return a factory parsing QoS XML strings from publish() and update() messages.


getQueryQosFactory

public final I_QueryQosFactory getQueryQosFactory()
Return a factory parsing QoS XML strings from publish() and update() messages.


getStatusQosFactory

public final I_StatusQosFactory getStatusQosFactory()
Return a factory parsing QoS XML strings from subcribe(), unSubscribe() and erase() returns.


getNativeCallbackDriver

public final I_CallbackDriver getNativeCallbackDriver(java.lang.String key)
The key is the protocol and the address to access the callback instance.

Parameters:
key - e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'
Returns:
The instance of the protocol callback driver or null if not known

addNativeCallbackDriver

public final void addNativeCallbackDriver(java.lang.String key,
                                          I_CallbackDriver driver)
The key is the protocol and the address to access the callback instance.

Parameters:
key - e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'
The - instance of the protocol callback driver

removeNativeCallbackDriver

public final void removeNativeCallbackDriver(java.lang.String key)
The key is the protocol and the address to access the callback instance.

Parameters:
key - e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'
The - instance of the protocol callback driver

getObjectEntry

public final java.lang.Object getObjectEntry(java.lang.String key)
Get an object in the scope of an xmlBlaster client connection or of one cluster node.

This is helpful if you have more than one I_XmlBlasterAccess or cluster nodes running in the same JVM

Parameters:
key - e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'
or "/xmlBlaster/I_Authenticate"
Returns:
The instance of this object

addObjectEntry

public final void addObjectEntry(java.lang.String key,
                                 java.lang.Object driver)
Add an object in the scope of an I_XmlBlasterAccess or of one cluster node.

This is helpful if you have more than one I_XmlBlasterAccess or cluster nodes running in the same JVM

Parameters:
key - e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'
The - instance of the protocol callback driver

removeObjectEntry

public final void removeObjectEntry(java.lang.String key)
Remove an object from the scope of an I_XmlBlasterAccess or of one cluster node.

This is helpful if you have more than one I_XmlBlasterAccess or cluster nodes running in the same JVM

Parameters:
key - e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'

setBootstrapAddress

public final void setBootstrapAddress(Address address)
Force to use the given bootstrap address, used for cluster connections


getBootstrapAddress

public final Address getBootstrapAddress()
Returns the address of the xmlBlaster internal http server.

Is configurable with

   -bootstrapHostname myhost.mycompany.com   (or the raw IP)
   -bootstrapPort 3412
 
Defaults to the local machine and the IANA xmlBlaster port.
You can set "-bootstrapPort 0" to avoid starting the internal HTTP server


getCbHostname

public java.lang.String getCbHostname()
Returns a local IP or bootstrapHostname as a default setting to use for callback servers.

It is determined by doing a short connect to the xmlBlaster HTTP server an reading the used local hostname. The precedence of finding the callback hostname is:

  1. Evaluate the -bootstrapHostnameCB property
  2. Try to determine it by a temporary connection to the xmlBlaster bootstrap server and reading the used local IP
  3. Use default IP of this host

Returns:
The default IP, is never null

getCbHostname

public java.lang.String getCbHostname(java.lang.String hostname,
                                      int port)
Returns a local IP as a default setting to use for callback servers.

It is determined by doing a short connect to the given hostname/socket an reading the used local hostname. The precedence of finding the callback hostname is:

  1. Try to determine it by a temporary connection to the given hostname/socket and reading the used local IP
  2. Use default IP of this host

Returns:
The default IP, is never null

accessFromInternalHttpServer

public java.lang.String accessFromInternalHttpServer(Address address,
                                                     java.lang.String urlPath,
                                                     boolean verbose)
                                              throws XmlBlasterException
Access the xmlBlaster internal HTTP server and download the requested path.

Currently we only use it for CORBA IOR download. To avoid the name service, one can access the AuthServer IOR directly using a http connection.

Parameters:
address - The address we want to connect to or null
urlPath - The part after the host:port, from an URL "http://myhost.com:3412/AuthenticationService.ior" urlPath is "AuthenticationService.ior"
false - Suppress error logging when server not found
Throws:
XmlBlasterException

getLocalIP

public final java.lang.String getLocalIP()
The IP address where we are running.

You can specify the local IP address with e.g. -bootstrapHostname 192.168.10.1 on command line, useful for multi-homed hosts.

Returns:
The local IP address, defaults to '127.0.0.1' if not known.

getClientSecurityPluginLoader

public final PluginLoader getClientSecurityPluginLoader()
Needed by java client helper classes to load the security plugin


getQueuePluginManager

public final QueuePluginManager getQueuePluginManager()

getDispatchPluginManager

public final DispatchPluginManager getDispatchPluginManager()

getClassLoaderFactory

public ClassLoaderFactory getClassLoaderFactory()
Access the xmlBlaster Classloader. Every Global instance may have an own factory instance. Set classLoaderFactory property to not use default StandaloneClassLoaderFactory.

Returns:
null if switched off with "useXmlBlasterClassloader=false"

getHttpServer

public final HttpIORServer getHttpServer()
                                  throws XmlBlasterException
Access the http server which allows bootstrapping the CORBA IOR

Throws:
XmlBlasterException

shutdownHttpServer

public final void shutdownHttpServer()

getSAXParserFactory

public javax.xml.parsers.SAXParserFactory getSAXParserFactory()
                                                       throws XmlBlasterException
Get the configured SAXParserFactory.

The implementation of the SAXParser factory is decided by the property javax.xml.parsers.SAXParserFactory if available in Global, otherwise the JDK1.4 default org.apache.crimson.jaxp.SAXParserFactoryImplis returned.

The JDK 1.5 default would be com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

Throws:
XmlBlasterException
See Also:
getDocumentBuilderFactory()

isIbmVM

private final boolean isIbmVM()

getDocumentBuilderFactory

public javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
                                                                   throws XmlBlasterException
Get the configured DocumentBuilderFactoryFactory.

The implementation of the DocumentBuilderFactory is decided by the property javax.xml.parsers.DocumentBuilderFactory if available in Global, otherwise the default org.apache.crimson.jaxp.DocumentBuilderFactoryImpl is returned for JDK 1.3 and smaller.

Currently only crimson is actually possible to use for JDK 1.3 and JDK 1.4 (see xmlBlaster/lib/parser.jar#/META-INF/services setting)

For JDK 1.5 the default delivered parser is used: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl and xmlBlaster/lib/parser.jar and jaxp.jar are obsolete. For JDK 1.5 or higher any DOM Level 3 compliant parser should be OK.

Throws:
XmlBlasterException

getEntryFactory

public I_EntryFactory getEntryFactory()
The factory creating queue or msgUnitStore entries from persistent store. Is overwritten in engine.Global

Parameters:
name - A name identifying this plugin.

encode

public static java.lang.String encode(java.lang.String s,
                                      java.lang.String enc)
This notation is URLEncoder since JDK 1.4.

Parameters:
enc - If null it defaults to "UTF-8"

decode

public static java.lang.String decode(java.lang.String s,
                                      java.lang.String enc)
This notation is URLDecoder since JDK 1.4.

Parameters:
enc - If null it defaults to "UTF-8"

getProtocolPluginManager

public final ProtocolPluginManager getProtocolPluginManager()
Access the handle of the burst mode timer thread.

Returns:
The Timeout instance

getCbServerPluginManager

public final CbServerPluginManager getCbServerPluginManager()
Access the handle of the burst mode timer thread.

Returns:
The Timeout instance

getBurstModeTimer

public final Timeout getBurstModeTimer()
Access the handle of the burst mode timer thread.

Returns:
The Timeout instance

getPingTimer

public final I_TimeoutManager getPingTimer()
Access the handle of the ping timer thread to test a client or callback connection.

Returns:
The Timeout instance

getMessageTimer

public final Timeout getMessageTimer()
Access the handle of the message expiry timer thread. NOTE: This holds only weak references to its callback I_Timeout So there is no need to clear the timer registration

Returns:
The Timeout instance

getJdbcConnectionPoolTimer

public final Timeout getJdbcConnectionPoolTimer()
Access the handle of the jdbcConnectionPool timer (the timer for the polling when the connection has been lost).

Returns:
The Timeout instance

getDispatchWorkerPool

public final DispatchWorkerPool getDispatchWorkerPool()
Access the handle of the callback thread pool.

Returns:
The DispatchWorkerPool instance

createClientDispatchConnectionsHandler

public DispatchConnectionsHandler createClientDispatchConnectionsHandler(ClientDispatchManager dispatchManager)
                                                                  throws XmlBlasterException
Returns the client access layer implementations 'ClientDispatchConnectionsHandler'

Throws:
XmlBlasterException

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

shutdown

public void shutdown()

getRunlevel

public int getRunlevel()

getPluginManager

public PluginManagerBase getPluginManager()
Returns the plugin manager used by the run level manager. All other specific Managers extend this class and reference the cache on this instance.


getPluginRegistry

public PluginRegistry getPluginRegistry()
Returns the plugin registry.


getXmlBlasterAccess

public I_XmlBlasterAccess getXmlBlasterAccess()
The client handle to access xmlBlaster remotely.

Access your client side handle with this method only, it is the with this Global instance configured client connection to xmlBlaster (a singleton regarding this Global).

Multiple invocations return the same instance.

NOTE: On server side engine.Global.getXmlBlasterAccess() returns the native access handle.

Throws:
java.lang.IllegalArgumentException - If we are extended by engine.Global (use getClone() to create a util.Global)

setWipeOutDB

public void setWipeOutDB(boolean doWipeout)
Tells the queue manager it should remove all entries from the persisence. This is used by the RequestBroker when starting up

Parameters:
doWipeout -

getWipeOutDB

public boolean getWipeOutDB()
Tells the jdbc queue manager if a cleanup of the DB is necessary

Returns:
true if a cleanup is necessary

getStackTraceAsString

public static java.lang.String getStackTraceAsString(java.lang.Throwable ex)
Prints the stack trace as a String so it can be put on the normal logs.

Parameters:
ex - The exception for which to write out the stack trace. If you pass null it will print the Stack trace of a newly created exception.
Returns:
The Stack trace as a String.

getNativeConnectArgs

public java.lang.String[] getNativeConnectArgs()
Convenience method which returns the typical environment settings for a LOCAL connection.

If you write a native plugin you can use these settings as a base.

Don't use for plugins started on runlevel below AvailabilityChecker allows to publish as we don't have a client side queue.

Returns:
A string array which you can pass to this.global = glob.getClone(glob.getNativeConnectArgs());

usage

public java.lang.String usage()
Command line usage.

These variables may be set in your property file as well. Don't use the "-" prefix there.

Set the verbosity when loading properties (outputs with System.out).

0=nothing, 1=info, 2=trace, configure with

 java -Dproperty.verbose 2 ...

 java org.xmlBlaster.Main -property.verbose 2
 


logUsage

public static java.lang.String logUsage()

main

public static void main(java.lang.String[] args)
To play with a profiling tool


get

public java.lang.String get(java.lang.String shortKey,
                            java.lang.String defaultValue,
                            java.util.Properties map,
                            I_PluginConfig pluginConfig)
                     throws XmlBlasterException
It searches for the given property. The replacement for '${...}' is supported. Note that the assignment of a '$' variable can only be done in global scope, that is in the xmlBlaster.properties or command line, and JVM properties but not in the xmlBlasterPlugins.xml. It first looks into the map (the hardcoded properties). If one is found it is returned. Then it looks into the global. If one is found it is returned. If none is found it is searched in the plugin

Parameters:
shortKey - the key (in its short form without prefix) of the property
defaultValue - the default value of the property (weakest)
map - the hardcoded properties (strongest)
pluginConfig - the pluginConfig used, checks the properties from PluginInfo
Returns:
Throws:
XmlBlasterException

get

public long get(java.lang.String shortKey,
                long defaultValue,
                java.util.Properties map,
                I_PluginConfig pluginConfig)
         throws XmlBlasterException
Parameters:
shortKey -
defaultValue -
map -
pluginConfig -
Returns:
Throws:
XmlBlasterException
See Also:
get(String, String, map, I_PluginConfig)

get

public int get(java.lang.String shortKey,
               int defaultValue,
               java.util.Properties map,
               I_PluginConfig pluginConfig)
        throws XmlBlasterException
Parameters:
shortKey -
defaultValue -
map -
pluginConfig -
Returns:
Throws:
XmlBlasterException
See Also:
get(String, String, map, I_PluginConfig)

get

public boolean get(java.lang.String shortKey,
                   boolean defaultValue,
                   java.util.Properties map,
                   I_PluginConfig pluginConfig)
            throws XmlBlasterException
Checks PluginInfo as well.

Parameters:
shortKey -
defaultValue -
map -
pluginConfig -
Returns:
Throws:
XmlBlasterException
See Also:
get(String, String, map, I_PluginConfig)

get

public double get(java.lang.String shortKey,
                  double defaultValue,
                  java.util.Properties map,
                  I_PluginConfig pluginConfig)
           throws XmlBlasterException
Parameters:
shortKey -
defaultValue -
map -
pluginConfig -
Returns:
Throws:
XmlBlasterException
See Also:
get(String, String, map, I_PluginConfig)

resetInstanceId

public void resetInstanceId()
Reset the cached instance id


getInstanceId

public java.lang.String getInstanceId()
Unique id of the client, changes on each restart. If 'client/joe' is restarted, the instanceId changes.

Returns:
id + timestamp, '/client/joe/instanceId/33470080380'

peekQueueMessagesToFile

public java.lang.String[] peekQueueMessagesToFile(I_Queue queue,
                                                  int numOfEntries,
                                                  java.lang.String path,
                                                  java.lang.String label)
                                           throws XmlBlasterException
Dumps given amount of messages from queue to file. TODO: This method is only partly implemented

Parameters:
queue - The queue to observe
numOfEntries - Maximum number of messages to dump
path - The path to dump the messages to, it is automatically created if missing.
label - A nice queue name for logging/exceptions
Returns:
The file names dumped, including the path
Throws:
XmlBlasterException

getFromClasspath

public static byte[] getFromClasspath(java.lang.String file,
                                      java.lang.Object location)
Access a file from the CLASSPATH, typically from xmlBlaster.jar It is searched in the directory of the package of the calling java class org.xmlBlaster.util.http => org/xmlBlaster/util/http

Parameters:
file - The file to lookup
Returns:
The byte[] of the found file
Throws:
java.io.IOException - if an I/O error occurs. or IllegalArgumentException if not found

byteString

public static final java.lang.String byteString(long size)
Build a nice, human readable string for the size in MB/KB/Bytes.
Example:
System.out.println(Memory.DataLenStr(136000));
-> "136 KB"

Parameters:
size - is the size in bytes
Returns:
a nice readable memory string

getJavadocUrl

public static java.lang.String getJavadocUrl(java.lang.String className,
                                             java.lang.String methodName)
http://www.xmlblaster.org/xmlBlaster/doc/api/org/xmlBlaster/util/admin/I_AdminPop3Driver.html#setPollingInterval(long)

Parameters:
className -
methodName -
Returns:
http://www.xmlblaster.org/xmlBlaster/doc/api/org/xmlBlaster/util/admin/I_AdminPop3Driver.html#setPollingInterval(long)

getJmxUsageLinkInfo

public static java.lang.String getJmxUsageLinkInfo(java.lang.String className,
                                                   java.lang.String methodName)
http://www.xmlblaster.org/xmlBlaster/doc/api/org/xmlBlaster/util/admin/I_AdminPop3Driver.html#setPollingInterval(long)

Parameters:
className -
methodName -
Returns:

getPersistentMap

public java.util.Map getPersistentMap(java.lang.String id)
                               throws XmlBlasterException
Returns a persistent map.

Parameters:
id - The id identifying the map. Normally this would be the sessionId. If you pass null or an empty String, then a default map is returned.
Returns:
the persistent map.
Throws:
XmlBlasterException

gc

public static void gc(int numGc,
                      long sleep)
Do some garbage collect attempts


getMemoryStatistic

public static final java.lang.String getMemoryStatistic()
Access a nice, human readable string with the current RAM memory situation.

Returns:
a nice readable memory statistic string

putInWeakRegistry

public void putInWeakRegistry(java.lang.Object key,
                              java.lang.Object value)

getFromWeakRegistry

public java.lang.Object getFromWeakRegistry(java.lang.Object key)

removeFromWeakRegistry

public java.lang.Object removeFromWeakRegistry(java.lang.Object key)

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.