xmlBlaster 2.2.0 client API

org.xmlBlaster.util.dispatch
Class DispatchConnectionsHandler

java.lang.Object
  extended by org.xmlBlaster.util.dispatch.DispatchConnectionsHandler
Direct Known Subclasses:
ClientDispatchConnectionsHandler

public abstract class DispatchConnectionsHandler
extends java.lang.Object

Holding all necessary infos to establish a remote connection and invoke update()/updateOneway()/ping().

This instance is a 'logical connection' hiding multiple 'physical' connections (called DispatchConnection).

One instance of this is used for each DispatchManager (one logical connection).

    State chart of the 'logical connection', initially UNDEF:

      +<-----------------initialize()--------------+
      |                                            |
      |   +<--toAlive()----+    +<-initialize()+   |          
      |   |   initialize() |    |              |   |  
      |   |                |    |              |   |  
    #########            ##########         ##########
   #         #          #          #       #          #
   #  ALIVE  #          # POLLING  #       #  DEAD    #
   #         #          #          #       #          #
    #########            ##########         ##########
      |   |                |    |             |    |
      |   +--toPolling()-->+    +--toDead()-->+    |
      |      initialize()          initialize()    |
      |                                            |
      +------------------toDead()----------------->+
                         initialize()
 

Note: Recovery from dead state is only possible if new callback addresses are passed with initialize()

Note: toAlive(), toPolling() and toDead() are called by a single DispatchConnection only, telling its state change.

Author:
xmlBlaster@marcelruff.info

Field Summary
protected  I_DispatchManager dispatchManager
           
protected  Global glob
           
 java.lang.String ME
           
protected  I_PostSendListener postSendListener
           
protected  DispatchStatistic statistic
           
 
Constructor Summary
DispatchConnectionsHandler(Global glob, I_DispatchManager dispatchManager)
          You need to call initialize() after construction.
 
Method Summary
 void addDispatchConnection(DispatchConnection con)
           
 void clearDispatchConnectionList()
           
abstract  DispatchConnection createDispatchConnection(AddressBase address)
          Create a DispatchConnection instance and load the protocol plugin.
abstract  void createFakedReturnObjects(I_QueueEntry[] entries, java.lang.String state, java.lang.String stateInfo)
          If no connection is available but the message is for example save queued, we can generate here valid return objects
abstract  java.util.ArrayList filterDistributorEntries(java.util.ArrayList entries, java.lang.Throwable ex)
           
 AddressBase getAliveAddress()
           
 DispatchConnection getAliveDispatchConnection()
           
 int getCountDispatchConnection()
           
 DispatchConnection getCurrentDispatchConnection()
           
 AddressBase getDeadAddress()
           
 DispatchConnection getDeadDispatchConnection()
           
 DispatchConnection[] getDispatchConnectionArr()
           
 I_DispatchManager getDispatchManager()
           
 DispatchStatistic getDispatchStatistic()
           
 DispatchConnection getPollingDispatchConnection()
           
 I_PostSendListener getPostSendListener()
          Access the listener for send messages.
 ConnectionStateEnum getState()
           
 void initialize(AddressBase[] cbAddr)
          Overwrite existing connections with new configuration
 boolean isAlive()
           
 boolean isDead()
           
 boolean isPolling()
           
 boolean isUndef()
           
abstract  boolean isUserThread()
           
 void registerPostSendListener(I_PostSendListener postSendListener)
          Register a listener to get notifications when a messages is successfully send.
 void send(MsgQueueEntry[] msgArr, boolean isAsyncMode)
          Send the messages back to the client.
 void shutdown()
          Stop all callback drivers of this client.
 java.lang.String toXml(java.lang.String extraOffset)
          Dump state of this object into a XML ASCII string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

public final java.lang.String ME

glob

protected final Global glob

dispatchManager

protected final I_DispatchManager dispatchManager

statistic

protected final DispatchStatistic statistic

postSendListener

protected I_PostSendListener postSendListener
Constructor Detail

DispatchConnectionsHandler

public DispatchConnectionsHandler(Global glob,
                                  I_DispatchManager dispatchManager)
                           throws XmlBlasterException
You need to call initialize() after construction.

Parameters:
dispatchManager - The message queue witch i belong to
cbAddr - The addresses i shall connect to
Throws:
XmlBlasterException
Method Detail

getDispatchManager

public final I_DispatchManager getDispatchManager()

getPostSendListener

public final I_PostSendListener getPostSendListener()
Access the listener for send messages.

Returns:
Returns the postSendListener or null if none is registered

registerPostSendListener

public final void registerPostSendListener(I_PostSendListener postSendListener)
Register a listener to get notifications when a messages is successfully send. Max one can be registered, any old one will be overwritten

Parameters:
postSendListener - The postSendListener to set.

initialize

public final void initialize(AddressBase[] cbAddr)
                      throws XmlBlasterException
Overwrite existing connections with new configuration

Throws:
XmlBlasterException

createDispatchConnection

public abstract DispatchConnection createDispatchConnection(AddressBase address)
                                                     throws XmlBlasterException
Create a DispatchConnection instance and load the protocol plugin. You should call initialie() later.

Throws:
XmlBlasterException

getCurrentDispatchConnection

public final DispatchConnection getCurrentDispatchConnection()
Returns:
a currently available callback connection (with any state) or null

getAliveDispatchConnection

public final DispatchConnection getAliveDispatchConnection()
Returns:
a currently alive callback connection or null

getPollingDispatchConnection

public final DispatchConnection getPollingDispatchConnection()
Returns:
a currently polling callback connection or null

getAliveAddress

public final AddressBase getAliveAddress()
Returns:
a currently alive callback connection or null

getDeadAddress

public final AddressBase getDeadAddress()
Returns:
a currently dead callback connection or null

getDeadDispatchConnection

public final DispatchConnection getDeadDispatchConnection()
Returns:
a dead callback connection or null

getDispatchConnectionArr

public DispatchConnection[] getDispatchConnectionArr()
Returns:
a copy snapshot of the current connections

getCountDispatchConnection

public int getCountDispatchConnection()
Returns:
Number of established callback connections

addDispatchConnection

public void addDispatchConnection(DispatchConnection con)

clearDispatchConnectionList

public void clearDispatchConnectionList()

isUndef

public final boolean isUndef()
Returns:
true if not initialized yet.

isAlive

public final boolean isAlive()
Returns:
true if at least one connection is alive

isPolling

public final boolean isPolling()
Returns:
true if no connection alive but at least one is still polling

isDead

public final boolean isDead()
Returns:
true if all connections are lost (polling is given up)

getState

public ConnectionStateEnum getState()

createFakedReturnObjects

public abstract void createFakedReturnObjects(I_QueueEntry[] entries,
                                              java.lang.String state,
                                              java.lang.String stateInfo)
                                       throws XmlBlasterException
If no connection is available but the message is for example save queued, we can generate here valid return objects

Parameters:
state - e.g. Constants.STATE_OK
Throws:
XmlBlasterException

send

public void send(MsgQueueEntry[] msgArr,
                 boolean isAsyncMode)
          throws java.lang.Throwable,
                 XmlBlasterException
Send the messages back to the client. If there are more fallback addresses, these will be used if the first fails.

The RETURN value is transferred in the msgArr[i].getReturnObj(), for oneway updates it is null

Parameters:
isAsyncMode - true if coming from queue
Throws:
java.lang.Throwable
XmlBlasterException

getDispatchStatistic

public final DispatchStatistic getDispatchStatistic()
Returns:
A container holding some statistical delivery information, is never null

isUserThread

public abstract boolean isUserThread()

shutdown

public final void shutdown()
Stop all callback drivers of this client.


toXml

public final java.lang.String toXml(java.lang.String extraOffset)
Dump state of this object into a XML ASCII string.

Parameters:
extraOffset - indenting of tags for nice output
Returns:
internal state of SessionInfo as a XML ASCII string

filterDistributorEntries

public abstract java.util.ArrayList filterDistributorEntries(java.util.ArrayList entries,
                                                             java.lang.Throwable ex)

xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.