copyright The Portico Project 2008.

org.portico.lrc.handlers
Class REQ_PublishObjectHandler

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

public class REQ_PublishObjectHandler
extends LRCMessageHandler

This handler manages object attribute publish/unpublish 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_PublishObjectHandler()
           
 
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 publish(com.lbf.commons.messaging.MessageContext context)
          Validates an object class publication request.
private  void unpublish(com.lbf.commons.messaging.MessageContext context)
          This method handles requests to stop publishing a specific object class.
private  void unpublishImplicit(com.lbf.commons.messaging.MessageContext context, int classHandle, String targetFederate)
          This method converts what was an object class publication request with 0-attributes into an object class unpublication request.
private  void validate(int classHandle, Set<Integer> attributes)
          This method will verify that the object class exists in the FOM, and that each of the attribute handles represents an attribute that exists for the object class.
private  void validatePublished(int classHandle)
          This method validates that the given object class is published 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_PublishObjectHandler

public REQ_PublishObjectHandler()
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

publish

private void publish(com.lbf.commons.messaging.MessageContext context)
              throws Exception
Validates an object class publication request. It will ensure that all the requested attribute handles (and the object class handle) exist in the FOM before allowing the request through. If the set of attributes to publish is empty, it is taken to be an implicit "unpublish" request and #unsubscribeOCImplicit(MessageContext, int, String) is called. As required by the spec, the privilegeToDelete attribute handle is added to any non-empty set (and thus it is implicitly published).

Following all this, it will send the publication request on to the RTI and if it is successful, it will record the information in the LRCInterestManager

Throws:
Exception

unpublishImplicit

private void unpublishImplicit(com.lbf.commons.messaging.MessageContext context,
                               int classHandle,
                               String targetFederate)
                        throws Exception
This method converts what was an object class publication request with 0-attributes into an object class unpublication request. It then passes that request on to the #unpublishOC(MessageContext) method.

Throws:
Exception

unpublish

private void unpublish(com.lbf.commons.messaging.MessageContext context)
                throws Exception
This method handles requests to stop publishing a specific object class. It will first validate that the class handle exists in the FOM and that the federate is publishing it. It will then send the request on to the RTI and if it is successful it will remove the publication record from the LRCInterestManager.

Some unpublication requests can specify the attribute they wish to unpublish. If that is the case with the handled request, this method will also first validate that each of the attribute handles exists in the FOM before sending the request to the RTI.

Throws:
Exception

validate

private void validate(int classHandle,
                      Set<Integer> attributes)
               throws JObjectClassNotDefined,
                      JAttributeNotDefined,
                      JRTIinternalError
This method will verify that the object class exists in the FOM, and that each of the attribute handles represents an attribute that exists for the object class.

Throws:
JObjectClassNotDefined - If the classHandle doesn't represent a class in the FOM
JAttributeNotDefined - If an attribute handle doesn't represent an attribute in the defined object class
JRTIinternalError - If there is a problem locating the FOM

validatePublished

private void validatePublished(int classHandle)
                        throws JObjectClassNotPublished
This method validates that the given object class is published by this federate

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

copyright The Portico Project 2008.