xmlBlaster 2.1.0 API

org.xmlBlaster.client.protocol.corba
Class CorbaConnection

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

public final class CorbaConnection
extends java.lang.Object
implements I_XmlBlasterConnection, I_Plugin

This is a helper class, helping a Java client to connect to xmlBlaster using IIOP (CORBA).

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

This class converts the Corba based exception
org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException
to
org.xmlBlaster.util.XmlBlasterException

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

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

You should set jacorb.retries=0 in $HOME/.jacorb_properties if you use the failsafe mode

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

NOTE: JacORB 1.1 does not release the listener thread and the poa threads of the callback server on orb.shutdown().
Therefor we recycle the ORB and POA instance to avoid a thread leak. The drawback is that a client for the bug being can't change the orb behavior after the first time the ORB is created.
This will be fixed as soon as possible.

Author:
Marcel Ruff.
See Also:
CORBA xmlBlaster.idl

Field Summary
private  AuthServer authServer
           
private  Address clientAddress
           
private  Global glob
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
private  org.omg.CosNaming.NamingContextExt nameService
           
private  org.omg.CORBA.ORB orb
           
private  PluginInfo pluginInfo
           
private  java.lang.String sessionId
           
private  boolean verbose
           
private  Server xmlBlaster
           
 
Constructor Summary
CorbaConnection()
          Called by plugin loader which calls init(Global, PluginInfo) thereafter.
CorbaConnection(Global glob, java.applet.Applet ap)
          CORBA client access to xmlBlaster for applets.
 
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 qos)
          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)
           
 AuthServer getAuthenticationService(Address address)
          Access the authentication service.
(package private)  org.omg.CosNaming.NamingContextExt getNamingService()
          Locate the CORBA Name Service.
 org.omg.CORBA.ORB getOrb()
          Accessing the orb handle.
 java.lang.String getProtocol()
           
 java.lang.String getType()
          Enforced by I_Plugin
 java.lang.String getVersion()
          Enforced by I_Plugin
private  Server getXmlBlaster()
          Accessing the xmlBlaster handle.
 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager (enforced by I_Plugin).
 boolean isLoggedIn()
           
 java.lang.String ping(java.lang.String qos)
          Ping the server on physical level and/or application level (see AvailabilityChecker).
 java.lang.String publish(MsgUnitRaw msgUnit)
          Publish fault-tolerant the given message.
 java.lang.String[] publishArr(MsgUnitRaw[] msgUnitArr)
           
 void publishOneway(MsgUnitRaw[] msgUnitArr)
           
 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 the callback server.
 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

orb

private org.omg.CORBA.ORB orb

nameService

private org.omg.CosNaming.NamingContextExt nameService

authServer

private AuthServer authServer

xmlBlaster

private Server xmlBlaster

clientAddress

private Address clientAddress

sessionId

private java.lang.String sessionId

verbose

private boolean verbose

pluginInfo

private PluginInfo pluginInfo
Constructor Detail

CorbaConnection

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


CorbaConnection

public CorbaConnection(Global glob,
                       java.applet.Applet ap)
CORBA client access to xmlBlaster for applets.

Use these environment settings for JacORB if you don't use this constructor!
Example:

     <APPLET
        CODEBASE = "http://localhost"
        CODE     = "DemoApplet.class"
        NAME     = "xmlBlaster demo"
        WIDTH    = 200
        HEIGHT   = 200
        HSPACE   = 0
        VSPACE   = 0
        ALIGN    = middle
     >
     <PARAM name=org.omg.CORBA.ORBClass value=org.jacorb.orb.ORB>
     <PARAM name=org.omg.CORBA.ORBSingletonClass value=org.jacorb.orb.ORBSingleton>
     <PARAM name=SVCnameroot value=xmlBlaster-Authenticate>
     </APPLET>
  

Parameters:
ap - Applet handle
Method Detail

getType

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

Specified by:
getType in interface I_Plugin
Returns:
"IOR"

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)
This method is called by the PluginManager (enforced by I_Plugin).

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

resetConnection

public void resetConnection()
Reset

Specified by:
resetConnection in interface I_XmlBlasterConnection

getProtocol

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

getOrb

public org.omg.CORBA.ORB getOrb()
Accessing the orb handle.

Returns:
org.omg.CORBA.ORB

getXmlBlaster

private Server getXmlBlaster()
                      throws XmlBlasterException
Accessing the xmlBlaster handle. For internal use, throws a COMMUNICATION XmlBlasterException if xmlBlaster==null We use this for similar handling as org.omg exceptions.

Returns:
Server
Throws:
XmlBlasterException

getNamingService

org.omg.CosNaming.NamingContextExt getNamingService()
                                              throws XmlBlasterException
Locate the CORBA Name Service.

The found name service is cached, for better performance in subsequent calls

Returns:
NamingContextExt, reference on name service
Throws:
XmlBlasterException - id="NoNameService" CORBA error handling if no naming service is found

getAuthenticationService

public AuthServer getAuthenticationService(Address address)
                                    throws XmlBlasterException
Access the authentication service.

There are several ways to bootstrap the authentication service:

Returns:
a handle on the AuthServer IDL interface
Throws:
XmlBlasterException - id="NoAuthService"

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

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)

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 qos)
Logout from the server. Note that this kills the server ping thread as well (if in failsafe mode)

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

shutdown

public void shutdown()
              throws XmlBlasterException
Shut down the callback server. 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 subscribe() 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 CORBA 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
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 qos)
                      throws XmlBlasterException
Description copied from interface: I_XmlBlasterConnection
Ping the server on physical level and/or application level (see AvailabilityChecker). This ping must be successful if the client can reach the server, with or without authentication (with or without connect()).

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

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.