xmlBlaster 2.2.0 API

org.xmlBlaster.client.protocol.rmi
Class RmiCallbackServer

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by org.xmlBlaster.client.protocol.rmi.RmiCallbackServer
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, I_CallbackServer, I_XmlBlasterCallback, I_Plugin

public class RmiCallbackServer
extends java.rmi.server.UnicastRemoteObject
implements I_XmlBlasterCallback, I_CallbackServer

Example for a RMI callback implementation.

You can use this default callback handling with your clients, but if you need other handling of callbacks, take a copy of this Callback implementation and add your own code.

A rmi-registry server is created automatically, if there is running already one, that is used.
You can specify another port or host to create/use a rmi-registry server:

     -dispatch/callback/plugin/rmi/registryPort Specify a port number where rmiregistry listens.
                         Default is port 1099, the port 0 switches this feature off.
     -dispatch/callback/plugin/rmi/hostname     Specify a hostname where rmiregistry runs.
                         Default is the localhost.
 

Note: The security manager must be initialized properly before you use an instance of this class.
RmiConnection does it in its constructor if you use this class, or you could use
XmlBlasterSecurityManager.createSecurityManager();
to do so yourself.

Invoke options:

   java -Djava.rmi.server.codebase=file:///${XMLBLASTER_HOME}/classes/  \
        -Djava.security.policy=${XMLBLASTER_HOME}/config/xmlBlaster.policy \
        -Djava.rmi.server.hostname=hostname.domainname
        MyApp -dispatch/connection/plugin/rmi/registryPort 2079
 

See Also:
Serialized Form

Field Summary
private  CallbackAddress callbackAddress
           
private  java.lang.String callbackRmiServerBindName
          The name for the RMI registry
private  I_CallbackExtended client
           
static int DEFAULT_REGISTRY_PORT
          XmlBlaster RMI registry listen port is 1099, to register callback server
private  Global glob
           
private static java.util.logging.Logger log
           
private  java.lang.String loginName
           
private  java.lang.String ME
           
private  RmiUrl rmiUrl
           
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
RmiCallbackServer()
           
 
Method Summary
private  void bindToRegistry(I_XmlBlasterCallback callbackRmiServer)
          Publish the RMI xmlBlaster server to rmi registry.
 void createCallbackServer(I_XmlBlasterCallback callbackRmiServer)
          Building a Callback server, using the tie approach.
 java.lang.String getCbAddress()
          Returns the current callback address.
 java.lang.String getCbProtocol()
          Returns the 'well known' protocol type.
 java.lang.String getType()
          Enforced by I_Plugin
 java.lang.String getVersion()
          Enforced by I_Plugin
 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager (enforced by I_Plugin).
 void initialize(Global glob, java.lang.String name, CallbackAddress callbackAddress, I_CallbackExtended client)
          Construct the callback server.
 java.lang.String ping(java.lang.String qos)
          Ping to check if the xmlBlaster server is alive.
 void shutdown()
          Shutdown the callback server.
 java.lang.String[] update(java.lang.String cbSessionId, MsgUnitRaw[] msgUnitArr)
          This is the callback method invoked from xmlBlaster informing the client in an asynchronous mode about new messages.
 void updateOneway(java.lang.String cbSessionId, MsgUnitRaw[] msgUnitArr)
          The oneway variant for better performance.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ME

private java.lang.String ME

glob

private Global glob

log

private static java.util.logging.Logger log

client

private I_CallbackExtended client

loginName

private java.lang.String loginName

callbackRmiServerBindName

private java.lang.String callbackRmiServerBindName
The name for the RMI registry


DEFAULT_REGISTRY_PORT

public static final int DEFAULT_REGISTRY_PORT
XmlBlaster RMI registry listen port is 1099, to register callback server

See Also:
Constant Field Values

rmiUrl

private RmiUrl rmiUrl

callbackAddress

private CallbackAddress callbackAddress
Constructor Detail

RmiCallbackServer

public RmiCallbackServer()
                  throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException
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)
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)

initialize

public void initialize(Global glob,
                       java.lang.String name,
                       CallbackAddress callbackAddress,
                       I_CallbackExtended client)
                throws XmlBlasterException
Construct the callback server.

Specified by:
initialize in interface I_CallbackServer
Parameters:
glob - The global handle with your environment settings
name - The login name of the client, for logging only
callbackAddress - The address configuration of this callback server
client - Your implementation to receive the callback messages from xmlBlaster
Throws:
XmlBlasterException

createCallbackServer

public void createCallbackServer(I_XmlBlasterCallback callbackRmiServer)
                          throws XmlBlasterException
Building a Callback server, using the tie approach.

Parameters:
the - BlasterCallback server
Throws:
XmlBlasterException - if the BlasterCallback server can't be created id="CallbackCreationError"

bindToRegistry

private void bindToRegistry(I_XmlBlasterCallback callbackRmiServer)
                     throws XmlBlasterException
Publish the RMI xmlBlaster server to rmi registry.

The bind name is typically "rmi://localhost:1099/xmlBlaster"

Throws:
XmlBlasterException - RMI registry error handling

getCbProtocol

public final java.lang.String getCbProtocol()
Description copied from interface: I_CallbackServer
Returns the 'well known' protocol type.

Specified by:
getCbProtocol in interface I_CallbackServer
Returns:
The protocol name "RMI"

getCbAddress

public java.lang.String getCbAddress()
                              throws XmlBlasterException
Description copied from interface: I_CallbackServer
Returns the current callback address.

Specified by:
getCbAddress in interface I_CallbackServer
Returns:
The RMI address of this server, which can be used for the connectQos
Throws:
XmlBlasterException

shutdown

public void shutdown()
Shutdown the callback server.

Specified by:
shutdown in interface I_CallbackServer
Specified by:
shutdown in interface I_Plugin

update

public java.lang.String[] update(java.lang.String cbSessionId,
                                 MsgUnitRaw[] msgUnitArr)
                          throws java.rmi.RemoteException,
                                 XmlBlasterException
This is the callback method invoked from xmlBlaster informing the client in an asynchronous mode about new messages.

It implements the interface I_XmlBlasterCallback

The call is converted to the native MsgUnitRaw, and the other update() method of this class is invoked.

Specified by:
update in interface I_XmlBlasterCallback
Parameters:
msgUnitArr - Contains a MsgUnitRaw structs (your message) for CORBA
Throws:
java.rmi.RemoteException
XmlBlasterException
See Also:
CORBA xmlBlaster.idl

updateOneway

public void updateOneway(java.lang.String cbSessionId,
                         MsgUnitRaw[] msgUnitArr)
                  throws java.rmi.RemoteException
The oneway variant for better performance.

Specified by:
updateOneway in interface I_XmlBlasterCallback
Throws:
java.rmi.RemoteException

ping

public java.lang.String ping(java.lang.String qos)
                      throws java.rmi.RemoteException
Ping to check if the xmlBlaster server is alive.

Specified by:
ping in interface I_XmlBlasterCallback
Returns:
Currently an empty string ""
Throws:
java.rmi.RemoteException
See Also:
I_CallbackDriver.ping(String)

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.