xmlBlaster 2.2.0 API

org.xmlBlaster.client.protocol.xmlrpc
Class XmlRpcConnection

java.lang.Object
  extended by org.xmlBlaster.client.protocol.xmlrpc.XmlRpcConnection
All Implemented Interfaces:
I_XmlBlasterConnection, I_Plugin

public class XmlRpcConnection
extends java.lang.Object
implements I_XmlBlasterConnection

This is an xmlBlaster proxy. It implements the interface I_XmlBlasterConnection. The client can invoke it as if the xmlBlaster would be on the same VM, making this way the xml-rpc protocol totally transparent.

Author:
Michele Laghi, Marcel Ruff.

Field Summary
private static java.lang.String AUTH
           
protected  Address clientAddress
           
protected  ConnectReturnQos connectReturnQos
           
private  boolean contentAsString
           
private  boolean forceNewConnectionOnReconnect
          This flag is used since it may be necessary to throw away the connection if a proxy or a gateway is somehow holding the session and after a failure constantly throwing exceptions.
private  Global glob
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
protected  PluginInfo pluginInfo
           
private  java.lang.String secretSessionId
           
private  XmlScriptSerializer serializer
           
private  java.lang.String sessionId
           
static java.lang.String XML_SCRIPT_INVOKE
           
private static java.lang.String XMLBLASTER
           
private  org.apache.xmlrpc.client.XmlRpcClient xmlRpcClient
           
private  XmlRpcUrl xmlRpcUrl
           
private  boolean xmlScript
           
 
Constructor Summary
XmlRpcConnection()
          Called by plugin loader which calls init(Global, PluginInfo) thereafter.
XmlRpcConnection(Global glob)
          Connect to xmlBlaster using XMLRPC.
XmlRpcConnection(Global glob, java.applet.Applet ap)
          Connect to xmlBlaster using XMLRPC.
 
Method Summary
 java.lang.String connect(java.lang.String connectQos)
          Login to the server.
 void connectLowlevel(Address address)
          Initialize the driver and verify if the remote side is reachable on the low-level protocol layer.
 boolean disconnect(java.lang.String disconnectQos)
          Does a logout.
 java.lang.String[] erase(java.lang.String xmlKey_literal, java.lang.String qos_literal)
          Delete messages.
static XmlBlasterException extractXmlBlasterException(Global glob, org.apache.xmlrpc.XmlRpcException e, ErrorCode fallback, java.lang.String txt)
          Helma XmlRpc does in XmlRpcServer.java:314 an exception.toString() which is sent back to the client.
static XmlBlasterException extractXmlBlasterException(Global glob, org.apache.xmlrpc.XmlRpcException e, java.lang.String txt)
           
 MsgUnitRaw[] get(java.lang.String xmlKey_literal, java.lang.String qos_literal)
          Synchronous access a message.
 XmlRpcConnection getCopy()
           
 java.lang.String getProtocol()
           
 XmlScriptSerializer getSerializer()
          This is used by the callback driver in case the xmlScript has been set to true (for update responses and ca
 java.lang.String getSessionId()
           
 java.lang.String getType()
          Enforced by I_Plugin
 void getUpdates(I_CallbackExtended cb)
          Publish multiple messages in one sweep.
 java.lang.String getVersion()
          Enforced by I_Plugin
 org.apache.xmlrpc.client.XmlRpcClient getXmlRpcClient()
           
 void init(Global global, PluginInfo plInfo)
          This method is called by the PluginManager (enforced by I_Plugin).
 boolean isLoggedIn()
           
static void main(java.lang.String[] args)
          For Testing.
 java.lang.String ping(java.lang.String str)
          Check server.
 java.lang.String publish(MsgUnitRaw msgUnit)
          Publish a message.
 java.lang.String[] publishArr(MsgUnitRaw[] msgUnitArr)
          Publish multiple messages in one sweep.
 void publishOneway(MsgUnitRaw[] msgUnitArr)
          Publish multiple messages in one sweep.
 I_ProgressListener registerProgressListener(I_ProgressListener listener)
          Register a listener for to receive information about the progress of incoming data.
 void resetConnection()
          Reset the driver on problems.
 void sendAckOrEx(java.lang.String uniqueId, java.lang.String[] acks, java.lang.String exTxt)
           
 void sendShutdownCb()
           
private  java.lang.Object sendXmlScript(java.lang.String literal, java.lang.String prefix, boolean singleChannel)
           
 void setConnectReturnQos(ConnectReturnQos connectReturnQos)
          Pass the driver the decrypted and parsed ConnectReturnQos directly after a connect.
 void shutdown()
          Shut down.
 java.lang.String subscribe(java.lang.String xmlKey_literal, java.lang.String qos_literal)
          Enforced by I_XmlBlasterConnection interface (failsafe mode).
 java.lang.String toXml()
           
 java.lang.String toXml(java.lang.String extraOffset)
          Dump of the server, remove in future.
 java.lang.String[] unSubscribe(java.lang.String xmlKey_literal, java.lang.String qos_literal)
          Unsubscribe from messages.
static java.lang.String usage()
          Command line usage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private java.lang.String ME

glob

private Global glob

log

private static java.util.logging.Logger log

xmlRpcUrl

private XmlRpcUrl xmlRpcUrl

xmlRpcClient

private org.apache.xmlrpc.client.XmlRpcClient xmlRpcClient

sessionId

private java.lang.String sessionId

connectReturnQos

protected ConnectReturnQos connectReturnQos

clientAddress

protected Address clientAddress

pluginInfo

protected PluginInfo pluginInfo

secretSessionId

private java.lang.String secretSessionId

contentAsString

private boolean contentAsString

xmlScript

private boolean xmlScript

serializer

private XmlScriptSerializer serializer

AUTH

private static final java.lang.String AUTH
See Also:
Constant Field Values

XMLBLASTER

private static final java.lang.String XMLBLASTER
See Also:
Constant Field Values

XML_SCRIPT_INVOKE

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

forceNewConnectionOnReconnect

private boolean forceNewConnectionOnReconnect
This flag is used since it may be necessary to throw away the connection if a proxy or a gateway is somehow holding the session and after a failure constantly throwing exceptions.

Constructor Detail

XmlRpcConnection

public XmlRpcConnection()
Called by plugin loader which calls init(Global, PluginInfo) thereafter.


XmlRpcConnection

public XmlRpcConnection(Global glob)
                 throws XmlBlasterException
Connect to xmlBlaster using XMLRPC.

Throws:
XmlBlasterException

XmlRpcConnection

public XmlRpcConnection(Global glob,
                        java.applet.Applet ap)
                 throws XmlBlasterException
Connect to xmlBlaster using XMLRPC.

Throws:
XmlBlasterException
Method Detail

getType

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

Specified by:
getType in interface I_Plugin

getVersion

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

Specified by:
getVersion in interface I_Plugin

init

public void init(Global global,
                 PluginInfo plInfo)
          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)

getCopy

public XmlRpcConnection getCopy()
                         throws XmlBlasterException
Throws:
XmlBlasterException

getProtocol

public final java.lang.String getProtocol()
Specified by:
getProtocol in interface I_XmlBlasterConnection
Returns:
The connection protocol name "XMLRPC"

connectLowlevel

public void connectLowlevel(Address address)
                     throws XmlBlasterException
Description copied from interface: I_XmlBlasterConnection
Initialize the driver and verify if the remote side is reachable on the low-level protocol layer. Calling this method multiple times will do noting if a low level connection is available.

Specified by:
connectLowlevel in interface I_XmlBlasterConnection
Parameters:
address - Contains the remote address, e.g. the host and port where the remote server listens
Throws:
XmlBlasterException - ErrorCode.COMMUNICATION* if the server is not reachable, in this case we can poll for the server.
Other errors if for example a malformed address is passed, in this case we stop and give up.
See Also:
I_XmlBlasterConnection.connectLowlevel(Address)

getSerializer

public XmlScriptSerializer getSerializer()
This is used by the callback driver in case the xmlScript has been set to true (for update responses and ca

Returns:

resetConnection

public void resetConnection()
Description copied from interface: I_XmlBlasterConnection
Reset the driver on problems. This method is called by the dispatcher framework on transition to POLLING, the protocol plugin must be able to establish a new connection after this call with a call to connectLowLevel().

Specified by:
resetConnection in interface I_XmlBlasterConnection

getXmlRpcClient

public org.apache.xmlrpc.client.XmlRpcClient getXmlRpcClient()
                                                      throws XmlBlasterException
Throws:
XmlBlasterException

connect

public java.lang.String connect(java.lang.String connectQos)
                         throws XmlBlasterException
Login to the server.

Specified by:
connect in interface I_XmlBlasterConnection
Parameters:
connectQos - The encrypted connect QoS
Returns:
ConnectReturnQos XML string
Throws:
XmlBlasterException - if login fails

setConnectReturnQos

public void setConnectReturnQos(ConnectReturnQos connectReturnQos)
                         throws XmlBlasterException
Description copied from interface: I_XmlBlasterConnection
Pass the driver the decrypted and parsed ConnectReturnQos directly after a connect. Some driver take the secretSessionId from it or a returned remote address

Specified by:
setConnectReturnQos in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
I_XmlBlasterConnection.setConnectReturnQos(ConnectReturnQos)

disconnect

public boolean disconnect(java.lang.String disconnectQos)
Does a logout.

Specified by:
disconnect in interface I_XmlBlasterConnection
Parameters:
sessionId - The client sessionId

shutdown

public void shutdown()
              throws XmlBlasterException
Shut down. Is called by logout()

Specified by:
shutdown in interface I_XmlBlasterConnection
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.


isLoggedIn

public boolean isLoggedIn()
Specified by:
isLoggedIn in interface I_XmlBlasterConnection
Returns:
true if you are logged in

subscribe

public final java.lang.String subscribe(java.lang.String xmlKey_literal,
                                        java.lang.String qos_literal)
                                 throws XmlBlasterException
Enforced by I_XmlBlasterConnection interface (failsafe mode). Subscribe to messages.

Specified by:
subscribe in interface I_XmlBlasterConnection
Throws:
XmlBlasterException

unSubscribe

public final java.lang.String[] unSubscribe(java.lang.String xmlKey_literal,
                                            java.lang.String qos_literal)
                                     throws XmlBlasterException
Unsubscribe from messages.

Specified by:
unSubscribe in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
The interface.unSubscribe requirement

publish

public final java.lang.String publish(MsgUnitRaw msgUnit)
                               throws XmlBlasterException
Publish a message.

Specified by:
publish in interface I_XmlBlasterConnection
Throws:
XmlBlasterException

publishArr

public final java.lang.String[] publishArr(MsgUnitRaw[] msgUnitArr)
                                    throws XmlBlasterException
Publish multiple messages in one sweep.

Specified by:
publishArr in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
The interface.publish requirement

publishOneway

public final void publishOneway(MsgUnitRaw[] msgUnitArr)
                         throws XmlBlasterException
Publish multiple messages in one sweep.

Specified by:
publishOneway in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
The interface.publish requirement

erase

public final java.lang.String[] erase(java.lang.String xmlKey_literal,
                                      java.lang.String qos_literal)
                               throws XmlBlasterException
Delete messages.

Specified by:
erase in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
The interface.erase requirement

get

public final MsgUnitRaw[] get(java.lang.String xmlKey_literal,
                              java.lang.String qos_literal)
                       throws XmlBlasterException
Synchronous access a message.

Specified by:
get in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
The interface.get requirement

extractXmlBlasterException

public static XmlBlasterException extractXmlBlasterException(Global glob,
                                                             org.apache.xmlrpc.XmlRpcException e,
                                                             java.lang.String txt)

extractXmlBlasterException

public static XmlBlasterException extractXmlBlasterException(Global glob,
                                                             org.apache.xmlrpc.XmlRpcException e,
                                                             ErrorCode fallback,
                                                             java.lang.String txt)
Helma XmlRpc does in XmlRpcServer.java:314 an exception.toString() which is sent back to the client.
xml-rpc exception: org.apache.xmlrpc.XmlRpcException: java.lang.Exception: errorCode=resource.unavailable message=The key 'NotExistingMessage' is not available.

Parameters:
glob -
e - The original exception
fallback - The error code to use if e is unparsable

ping

public java.lang.String ping(java.lang.String str)
                      throws XmlBlasterException
Check server.

Specified by:
ping in interface I_XmlBlasterConnection
Returns:
The StatusQosData string
Throws:
XmlBlasterException
See Also:
CORBA xmlBlaster.idl

toXml

public java.lang.String toXml()
                       throws XmlBlasterException
Throws:
XmlBlasterException

toXml

public java.lang.String toXml(java.lang.String extraOffset)
                       throws XmlBlasterException
Dump of the server, remove in future.

Throws:
XmlBlasterException

getUpdates

public final void getUpdates(I_CallbackExtended cb)
                      throws XmlBlasterException
Publish multiple messages in one sweep.

Throws:
XmlBlasterException
See Also:
The interface.publish requirement

sendAckOrEx

public void sendAckOrEx(java.lang.String uniqueId,
                        java.lang.String[] acks,
                        java.lang.String exTxt)

sendShutdownCb

public void sendShutdownCb()

registerProgressListener

public I_ProgressListener registerProgressListener(I_ProgressListener listener)
Register a listener for to receive information about the progress of incoming data. Only one listener is supported, the last call overwrites older calls. This implementation does nothing here, it just returns null.

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

usage

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

These variables may be set in xmlBlaster.properties as well. Don't use the "-" prefix there.


sendXmlScript

private final java.lang.Object sendXmlScript(java.lang.String literal,
                                             java.lang.String prefix,
                                             boolean singleChannel)
                                      throws org.apache.xmlrpc.XmlRpcException,
                                             XmlBlasterException
Throws:
org.apache.xmlrpc.XmlRpcException
XmlBlasterException

main

public static void main(java.lang.String[] args)
For Testing.
 java org.xmlBlaster.client.protocol.xmlrpc.XmlRpcConnection
 


getSessionId

public java.lang.String getSessionId()

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.