xmlBlaster 2.2.0 client API

org.xmlBlaster.util.protocol.socket
Class SocketExecutor

java.lang.Object
  extended by org.xmlBlaster.util.protocol.RequestReplyExecutor
      extended by org.xmlBlaster.util.protocol.socket.SocketExecutor
All Implemented Interfaces:
I_AdminPlugin, I_AdminUsage, RequestReplyExecutorMBean, SocketExecutorMBean
Direct Known Subclasses:
SocketCallbackImpl

public abstract class SocketExecutor
extends RequestReplyExecutor
implements SocketExecutorMBean

Send/receive messages over outStream and inStream.

A common base class for socket based messaging. Allows to block during a request and deliver the return message to the waiting thread.

Author:
Marcel Ruff.
See Also:
xmlBlaster SOCKET access protocol

Field Summary
protected  java.io.InputStream iStream
          Reading from socket
protected  java.lang.String loginName
          This is the client side
protected  int maxChunkSize
           
protected  java.lang.String msgInfoParserClassName
          Which message format parser to use
protected  java.io.OutputStream oStream
          Writing to socket
protected  boolean running
           
protected  long soLingerTimeout
          How long to block the socket on close with remaining data
protected  long soTimeout
          How long to block the socket on input stream read
 
Fields inherited from class org.xmlBlaster.util.protocol.RequestReplyExecutor
addressConfig, addressServer, cbClient, compressZlib, compressZlibStream, contextNode, glob, mbeanHandle, minSizeForCompression, ONEWAY, pingResponseTimeout, prefix, progressListener, responseListenerMap, responseTimeout, updateResponseTimeout, useEmailExpiryTimestamp, WAIT_ON_RESPONSE
 
Constructor Summary
SocketExecutor()
           
 
Method Summary
 java.lang.String getCbMsgInfoParserClassName()
           
static java.lang.String getGlobalKey(SessionName sessionName)
           
 java.io.InputStream getInputStream()
           
 java.lang.String getMsgInfoParserClassName()
          Which parser to use.
 java.io.OutputStream getOutputStream()
           
 long getSoLingerTimeout()
           
 long getSoTimeout()
           
 java.lang.String getUsageUrl()
           
 java.lang.String getVersion()
          The version of the plugin
protected  void initialize(Global glob, AddressBase addressConfig, java.io.InputStream iStream, java.io.OutputStream oStream)
          Used by SocketCallbackImpl on client side, uses I_CallbackExtended to invoke client classes

Used by HandleClient on server side, uses I_XmlBlaster to invoke xmlBlaster core

This executor has mixed client and server specific code for two reasons:
- Possibly we can use the same socket between two xmlBlaster server (load balance)
- Everything is together

 java.lang.String ping(java.lang.String qos)
          Ping to check if callback server (or server protocol) is alive.
protected  void sendMessage(MsgInfo msgInfo, java.lang.String requestId, MethodName methodName, boolean udp)
          Flush the data to the socket.
 java.lang.String[] sendUpdate(java.lang.String cbSessionId, MsgUnitRaw[] msgArr, boolean expectingResponse, boolean useUdpForOneway, PluginInfo callbackPluginInfo)
          Updating multiple messages in one sweep, callback to client.
protected  void setLoginName(java.lang.String loginName)
          Sets the loginName and automatically the requestId as well
 void setRunning(boolean run)
           
 void setSoLingerTimeout(long millis)
          Set the given millis to timeout socket close if data are lingering
 void setSoTimeout(long millis)
          Set the given millis to protect against blocking socket on input stream read() operations
 void setUsageUrl(java.lang.String url)
           
 void shutdown()
          Shutdown the plugin, free resources.
 java.lang.String usage()
           
 boolean useUdpForOneway()
           
 
Methods inherited from class org.xmlBlaster.util.protocol.RequestReplyExecutor
addResponseListener, clearResponseListenerMap, executeException, executeResponse, freePendingThreads, getAddressServer, getCbClient, getDefaultPingResponseTimeout, getDefaultResponseTimeout, getDefaultUpdateResponseTimeout, getExpiryTimestamp, getMinSizeForCompression, getPendingRequestList, getPingResponseTimeout, getProgressListener, getResponseListener, getResponseTimeout, getResponseTimeout, getResponseTimeout, getResponseTimeoutPropertyName, getType, getUpdateResponseTimeout, getXmlBlasterCore, hasConnection, initialize, initializeCb, interruptInvocation, isCompressZlib, isCompressZlibStream, isShutdown, isShutdownCompletly, isUseEmailExpiryTimestamp, receiveReply, registerProgressListener, removeResponseListener, requestAndBlockForReply, setCbClient, setCompressZlib, setCompressZlibStream, setMinSizeForCompression, setPingResponseTimeout, setResponseTimeout, setUpdateResponseTimeout, setUseEmailExpiryTimestamp, setXmlBlasterCore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xmlBlaster.util.protocol.RequestReplyExecutorMBean
getMinSizeForCompression, getPingResponseTimeout, getResponseTimeout, getResponseTimeout, getUpdateResponseTimeout, interruptInvocation, isCompressZlib, isCompressZlibStream, isUseEmailExpiryTimestamp, setCompressZlib, setCompressZlibStream, setMinSizeForCompression, setPingResponseTimeout, setResponseTimeout, setUpdateResponseTimeout, setUseEmailExpiryTimestamp
 
Methods inherited from interface org.xmlBlaster.util.admin.I_AdminPlugin
getType, isShutdown
 

Field Detail

iStream

protected java.io.InputStream iStream
Reading from socket


oStream

protected java.io.OutputStream oStream
Writing to socket


soTimeout

protected long soTimeout
How long to block the socket on input stream read


soLingerTimeout

protected long soLingerTimeout
How long to block the socket on close with remaining data


loginName

protected java.lang.String loginName
This is the client side


msgInfoParserClassName

protected java.lang.String msgInfoParserClassName
Which message format parser to use


maxChunkSize

protected int maxChunkSize

running

protected boolean running
Constructor Detail

SocketExecutor

public SocketExecutor()
Method Detail

initialize

protected void initialize(Global glob,
                          AddressBase addressConfig,
                          java.io.InputStream iStream,
                          java.io.OutputStream oStream)
                   throws java.io.IOException
Used by SocketCallbackImpl on client side, uses I_CallbackExtended to invoke client classes

Used by HandleClient on server side, uses I_XmlBlaster to invoke xmlBlaster core

This executor has mixed client and server specific code for two reasons:
- Possibly we can use the same socket between two xmlBlaster server (load balance)
- Everything is together

Parameters:
iStream - The reading stream (for example a socket InputStream)
oStream - The writing stream (for example a socket OutputStream)
Throws:
java.io.IOException

setLoginName

protected void setLoginName(java.lang.String loginName)
Sets the loginName and automatically the requestId as well

Overrides:
setLoginName in class RequestReplyExecutor

getMsgInfoParserClassName

public java.lang.String getMsgInfoParserClassName()
Which parser to use. The SOCKET protocol uses as a default setting the XbfParser

Returns:
The class name of the parser, "org.xmlBlaster.util.xbformat.XbfParser"

getCbMsgInfoParserClassName

public java.lang.String getCbMsgInfoParserClassName()

setSoTimeout

public final void setSoTimeout(long millis)
Set the given millis to protect against blocking socket on input stream read() operations

Parameters:
millis - If <= 0 it is disabled

getSoTimeout

public final long getSoTimeout()

setSoLingerTimeout

public final void setSoLingerTimeout(long millis)
Set the given millis to timeout socket close if data are lingering

Parameters:
millis - If < 0 it is set to one minute, 0 disable timeout

getSoLingerTimeout

public final long getSoLingerTimeout()

getOutputStream

public final java.io.OutputStream getOutputStream()

getInputStream

public final java.io.InputStream getInputStream()

setRunning

public void setRunning(boolean run)

sendUpdate

public final java.lang.String[] sendUpdate(java.lang.String cbSessionId,
                                           MsgUnitRaw[] msgArr,
                                           boolean expectingResponse,
                                           boolean useUdpForOneway,
                                           PluginInfo callbackPluginInfo)
                                    throws XmlBlasterException
Updating multiple messages in one sweep, callback to client.

Parameters:
expectingResponse - is WAIT_ON_RESPONSE or ONEWAY
Returns:
null if oneway
Throws:
XmlBlasterException
See Also:
RequestBroker

useUdpForOneway

public boolean useUdpForOneway()

ping

public java.lang.String ping(java.lang.String qos)
                      throws XmlBlasterException
Ping to check if callback server (or server protocol) is alive. This ping checks the availability on the application level.

Parameters:
qos - Currently an empty string ""
Returns:
Currently an empty string ""
Throws:
XmlBlasterException - If client not reachable

sendMessage

protected void sendMessage(MsgInfo msgInfo,
                           java.lang.String requestId,
                           MethodName methodName,
                           boolean udp)
                    throws XmlBlasterException,
                           java.io.IOException
Flush the data to the socket. Overwrite this in your derived class to send UDP

Specified by:
sendMessage in class RequestReplyExecutor
Throws:
XmlBlasterException
java.io.IOException

shutdown

public void shutdown()
Description copied from interface: I_AdminPlugin
Shutdown the plugin, free resources.

Specified by:
shutdown in interface I_AdminPlugin
Overrides:
shutdown in class RequestReplyExecutor

getVersion

public java.lang.String getVersion()
Description copied from interface: I_AdminPlugin
The version of the plugin

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

usage

public java.lang.String usage()
Specified by:
usage in interface I_AdminUsage
Overrides:
usage in class RequestReplyExecutor
Returns:
a human readable usage help string

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

getGlobalKey

public static java.lang.String getGlobalKey(SessionName sessionName)

xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.