copyright The Portico Project 2008.

org.portico.lrc.handlers
Class REQ_SubscribeInteractionHandler

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

public class REQ_SubscribeInteractionHandler
extends LRCMessageHandler

This handler manages interaction subscribe/unsubscribe requests. It will make all the appropriate checks before sending the request on to the RTI, and it will store the relevant information once it has been returned from the RTI.

Before *ANY* request is processed, the processMessage() method will check to make sure the federate is an execution member and that a save or restore is not currently in progress.


Field Summary
 
Fields inherited from class org.portico.lrc.handlers.LRCMessageHandler
interests, logger, lrc, regions, repository, state
 
Fields inherited from class com.lbf.commons.messaging.AbstractMessageHandler
augmentable, name
 
Constructor Summary
REQ_SubscribeInteractionHandler()
           
 
Method Summary
 void processMessage(com.lbf.commons.messaging.MessageContext context)
          Processes an incoming message and depending on the type, delegates it to the appropriate private handling method.
private  void subscribe(com.lbf.commons.messaging.MessageContext context)
          Attempt to inform the RTI that the federate wishes to subscribe to the given interaction class.
private  void unsubscribe(com.lbf.commons.messaging.MessageContext context)
          Attempt to inform the RTI that the federate wishes to no longer subscribe the given interaction class.
private  ICMetadata validate(int classHandle)
          This method will verify that the interaction class exists in the FOM.
private  RegionInstance validateDDM(ICMetadata metadata, int regionToken)
          This method will validate the DDM portion of a request.
private  void validateSubscribed(int classHandle)
          This method validates that the given interaction class is subscribed by this federate
 
Methods inherited from class org.portico.lrc.handlers.LRCMessageHandler
error, error, getConnection, getFOM, initialize, 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
 

Constructor Detail

REQ_SubscribeInteractionHandler

public REQ_SubscribeInteractionHandler()
Method Detail

processMessage

public void processMessage(com.lbf.commons.messaging.MessageContext context)
                    throws Exception
Processes an incoming message and depending on the type, delegates it to the appropriate private handling method.

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

subscribe

private void subscribe(com.lbf.commons.messaging.MessageContext context)
                throws Exception
Attempt to inform the RTI that the federate wishes to subscribe to the given interaction class. Once the interaction handle has been validated (to make sure it exists in the FOM), the request is sent to the RTI. It a success response is received, the subscription interest is recorded in the LRCInterestManager.

Throws:
Exception

unsubscribe

private void unsubscribe(com.lbf.commons.messaging.MessageContext context)
                  throws Exception
Attempt to inform the RTI that the federate wishes to no longer subscribe the given interaction class. Once the interaction handle has been validated (to make sure it exists in the FOM), and the method has ensured that the interaction class is currently being subscribed to by the federate, the request is sent to the RTI. It a success response is received, the subscription interest is removed from the LRCInterestManager.

Throws:
Exception

validate

private ICMetadata validate(int classHandle)
                     throws JInteractionClassNotDefined,
                            JRTIinternalError
This method will verify that the interaction class exists in the FOM. If this method does find the class, it will return the ICMetadata instance associated with it.

Returns:
The ICMetadata associated with the class handle
Throws:
JInteractionClassNotDefined - If the classHandle doesn't represent a class in the FOM
JRTIinternalError - If there is a problem locating the FOM

validateSubscribed

private void validateSubscribed(int classHandle)
                         throws JInteractionClassNotSubscribed
This method validates that the given interaction class is subscribed by this federate

Throws:
JObjectClassNotPublished - If the object class is not currently published
JInteractionClassNotSubscribed

validateDDM

private RegionInstance validateDDM(ICMetadata metadata,
                                   int regionToken)
                            throws JRegionNotKnown,
                                   JInvalidRegionContext
This method will validate the DDM portion of a request. You can safely call this method, even if you are not sure if DDM is being used or not. If the given region handle is the default value, this method will take no action and make no checks (returning right away). If DDM is being used, it will check to make sure that the region exists (that we know of it) and that it is valid for the identified interaction class. If all is acceptable, this method will return the RegionInstance identified by the token.

Parameters:
metadata - The FOM information about the interaction
regionToken - The token identifiying the region
Throws:
JRegionNotKnown
JInvalidRegionContext

copyright The Portico Project 2008.