xmlBlaster 2.2.0 API

org.xmlBlaster.protocol.socket
Class SocketDriver

java.lang.Object
  extended by java.lang.Thread
      extended by org.xmlBlaster.protocol.socket.SocketDriver
All Implemented Interfaces:
java.lang.Runnable, I_Driver, SocketDriverMBean, I_AdminPlugin, I_AdminService, I_AdminUsage, I_Plugin

public class SocketDriver
extends java.lang.Thread
implements I_Driver, SocketDriverMBean

Socket driver class to invoke the xmlBlaster server over a native message format

This "SOCKET:" driver needs to be registered in xmlBlaster.properties and will be started on xmlBlaster startup, for example:

 ProtocolPlugin[SOCKET][1.0]=org.xmlBlaster.protocol.socket.SocketDriver

 CbProtocolPlugin[SOCKET][1.0]=org.xmlBlaster.protocol.socket.CallbackSocketDriver
 
The variable plugin/socket/port (default 7607) sets the socket server port, you may change it in xmlBlaster.properties or on command line:
 java -jar lib/xmlBlaster.jar  -plugin/socket/port 9090
 
The interface I_Driver is needed by xmlBlaster to instantiate and shutdown this driver implementation.

All adjustable parameters are explained in usage()

Author:
Marcel Ruff, Balázs Póka (SSL embedding, zlib compression)
See Also:
MsgInfo, The protocol.socket requirement

Nested Class Summary
(package private)  class SocketDriver.UDPListener
          There is exactly one UDP listener thread which receives datagrams for all clients.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  AddressServer addressServer
          The address configuration
private  I_Authenticate authenticate
          The singleton handle for this authentication server
protected  ContextNode contextNode
           
private  Global glob
          The global handle
private  java.util.Map handleClientMap
           
private  java.util.Set handleClientSet
          Remember all client connections
protected  boolean isShutdown
           
private  java.net.ServerSocket listen
          The socket server
private  boolean listenerReady
           
private  boolean listenerReadyUDP
           
private  java.lang.Thread listenerUDP
          State of server
private static java.util.logging.Logger log
           
protected  java.lang.Object mbeanHandle
          My JMX registration
private  java.lang.String ME
           
private  PluginInfo pluginInfo
           
private  boolean running
           
private  boolean runningUDP
           
private  java.net.DatagramSocket socketUDP
          The URL which clients need to use to access this server, e.g.
private  SocketUrl socketUrl
          The socket address info object holding hostname (useful for multi homed hosts) and port
private  int sslMarker
           
private  boolean startUdpListener
           
private  boolean useUdpForOneway
          Setting by plugin configuration, see xmlBlasterPlugins.xml, for example
<attribute id='useUdpForOneway'>true</attribute>
private  I_XmlBlaster xmlBlasterImpl
          The singleton handle for this xmlBlaster server
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SocketDriver()
          Creates the driver.
 
Method Summary
 void activate()
          Activate xmlBlaster access through this protocol.
(package private)  void addClient(java.lang.String sessionId, HandleClient h)
           
 void deActivate()
          Deactivate xmlBlaster access (standby), no clients can connect.
(package private)  AddressServer getAddressServer()
           
(package private)  I_Authenticate getAuthenticate()
          Access the handle to the xmlBlaster authenication core
(package private)  HandleClient getClient(java.lang.String sessionId)
           
 java.lang.String getEnvPrefix()
          The command line key prefix
(package private)  Global getGlobal()
           
 I_PluginConfig getPluginConfig()
           
 java.lang.String getProtocolId()
          Access the xmlBlaster internal name of the protocol driver.
 java.lang.String getRawAddress()
          Get the address how to access this driver.
 java.lang.String getType()
          Enforced by I_Plugin
 java.lang.String getUsageUrl()
           
 java.lang.String getVersion()
          Enforced by I_Plugin
(package private)  I_XmlBlaster getXmlBlaster()
          Access the handle to the xmlBlaster core
private  void init(Global glob, AddressServer addressServer, I_Authenticate authenticate, I_XmlBlaster xmlBlasterImpl)
          Start xmlBlaster SOCKET access.
 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager (enforced by I_Plugin).
 boolean isActive()
          Access the current state
 boolean isShutdown()
          Check status
 boolean isSSL()
          Is SSL support switched on?
(package private)  void removeClient(HandleClient h)
           
 void run()
          Starts the server socket and waits for clients to connect.
 void setUsageUrl(java.lang.String url)
           
 void shutdown()
          Close the listener port, the driver shuts down.
 boolean startUdpListener()
          Switch on/off UDP socket listener
 java.lang.String usage()
          Command line usage.
 boolean useUdpForOneway()
          Configuration option to use UDP for updateOneway() calls.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xmlBlaster.protocol.I_Driver
getName
 

Field Detail

ME

private java.lang.String ME

glob

private Global glob
The global handle


log

private static java.util.logging.Logger log

authenticate

private I_Authenticate authenticate
The singleton handle for this authentication server


xmlBlasterImpl

private I_XmlBlaster xmlBlasterImpl
The singleton handle for this xmlBlaster server


socketUrl

private SocketUrl socketUrl
The socket address info object holding hostname (useful for multi homed hosts) and port


listen

private java.net.ServerSocket listen
The socket server


socketUDP

private java.net.DatagramSocket socketUDP
The URL which clients need to use to access this server, e.g. "server.mars.univers:6701"


listenerUDP

private java.lang.Thread listenerUDP
State of server


sslMarker

private int sslMarker

running

private boolean running

runningUDP

private boolean runningUDP

listenerReady

private boolean listenerReady

listenerReadyUDP

private boolean listenerReadyUDP

handleClientSet

private java.util.Set handleClientSet
Remember all client connections


handleClientMap

private java.util.Map handleClientMap

addressServer

private AddressServer addressServer
The address configuration


pluginInfo

private PluginInfo pluginInfo

startUdpListener

private boolean startUdpListener

useUdpForOneway

private boolean useUdpForOneway
Setting by plugin configuration, see xmlBlasterPlugins.xml, for example
<attribute id='useUdpForOneway'>true</attribute>


mbeanHandle

protected java.lang.Object mbeanHandle
My JMX registration


contextNode

protected ContextNode contextNode

isShutdown

protected boolean isShutdown
Constructor Detail

SocketDriver

public SocketDriver()
Creates the driver. Note: getName() is enforced by interface I_Driver, but is already defined in Thread class

Method Detail

addClient

void addClient(java.lang.String sessionId,
               HandleClient h)

getClient

HandleClient getClient(java.lang.String sessionId)

getPluginConfig

public I_PluginConfig getPluginConfig()

getProtocolId

public java.lang.String getProtocolId()
Access the xmlBlaster internal name of the protocol driver.

Specified by:
getProtocolId in interface I_Driver
Returns:
The configured [type] in xmlBlaster.properties, defaults to "SOCKET"

getType

public java.lang.String getType()
Enforced by I_Plugin

Specified by:
getType in interface I_AdminPlugin
Specified by:
getType in interface I_Plugin
Returns:
The configured type in xmlBlaster.properties, defaults to "SOCKET"

getEnvPrefix

public java.lang.String getEnvPrefix()
The command line key prefix

Returns:
The configured type in xmlBlasterPlugins.xml, defaults to "plugin/socket"

getVersion

public java.lang.String getVersion()
Enforced by I_Plugin

Specified by:
getVersion in interface I_AdminPlugin
Specified by:
getVersion in interface I_Plugin
Returns:
For example "1.0"

startUdpListener

public boolean startUdpListener()
Switch on/off UDP socket listener


useUdpForOneway

public boolean useUdpForOneway()
Configuration option to use UDP for updateOneway() calls.
Typically a setting from the plugin configuration, see xmlBlasterPlugins.xml, for example
<attribute id='useUdpForOneway'>true</attribute>


init

public void init(Global glob,
                 PluginInfo pluginInfo)
          throws XmlBlasterException
This method is called by the PluginManager (enforced by I_Plugin).

Specified by:
init in interface I_Plugin
Throws:
XmlBlasterException
See Also:
I_Plugin.init(org.xmlBlaster.util.Global,org.xmlBlaster.util.plugin.PluginInfo)

getRawAddress

public java.lang.String getRawAddress()
Get the address how to access this driver.

Specified by:
getRawAddress in interface I_Driver
Specified by:
getRawAddress in interface SocketDriverMBean
Returns:
"server.mars.univers:6701"

getAuthenticate

I_Authenticate getAuthenticate()
Access the handle to the xmlBlaster authenication core


getXmlBlaster

I_XmlBlaster getXmlBlaster()
Access the handle to the xmlBlaster core


getAddressServer

AddressServer getAddressServer()

init

private void init(Global glob,
                  AddressServer addressServer,
                  I_Authenticate authenticate,
                  I_XmlBlaster xmlBlasterImpl)
           throws XmlBlasterException
Start xmlBlaster SOCKET access.

Enforced by interface I_Driver.
This method returns as soon as the listener socket is alive and ready or on error.

Parameters:
glob - Global handle to access logging, property and commandline args
authenticate - Handle to access authentication server
xmlBlasterImpl - Handle to access xmlBlaster core
Throws:
XmlBlasterException

activate

public void activate()
              throws XmlBlasterException
Activate xmlBlaster access through this protocol.

Specified by:
activate in interface I_Driver
Specified by:
activate in interface I_AdminService
Throws:
XmlBlasterException

isActive

public boolean isActive()
Description copied from interface: I_AdminService
Access the current state

Specified by:
isActive in interface I_AdminService
Returns:
true if active

deActivate

public void deActivate()
                throws java.lang.RuntimeException
Deactivate xmlBlaster access (standby), no clients can connect.

Specified by:
deActivate in interface I_Driver
Specified by:
deActivate in interface I_AdminService
Throws:
java.lang.RuntimeException

removeClient

final void removeClient(HandleClient h)

getGlobal

final Global getGlobal()

isSSL

public final boolean isSSL()
Is SSL support switched on?


run

public void run()
Starts the server socket and waits for clients to connect.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

shutdown

public void shutdown()
              throws XmlBlasterException
Close the listener port, the driver shuts down.

Specified by:
shutdown in interface I_AdminPlugin
Specified by:
shutdown in interface I_Plugin
Throws:
XmlBlasterException - if an exception occurs. The exception is handled by the RunLevelManager depending on how the plugin has been configured with the action:

<action do='STOP' onShutdownRunlevel='2' sequence='5' onFail='resource.configuration.pluginFailed'> If onFail is defined to something, the RunLevelManager will stop.


isShutdown

public boolean isShutdown()
Description copied from interface: I_AdminPlugin
Check status

Specified by:
isShutdown in interface I_AdminPlugin
Returns:
true if down

getUsageUrl

public java.lang.String getUsageUrl()
Specified by:
getUsageUrl in interface I_AdminUsage
Returns:
A link for JMX usage

setUsageUrl

public void setUsageUrl(java.lang.String url)
Specified by:
setUsageUrl in interface I_AdminUsage

usage

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

Enforced by interface I_Driver.

Specified by:
usage in interface I_Driver
Specified by:
usage in interface I_AdminUsage
Returns:
a human readable usage help string

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.