copyright The Portico Project 2008.

org.portico.impl.hla1516.handlers
Class CLB_CallbackHandler

java.lang.Object
  extended by com.lbf.commons.messaging.AbstractMessageHandler
      extended by org.portico.lrc.handlers.LRCMessageHandler
          extended by org.portico.impl.hla1516.handlers.CLB_CallbackHandler
All Implemented Interfaces:
com.lbf.commons.messaging.IMessageHandler

public class CLB_CallbackHandler
extends LRCMessageHandler

This class is an "all-in-one" callback message handler. Using delegates it takes care of a number of federate ambassador callbacks in a single class. It requires additional XML configuration as follows:

Example:

 <handler name="CLB_CallbackHandler"
          class="org.portico.impl.hla13.handlers.CLB_CallbackHandler">
                <message id="FED_AdvanceGranted"/>
                <message id="FED_ConstrainedEnabled"/>
                <message id="FED_RegulationEnabled"/>
                <configuration>
                        <link id="FED_AdvanceGranted" method="timeAdvanceGranted"/>
                        <link id="FED_ConstrainedEnabled" method="constrainedEnabled"/>
                        <link id="FED_RegulationEnabled" method="regulationEnabled"/>
                </configuration>
 </handler>
 

Remember to register a message type for each message the handler should be responsible for. Further, you must create a "link" between each message id and the name of the method within this class that should be used to handle it.

Each of the methods provided by this class that the target of delegates (the HLA-related methods such as discoverObject) just serve to extract the appropriate information from the incoming message and pass it on to the FederateAmbassador to which the handler is linked. The ambassador is accessed through the Impl1516Helper.


Field Summary
private  HashMap<String,com.lbf.commons.delegate.Delegate> delegates
           
private  Impl1516Helper helper
           
private  org.apache.log4j.Logger logger
           
 
Fields inherited from class org.portico.lrc.handlers.LRCMessageHandler
interests, lrc, regions, repository, state
 
Fields inherited from class com.lbf.commons.messaging.AbstractMessageHandler
augmentable, name
 
Constructor Summary
CLB_CallbackHandler()
           
 
Method Summary
 void constrainedEnabled(com.lbf.commons.messaging.RequestMessage request)
           
 void discoverObject(com.lbf.commons.messaging.RequestMessage request)
           
 void federationSynchronized(com.lbf.commons.messaging.RequestMessage request)
           
 void initialize(com.lbf.commons.utils.Bag<String,?> properties)
          This method will attempt to extract from the given properties the instance of the Impl1516Helper class that provides its link to the federate to which the various callbacks should be delivered.
 void processMessage(com.lbf.commons.messaging.MessageContext context)
          This method attempts to locate the appropriate Delegate for the incoming request (based off the request messages identifier) and then invoke the delegate passing the message context as the parameter.
 void provideUpdate(com.lbf.commons.messaging.RequestMessage request)
           
 void receiveInteraction(com.lbf.commons.messaging.RequestMessage request)
           
 void reflectAttributes(com.lbf.commons.messaging.RequestMessage request)
           
 void regulationEnabled(com.lbf.commons.messaging.RequestMessage request)
           
 void removeObject(com.lbf.commons.messaging.RequestMessage request)
           
 void syncPointAnnounced(com.lbf.commons.messaging.RequestMessage request)
           
 void syncPointRegResult(com.lbf.commons.messaging.RequestMessage request)
           
 void timeAdvanceGranted(com.lbf.commons.messaging.RequestMessage request)
           
 
Methods inherited from class org.portico.lrc.handlers.LRCMessageHandler
error, error, getConnection, getFOM, sendMessage, success, success, success
 
Methods inherited from class com.lbf.commons.messaging.AbstractMessageHandler
getName, isAugmentable, setAugmentable, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegates

private HashMap<String,com.lbf.commons.delegate.Delegate> delegates

helper

private Impl1516Helper helper

logger

private org.apache.log4j.Logger logger
Constructor Detail

CLB_CallbackHandler

public CLB_CallbackHandler()
Method Detail

initialize

public void initialize(com.lbf.commons.utils.Bag<String,?> properties)
                throws com.lbf.commons.config.ConfigurationException
This method will attempt to extract from the given properties the instance of the Impl1516Helper class that provides its link to the federate to which the various callbacks should be delivered. If that helper cannot be found, an exception will be thrown.

The other main function of this class is to extract from the properties the configuration information that is used to identify which messages should be processed by which methods of this class. See the class level javadoc for more information.

Specified by:
initialize in interface com.lbf.commons.messaging.IMessageHandler
Overrides:
initialize in class LRCMessageHandler
Throws:
com.lbf.commons.config.ConfigurationException

processMessage

public void processMessage(com.lbf.commons.messaging.MessageContext context)
                    throws JRTIinternalError
This method attempts to locate the appropriate Delegate for the incoming request (based off the request messages identifier) and then invoke the delegate passing the message context as the parameter. If the delegate cannot be found, or an exception is thrown while invoking it, an exception is thrown.

Specified by:
processMessage in interface com.lbf.commons.messaging.IMessageHandler
Specified by:
processMessage in class LRCMessageHandler
Throws:
JRTIinternalError

timeAdvanceGranted

public void timeAdvanceGranted(com.lbf.commons.messaging.RequestMessage request)
                        throws Exception
Throws:
Exception

constrainedEnabled

public void constrainedEnabled(com.lbf.commons.messaging.RequestMessage request)
                        throws Exception
Throws:
Exception

regulationEnabled

public void regulationEnabled(com.lbf.commons.messaging.RequestMessage request)
                       throws Exception
Throws:
Exception

syncPointRegResult

public void syncPointRegResult(com.lbf.commons.messaging.RequestMessage request)
                        throws Exception
Throws:
Exception

syncPointAnnounced

public void syncPointAnnounced(com.lbf.commons.messaging.RequestMessage request)
                        throws Exception
Throws:
Exception

federationSynchronized

public void federationSynchronized(com.lbf.commons.messaging.RequestMessage request)
                            throws Exception
Throws:
Exception

discoverObject

public void discoverObject(com.lbf.commons.messaging.RequestMessage request)
                    throws Exception
Throws:
Exception

removeObject

public void removeObject(com.lbf.commons.messaging.RequestMessage request)
                  throws Exception
Throws:
Exception

receiveInteraction

public void receiveInteraction(com.lbf.commons.messaging.RequestMessage request)
                        throws Exception
Throws:
Exception

reflectAttributes

public void reflectAttributes(com.lbf.commons.messaging.RequestMessage request)
                       throws Exception
Throws:
Exception

provideUpdate

public void provideUpdate(com.lbf.commons.messaging.RequestMessage request)
                   throws Exception
Throws:
Exception

copyright The Portico Project 2008.