org.jboss.soa.esb.listeners.gateway
Class GatewayListenerController

java.lang.Object
  extended by org.jboss.soa.esb.listeners.gateway.GatewayListenerController
All Implemented Interfaces:
java.lang.Runnable

public class GatewayListenerController
extends java.lang.Object
implements java.lang.Runnable


Nested Class Summary
static class GatewayListenerController.State
           
 
Field Summary
static java.text.SimpleDateFormat _dateFormat
           
protected  int _defaultReloadMillis
           
static java.lang.String END_TIME_TAG
           
static java.lang.String GATEWAY_CLASS_TAG
           
static java.lang.String RELOAD_SECONDS_TAG
           
 
Constructor Summary
protected GatewayListenerController()
          Package private default constructor.
  GatewayListenerController(ConfigTree config)
          Construct a Listener Manager using the specified listener configuration.
  GatewayListenerController(java.lang.String p_sParameterName)
          Construct a Listener Manager from the named repository based configuration.
 
Method Summary
 void checkParms(ConfigTree p_oP)
          Check to see if all needed parameters are there, and assign default values to some of them
 boolean continueLooping()
          Helper accessor for child processes that provides info to determine if they can continue with yet another execution cycle
 boolean endNotRequested()
          Accessor to determine if execution time is not expired, and no shutdown request received
 boolean endRequested()
          Accessor to determine if execution time is expired or shutdown requested
 java.util.Map<java.lang.String,java.lang.Object> getControllerAttributes()
          Obtain a shallow copy of needed atributes in this object's last loaded parameter tree

The local bject is cloned so child threads can use it as they choose to without interfering with the environment

Listener processes controlled by this object should keep a reference to this object at construction time, and not call this method again unless they specifically need updated values.

 java.util.Collection<EPR> getEprs(java.lang.String category, java.lang.String name)
           
 GatewayListenerController.State getState()
           
static void main(java.lang.String[] args)
           
 java.lang.String obtainAtt(ConfigTree p_oP, java.lang.String p_sAtt, java.lang.String p_sDefault)
          Find an attribute in the tree (arg 0) or assign default value (arg 2)
 void register(ConfigTree config, EPR epr)
          Register an EPR in the registry.
 void register(java.lang.String name, EPR address)
          Deprecated. use register (ConfigTree config, EPR address) instead.
 void requestEnd()
           
 void run()
          Main execution loop

Will continue to run until either

a) run time is expired

b) quiesce command is received in command queue

For every child element that contains a PARM_LISTENER_CLASS attribute, this method will try to launch a child thread instantiating an object of that class, and will call it's run() method

Once all child processes are trigered, the main thread will either

1) wait for a message in the command queue (if one was configured) until next reload or end of run period expired

or 2) Just sleep if there's no command queue to listen on

static void setDefaultCommandQueue(org.jboss.internal.soa.esb.command.CommandQueue defaultCommandQueue)
          Allows a default command queue to be set statically for all GatewayListener instances.
 boolean timeToReload()
          Provide a common accessor to determine if parameters have to be reloaded

For child threads this means thread execution has to end

 void unRegister(java.lang.String name)
          Deprecated. use unRegister (String serviceCategoryName, String serviceName, EPR epr) instead.
 void unRegister(java.lang.String serviceCategoryName, java.lang.String serviceName, EPR epr)
          Unregister the EPR from the registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RELOAD_SECONDS_TAG

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

END_TIME_TAG

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

GATEWAY_CLASS_TAG

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

_defaultReloadMillis

protected int _defaultReloadMillis

_dateFormat

public static final java.text.SimpleDateFormat _dateFormat
Constructor Detail

GatewayListenerController

protected GatewayListenerController()
Package private default constructor.


GatewayListenerController

public GatewayListenerController(java.lang.String p_sParameterName)
                          throws java.lang.Exception
Construct a Listener Manager from the named repository based configuration.

Parameters:
p_sParameterName - Name of the Repository entry containing the configuration.
Throws:
java.lang.Exception - Unable to load/use the named configuration.

GatewayListenerController

public GatewayListenerController(ConfigTree config)
                          throws java.lang.Exception
Construct a Listener Manager using the specified listener configuration.

Parameters:
config - The configuration.
Throws:
java.lang.Exception - Unable to load/use the supplied configuration.
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

getControllerAttributes

public java.util.Map<java.lang.String,java.lang.Object> getControllerAttributes()
Obtain a shallow copy of needed atributes in this object's last loaded parameter tree

The local bject is cloned so child threads can use it as they choose to without interfering with the environment

Listener processes controlled by this object should keep a reference to this object at construction time, and not call this method again unless they specifically need updated values. Parameter reload could have happened since last call

Returns:
Map - a shallow copy of the attributes Map

getState

public GatewayListenerController.State getState()

checkParms

public void checkParms(ConfigTree p_oP)
                throws java.lang.Exception
Check to see if all needed parameters are there, and assign default values to some of them

Parameters:
p_oP - ConfigTree - Where to look for the mandatory/optional configuration attributes
Throws:
java.lang.Exception - - If attributes are wrong or not enough for a proper runtime configuration

setDefaultCommandQueue

public static void setDefaultCommandQueue(org.jboss.internal.soa.esb.command.CommandQueue defaultCommandQueue)
Allows a default command queue to be set statically for all GatewayListener instances.

Parameters:
defaultCommandQueue - The defaultCommandQueue to set.

run

public void run()
Main execution loop

Will continue to run until either

a) run time is expired

b) quiesce command is received in command queue

For every child element that contains a PARM_LISTENER_CLASS attribute, this method will try to launch a child thread instantiating an object of that class, and will call it's run() method

Once all child processes are trigered, the main thread will either

1) wait for a message in the command queue (if one was configured) until next reload or end of run period expired

or 2) Just sleep if there's no command queue to listen on

Specified by:
run in interface java.lang.Runnable

endRequested

public boolean endRequested()
Accessor to determine if execution time is expired or shutdown requested

Returns:
boolean if processing has to stop (all child threads will be allowed to finish)

requestEnd

public void requestEnd()

endNotRequested

public boolean endNotRequested()
Accessor to determine if execution time is not expired, and no shutdown request received

Returns:
boolean - true if run time has not expired and quiesce has not been requested

timeToReload

public boolean timeToReload()
Provide a common accessor to determine if parameters have to be reloaded

For child threads this means thread execution has to end

Child processes should only call this method when they are idle (as opposed to in the middle of executing a unit of work)

Returns:
boolean - true if it's time to reload parameters

continueLooping

public boolean continueLooping()
Helper accessor for child processes that provides info to determine if they can continue with yet another execution cycle

Returns:
boolean - true if runtime is not expired and not time yet to reload parameters

obtainAtt

public java.lang.String obtainAtt(ConfigTree p_oP,
                                  java.lang.String p_sAtt,
                                  java.lang.String p_sDefault)
                           throws ConfigurationException
Find an attribute in the tree (arg 0) or assign default value (arg 2)

Parameters:
p_oP - ConfigTree - look for attributes in this Element only
p_sAtt - String - Name of attribute to find
p_sDefault - String -default value if requested attribute is not there
Returns:
String - value of attribute, or default value (if null)
Throws:
java.lang.Exception - - If requested attribute not found and no default value supplied by invoker
ConfigurationException

getEprs

public java.util.Collection<EPR> getEprs(java.lang.String category,
                                         java.lang.String name)
                                  throws RegistryException
Throws:
RegistryException

register

public void register(java.lang.String name,
                     EPR address)
Deprecated. use register (ConfigTree config, EPR address) instead.

Parameters:
name -
address -

unRegister

public void unRegister(java.lang.String name)
Deprecated. use unRegister (String serviceCategoryName, String serviceName, EPR epr) instead.

Parameters:
name -

register

public void register(ConfigTree config,
                     EPR epr)
              throws RegistryException
Register an EPR in the registry.

Parameters:
config - - a config tree containing the deployment-configuration of the service.
epr - - the epr (EndPoint Reference) of the service.
Throws:
RegistryException

unRegister

public void unRegister(java.lang.String serviceCategoryName,
                       java.lang.String serviceName,
                       EPR epr)
                throws RegistryException
Unregister the EPR from the registry.

Parameters:
serviceCategoryName - - name of the category of the service ('Content Based Routing')
serviceName - - name of the service ("
epr -
Throws:
RegistryException