xmlBlaster 2.2.0 API

org.xmlBlaster.protocol.stomp
Class XbStompInOutBridge

java.lang.Object
  extended by org.xmlBlaster.protocol.stomp.XbStompInOutBridge
All Implemented Interfaces:
org.codehaus.stomp.StompHandler, I_CallbackDriver, I_Plugin

public class XbStompInOutBridge
extends java.lang.Object
implements org.codehaus.stomp.StompHandler, I_CallbackDriver

Protocol bridge, to bridge between xmlBlaster and STOMP protocol. implements StompHandler and I_CallbackDriver for incoming STOMP messages and outgoing XmlBlaster Messages.

One instance per client connect

Author:
Dieter Saken (Marcel Ruff)
See Also:
Protocol integration, Website, Protocol describtion

Field Summary
private  I_Authenticate authenticate
           
private  ConnectQosServer connectQos
           
private  XbStompDriver driver
           
private  java.util.concurrent.ConcurrentHashMap<java.lang.String,RequestHolder> framesToAck
           
private  Global glob
           
private static java.util.logging.Logger log
           
 java.lang.String ME
           
private  org.codehaus.stomp.StompHandler outputHandler
           
protected  long pingResponseTimeout
          How long to block on remote call waiting on ping responses
static java.lang.String PROTOCOL_NAME
           
private  java.lang.String remoteAddress
           
private  java.lang.String secretSessionId
           
private  boolean stompOpened
           
protected  long updateResponseTimeout
          How long to block on remote call waiting on update responses
private  I_XmlBlaster xb
           
static java.lang.String XB_SERVER_COMMAND_PING
           
static java.lang.String XB_SERVER_HEADER_KEY
           
static java.lang.String XB_SERVER_HEADER_QOS
           
 
Constructor Summary
XbStompInOutBridge(Global glob, XbStompDriver driver, org.codehaus.stomp.StompHandler outputHandler)
           
 
Method Summary
private  void _destroy()
           
private  boolean checkStompConnected()
           
private  boolean checkXbConnected()
           
private  java.lang.String cleanNewlines(java.lang.String str)
          HTTP header key/value should not contain new line.
 void close()
          Callback from #StompHandler
private  java.lang.String dump(org.codehaus.stomp.StompFrame frame)
           
private  java.lang.String getContentType(MsgUnitRaw msgUnitRaw)
           
 long getDefaultPingResponseTimeout()
          How long to block on remote call waiting on a ping response.
 long getDefaultUpdateResponseTimeout()
          How long to block on remote call waiting on a update() response.
 java.lang.String getExtendedLogId()
          All stomp threads contain the remote address alreay, but not our internal threads
private  RequestHolder getFrameForMessageId(java.lang.String messageId)
           
 RequestHolder[] getFramesToAck()
           
private  KeyData getKeyData(MsgUnitRaw msgUnitRaw)
           
 java.lang.String getLoginName()
           
 java.lang.String getName()
          Get a human readable name of this driver
 java.lang.String getProtocolId()
          Access the xmlBlaster internal name of the protocol driver.
 java.lang.String getRawAddress()
          Return the address how to access this driver.
 long getResponseTimeout(MethodName methodName)
           
 java.lang.String getType()
           
 java.lang.String getVersion()
           
 void init(Global glob, CallbackAddress addressConfig)
          Intialize the driver.
 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager.
 boolean isAlive()
           
 int notifyAllFrameAcks()
           
private  boolean notifyFrameAck(RequestHolder requestHolder)
           
 void onException(java.lang.Exception e)
          Callback from Stomp
protected  void onStompAck(org.codehaus.stomp.StompFrame command)
           
protected  void onStompConnect(org.codehaus.stomp.StompFrame command)
           
protected  void onStompDisconnect(org.codehaus.stomp.StompFrame command)
           
 void onStompFrame(org.codehaus.stomp.StompFrame frame)
          Callback from stomp layer.
protected  void onStompNak(org.codehaus.stomp.StompFrame command)
           
protected  void onStompSend(org.codehaus.stomp.StompFrame command)
           
protected  void onStompSubscribe(org.codehaus.stomp.StompFrame command)
           
protected  void onStompUnsubscribe(org.codehaus.stomp.StompFrame command)
           
 java.lang.String ping(java.lang.String qos)
          Ping to check if the clients callback server instance is alive.
private  RequestHolder registerFrame(org.codehaus.stomp.StompFrame frame)
           
 I_ProgressListener registerProgressListener(I_ProgressListener listener)
          Register a listener for to receive information about the progress of incoming data.
private  void removeFrameForMessageId(java.lang.String messageId)
           
private  void sendExeption(org.codehaus.stomp.StompFrame command, XmlBlasterException e)
           
private  java.lang.String sendFrameAndWait(org.codehaus.stomp.StompFrame frame, MethodName methodName)
           
private  void sendFrameNoWait(org.codehaus.stomp.StompFrame frame)
           
private  void sendResponse(org.codehaus.stomp.StompFrame command)
           
 java.lang.String[] sendUpdate(MsgUnitRaw[] msgArr)
          Send the message update to the client.
 void sendUpdateOneway(MsgUnitRaw[] msgArr)
          The oneway variant, without return value
 void setPingResponseTimeout(long millis)
          Set the given millis to protect against blocking client for ping invocations.
 void setUpdateResponseTimeout(long millis)
          Set the given millis to protect against blocking client for update() invocations.
 void shutdown()
          Called from xmlBlaster core on disconnect Called on exception or driver deactivate
static byte[] toUtf8Bytes(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

XB_SERVER_COMMAND_PING

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

XB_SERVER_HEADER_KEY

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

XB_SERVER_HEADER_QOS

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

ME

public java.lang.String ME

PROTOCOL_NAME

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

outputHandler

private final org.codehaus.stomp.StompHandler outputHandler

driver

private final XbStompDriver driver

glob

private final Global glob

framesToAck

private final java.util.concurrent.ConcurrentHashMap<java.lang.String,RequestHolder> framesToAck

secretSessionId

private java.lang.String secretSessionId

authenticate

private I_Authenticate authenticate

xb

private I_XmlBlaster xb

stompOpened

private boolean stompOpened

pingResponseTimeout

protected long pingResponseTimeout
How long to block on remote call waiting on ping responses


updateResponseTimeout

protected long updateResponseTimeout
How long to block on remote call waiting on update responses


connectQos

private ConnectQosServer connectQos

remoteAddress

private java.lang.String remoteAddress
Constructor Detail

XbStompInOutBridge

public XbStompInOutBridge(Global glob,
                          XbStompDriver driver,
                          org.codehaus.stomp.StompHandler outputHandler)
Method Detail

getExtendedLogId

public java.lang.String getExtendedLogId()
All stomp threads contain the remote address alreay, but not our internal threads


shutdown

public void shutdown()
Called from xmlBlaster core on disconnect Called on exception or driver deactivate

Specified by:
shutdown in interface I_Plugin

close

public void close()
Callback from #StompHandler

Specified by:
close in interface org.codehaus.stomp.StompHandler

_destroy

private void _destroy()

notifyAllFrameAcks

public int notifyAllFrameAcks()

getFramesToAck

public RequestHolder[] getFramesToAck()

checkStompConnected

private boolean checkStompConnected()

checkXbConnected

private boolean checkXbConnected()

onException

public void onException(java.lang.Exception e)
Callback from Stomp

Specified by:
onException in interface org.codehaus.stomp.StompHandler

dump

private java.lang.String dump(org.codehaus.stomp.StompFrame frame)

onStompFrame

public void onStompFrame(org.codehaus.stomp.StompFrame frame)
                  throws java.lang.Exception
Callback from stomp layer.

Specified by:
onStompFrame in interface org.codehaus.stomp.StompHandler
Throws:
java.lang.Exception

onStompConnect

protected void onStompConnect(org.codehaus.stomp.StompFrame command)

getLoginName

public java.lang.String getLoginName()

onStompDisconnect

protected void onStompDisconnect(org.codehaus.stomp.StompFrame command)

onStompSend

protected void onStompSend(org.codehaus.stomp.StompFrame command)

onStompSubscribe

protected void onStompSubscribe(org.codehaus.stomp.StompFrame command)
                         throws java.lang.Exception
Throws:
java.lang.Exception

onStompUnsubscribe

protected void onStompUnsubscribe(org.codehaus.stomp.StompFrame command)
                           throws java.lang.Exception
Throws:
java.lang.Exception

onStompAck

protected void onStompAck(org.codehaus.stomp.StompFrame command)
                   throws java.lang.Exception
Throws:
java.lang.Exception

onStompNak

protected void onStompNak(org.codehaus.stomp.StompFrame command)
                   throws java.lang.Exception
Throws:
java.lang.Exception

notifyFrameAck

private boolean notifyFrameAck(RequestHolder requestHolder)

getName

public java.lang.String getName()
Description copied from interface: I_CallbackDriver
Get a human readable name of this driver

Specified by:
getName in interface I_CallbackDriver

getProtocolId

public java.lang.String getProtocolId()
Description copied from interface: I_CallbackDriver
Access the xmlBlaster internal name of the protocol driver.

Specified by:
getProtocolId in interface I_CallbackDriver
Returns:
e.g. "IOR" "EMAIL" "XMLRPC" depending on driver

getRawAddress

public java.lang.String getRawAddress()
Description copied from interface: I_CallbackDriver
Return the address how to access this driver.

Specified by:
getRawAddress in interface I_CallbackDriver
Returns:
e.g. "http:/www.mars.universe:8080/RPC2" or "IOR:000034100..."

getDefaultPingResponseTimeout

public long getDefaultPingResponseTimeout()
How long to block on remote call waiting on a ping response. The default is to block for one minute This method can be overwritten by implementations like EMAIL


getDefaultUpdateResponseTimeout

public long getDefaultUpdateResponseTimeout()
How long to block on remote call waiting on a update() response. The default is to block forever This method can be overwritten by implementations like EMAIL


setPingResponseTimeout

public final void setPingResponseTimeout(long millis)
Set the given millis to protect against blocking client for ping invocations.

Parameters:
millis - If <= 0 it is set to the default (one minute). An argument less than or equal to zero means not to wait at all and is not supported

setUpdateResponseTimeout

public final void setUpdateResponseTimeout(long millis)
Set the given millis to protect against blocking client for update() invocations.

Parameters:
millis - If <= 0 it is set to the default (one minute). An argument less than or equal to zero means not to wait at all and is not supported

getResponseTimeout

public long getResponseTimeout(MethodName methodName)
Returns:
Returns the responseTimeout.

init

public void init(Global glob,
                 CallbackAddress addressConfig)
          throws XmlBlasterException
Description copied from interface: I_CallbackDriver
Intialize the driver.

Specified by:
init in interface I_CallbackDriver
addressConfig - Contains the callback address, e.g. the stringified CORBA callback handle of the client or his email address.
Throws:
XmlBlasterException

isAlive

public boolean isAlive()
Specified by:
isAlive in interface I_CallbackDriver
Returns:
true if the plugin is still alive, false otherwise

ping

public java.lang.String ping(java.lang.String qos)
                      throws XmlBlasterException
Description copied from interface: I_CallbackDriver
Ping to check if the clients callback server instance is alive. This ping checks the availability on the application level, a future implementation could return other values than 'OK' for example to signalize a standby mode of this client.

Specified by:
ping in interface I_CallbackDriver
Parameters:
qos - Currently not looked at, please pass an empty string ""
Returns:
"<qos><state id='OK'/></qos>"
Throws:
XmlBlasterException
See Also:
org.xmlBlaster.protocol.I_XmlBlaster#ping(String)

registerProgressListener

public I_ProgressListener registerProgressListener(I_ProgressListener listener)
Description copied from interface: I_CallbackDriver
Register a listener for to receive information about the progress of incoming data. Only one listener is supported, the last call overwrites older calls.

Specified by:
registerProgressListener in interface I_CallbackDriver
Parameters:
listener - Your listener, pass 0 to unregister.
Returns:
The previously registered listener or 0

cleanNewlines

private java.lang.String cleanNewlines(java.lang.String str)
HTTP header key/value should not contain new line.

Parameters:
str -
Returns:

getKeyData

private KeyData getKeyData(MsgUnitRaw msgUnitRaw)

getContentType

private java.lang.String getContentType(MsgUnitRaw msgUnitRaw)

sendUpdate

public java.lang.String[] sendUpdate(MsgUnitRaw[] msgArr)
                              throws XmlBlasterException
Description copied from interface: I_CallbackDriver
Send the message update to the client.

The protocol for sending is implemented in the derived class

Specified by:
sendUpdate in interface I_CallbackDriver
Parameters:
msgArr - Array of all messages to send, is guaranteed to never be null
Returns:
Clients should return a qos as follows. An empty qos string "" is valid as well and interpreted as OK
  <qos>
     <state id='OK'/>  <!-- Client processing state OK | ERROR ... see Constants.java -->
  </qos>
 
Throws:
XmlBlasterException

sendUpdateOneway

public void sendUpdateOneway(MsgUnitRaw[] msgArr)
                      throws XmlBlasterException
Description copied from interface: I_CallbackDriver
The oneway variant, without return value

Specified by:
sendUpdateOneway in interface I_CallbackDriver
Parameters:
msgArr - Array of all messages to send, is guaranteed to never be null
Throws:
XmlBlasterException - Is never from the client (oneway).

getType

public java.lang.String getType()
Specified by:
getType in interface I_Plugin

getVersion

public java.lang.String getVersion()
Specified by:
getVersion in interface I_Plugin

init

public void init(Global glob,
                 PluginInfo pluginInfo)
          throws XmlBlasterException
Description copied from interface: I_Plugin
This method is called by the PluginManager.

Example how options are evaluated:

   // An entry in xmlBlaster.properties (in one line):
   MimeSubscribePlugin[ContentLenFilter][1.0]=\
                 org.xmlBlaster.engine.mime.demo.ContentLenFilter,\
                 DEFAULT_MAX_LEN=200,DEFAULT_MIN_LEN=20

  // Access it like this:
  java.util.Properties props = pluginInfo.getParameters();
  String maxLen = (String)props.get("DEFAULT_MAX_LEN");
  String throwLen = (String)props.get("THROW_EXCEPTION_FOR_LEN");
 

Specified by:
init in interface I_Plugin
Throws:
XmlBlasterException

getFrameForMessageId

private RequestHolder getFrameForMessageId(java.lang.String messageId)

registerFrame

private RequestHolder registerFrame(org.codehaus.stomp.StompFrame frame)

removeFrameForMessageId

private void removeFrameForMessageId(java.lang.String messageId)

sendFrameNoWait

private void sendFrameNoWait(org.codehaus.stomp.StompFrame frame)
                      throws XmlBlasterException
Throws:
XmlBlasterException

sendFrameAndWait

private java.lang.String sendFrameAndWait(org.codehaus.stomp.StompFrame frame,
                                          MethodName methodName)
                                   throws XmlBlasterException
Throws:
XmlBlasterException

sendResponse

private void sendResponse(org.codehaus.stomp.StompFrame command)
                   throws XmlBlasterException
Throws:
XmlBlasterException

toUtf8Bytes

public static byte[] toUtf8Bytes(java.lang.String s)

sendExeption

private void sendExeption(org.codehaus.stomp.StompFrame command,
                          XmlBlasterException e)

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.