xmlBlaster 2.1.0 API

org.xmlBlaster.client.protocol.rmi
Class RmiConnection

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

public class RmiConnection
extends java.lang.Object
implements I_XmlBlasterConnection

This is a helper class, helping a Java client to connect to xmlBlaster using RMI.

Please note that you don't need to use this wrapper, you can use the raw RMI interface as well. You can also hack your own little wrapper, which does exactly what you want.

There is a constructor for applets, and standalone Java clients.

If you need a failsafe client, you can invoke the xmlBlaster RMI methods through this class as well (for example use rmiConnection.publish() instead of the direct RMI server.publish()).

If you want to connect from a servlet, please use the framework in xmlBlaster/src/java/org/xmlBlaster/protocol/http

  # Configure RMI plugin to load:
  ClientProtocolPlugin[RMI][1.0]=org.xmlBlaster.client.protocol.rmi.RmiConnection
 

Author:
Marcel Ruff.
See Also:
The RMI requirement

Field Summary
private  I_AuthServer authServer
           
private  I_XmlBlaster blasterServer
           
protected  Address clientAddress
           
static int DEFAULT_REGISTRY_PORT
          XmlBlaster RMI registry listen port is 1099, to access for bootstrapping
private  Global glob
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
private  RmiUrl rmiUrl
           
private  java.lang.String sessionId
           
private  boolean verbose
           
 
Constructor Summary
RmiConnection()
          Called by plugin loader which calls init(Global, PluginInfo) thereafter.
RmiConnection(Global glob)
          RMI client access to xmlBlaster for normal client applications.
RmiConnection(Global glob, java.applet.Applet ap)
          RMI client access to xmlBlaster for applets.
 
Method Summary
 java.lang.String connect(java.lang.String connectQos)
          Login to the server.
 void connectLowlevel(Address address)
          Connect to RMI server.
 boolean disconnect(java.lang.String disconnectQos)
          Logout from the server.
 java.lang.String[] erase(java.lang.String xmlKey, java.lang.String qos)
           
 MsgUnitRaw[] get(java.lang.String xmlKey, java.lang.String qos)
           
 java.lang.String getProtocol()
           
 java.lang.String getType()
          Enforced by I_Plugin
 java.lang.String getVersion()
          Enforced by I_Plugin
private  I_XmlBlaster getXmlBlaster()
          Accessing the xmlBlaster handle.
 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager (enforced by I_Plugin).
 boolean isLoggedIn()
           
private  java.rmi.Remote lookup(java.lang.String addr)
          Connect to RMI server.
 java.lang.String ping(java.lang.String str)
          Check server.
 java.lang.String publish(MsgUnitRaw msgUnit)
          Publish fault-tolerant the given message.
 java.lang.String[] publishArr(MsgUnitRaw[] msgUnitArr)
           
 void publishOneway(MsgUnitRaw[] msgUnitArr)
          RMI does not support oneway messages.
 I_ProgressListener registerProgressListener(I_ProgressListener listener)
          Register a listener for to receive information about the progress of incoming data.
 void resetConnection()
          Reset
 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, java.lang.String qos)
          Enforced by I_XmlBlasterConnection interface (failsafe mode).
 java.lang.String[] unSubscribe(java.lang.String xmlKey, java.lang.String qos)
          Enforced by I_XmlBlasterConnection interface (failsafe mode)
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

authServer

private I_AuthServer authServer

blasterServer

private I_XmlBlaster blasterServer

sessionId

private java.lang.String sessionId

clientAddress

protected Address clientAddress

rmiUrl

private RmiUrl rmiUrl

DEFAULT_REGISTRY_PORT

public static final int DEFAULT_REGISTRY_PORT
XmlBlaster RMI registry listen port is 1099, to access for bootstrapping

See Also:
Constant Field Values

verbose

private boolean verbose
Constructor Detail

RmiConnection

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


RmiConnection

public RmiConnection(Global glob)
              throws XmlBlasterException
RMI client access to xmlBlaster for normal client applications.

Parameters:
arg - parameters given on command line
Throws:
XmlBlasterException

RmiConnection

public RmiConnection(Global glob,
                     java.applet.Applet ap)
              throws XmlBlasterException
RMI client access to xmlBlaster for applets.

Parameters:
ap - Applet handle
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 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)

connectLowlevel

public void connectLowlevel(Address address)
                     throws XmlBlasterException
Connect to RMI server.

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.

lookup

private java.rmi.Remote lookup(java.lang.String addr)
                        throws XmlBlasterException
Connect to RMI server.

Throws:
XmlBlasterException
See Also:
I_XmlBlasterConnection.connectLowlevel(Address)

resetConnection

public void resetConnection()
Reset

Specified by:
resetConnection in interface I_XmlBlasterConnection

getXmlBlaster

private I_XmlBlaster getXmlBlaster()
                            throws XmlBlasterException
Accessing the xmlBlaster handle. For internal use, throws an ordinary Exception if xmlBlaster==null We use this for similar handling as org.omg exceptions.

Returns:
Server
Throws:
XmlBlasterException

getProtocol

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

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)
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
See Also:
I_XmlBlasterConnection.setConnectReturnQos(ConnectReturnQos)

disconnect

public boolean disconnect(java.lang.String disconnectQos)
Logout from the server.

The callback server is removed as well, releasing all RMI threads. Note that this kills the server ping thread as well (if in failsafe mode)

Specified by:
disconnect in interface I_XmlBlasterConnection
Parameters:
disconnectQos - The QoS or null
Returns:
true successfully logged out false failure on gout

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,
                                        java.lang.String qos)
                                 throws XmlBlasterException
Enforced by I_XmlBlasterConnection interface (failsafe mode). see explanations of publish() method.

Specified by:
subscribe in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
CORBA xmlBlaster.idl

unSubscribe

public final java.lang.String[] unSubscribe(java.lang.String xmlKey,
                                            java.lang.String qos)
                                     throws XmlBlasterException
Enforced by I_XmlBlasterConnection interface (failsafe mode)

Specified by:
unSubscribe in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
CORBA xmlBlaster.idl

publish

public final java.lang.String publish(MsgUnitRaw msgUnit)
                               throws XmlBlasterException
Publish fault-tolerant the given message.

This is a wrapper around the raw RMI publish() method If the server disappears you get an exception. This call will not block.

Enforced by I_XmlBlasterConnection interface (failsafe mode)

Specified by:
publish in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
CORBA xmlBlaster.idl

publishArr

public java.lang.String[] publishArr(MsgUnitRaw[] msgUnitArr)
                              throws XmlBlasterException
Specified by:
publishArr in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
CORBA xmlBlaster.idl

publishOneway

public void publishOneway(MsgUnitRaw[] msgUnitArr)
                   throws XmlBlasterException
RMI does not support oneway messages.

Specified by:
publishOneway in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
CORBA xmlBlaster.idl

erase

public final java.lang.String[] erase(java.lang.String xmlKey,
                                      java.lang.String qos)
                               throws XmlBlasterException
Specified by:
erase in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
CORBA xmlBlaster.idl

get

public final MsgUnitRaw[] get(java.lang.String xmlKey,
                              java.lang.String qos)
                       throws XmlBlasterException
Specified by:
get in interface I_XmlBlasterConnection
Throws:
XmlBlasterException
See Also:
CORBA xmlBlaster.idl

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

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

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.


xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.