copyright The Portico Project 2008.

org.portico.core
Class RTIConnection

java.lang.Object
  extended by org.portico.core.RTIConnection
Direct Known Subclasses:
JSOPActiveConnection.JSOPServerConnection, JVMServerConnection, MomConnection

public abstract class RTIConnection
extends Object

As discussed in the documentation on the wiki, the entire communications sub-system is abstracted from the rest of the RTI. The RTIConnection class is something of the facade that enables this. Communications-binding specific implementations should extends this class, providing implementations of the abstract methods. The other methods generally exist for convenience in the subclasses or for use by the RTI. You shouldn't need to override them, although you can if you wish.


Field Summary
private  com.lbf.commons.messaging.IMessageHandler requestHandler
           
protected  RTIExec rti
           
 
Constructor Summary
RTIConnection()
           
 
Method Summary
abstract  void close(String reason)
          This method should close the connection to the client.
 RTIExec getRtiExecution()
          Fetches the RTIExec that has been associated with this connection.
 boolean harvestConnection()
          This method will ask the Reaper to harvest it.
 void receiveRequest(com.lbf.commons.messaging.MessageContext context)
          This is the method to which all incoming requests from the LRC should be passed when they are received by the implemention-specific subclasses of RTIConnection.
abstract  void sendCallback(com.lbf.commons.messaging.MessageContext context)
          This method should be implemented by all subclasses in a manner specific to the communication mechanism that is in use.
 void setRequestHandler(com.lbf.commons.messaging.IMessageHandler handler)
          This is called automatically by the framework when the connection is attached to a federate.
 void setRtiExecution(RTIExec rti)
          Like setRequestHandler(IMessageHandler), this method is called automatically by the framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestHandler

private com.lbf.commons.messaging.IMessageHandler requestHandler

rti

protected RTIExec rti
Constructor Detail

RTIConnection

public RTIConnection()
Method Detail

receiveRequest

public void receiveRequest(com.lbf.commons.messaging.MessageContext context)
This is the method to which all incoming requests from the LRC should be passed when they are received by the implemention-specific subclasses of RTIConnection. If you are implementing a connection, pass any messages you receive to this method.

This method will take the given message and pass it to the request handler associated with this connection. You don't need to set that handler, it will be done automatically by the RTIExec when a federate joins a federation. Once the call is over, the appropriate response should be in the context. If an exception occurs, it is wrapped in an exception response message and placed into the context.


setRequestHandler

public void setRequestHandler(com.lbf.commons.messaging.IMessageHandler handler)
This is called automatically by the framework when the connection is attached to a federate. It provides the message handler that this connection should send incoming messages to. If you are implementing a subclass, you should not refernce this handler directly, rather, you should call the receiveRequest(MessageContext) to pass it messages when they are received.


setRtiExecution

public void setRtiExecution(RTIExec rti)
Like setRequestHandler(IMessageHandler), this method is called automatically by the framework. This is currently done in the FedexFactory, as a federate is created.


getRtiExecution

public RTIExec getRtiExecution()
Fetches the RTIExec that has been associated with this connection. If you call this too soon, it may be null. If should be set in the FedexFactory when the federate is being created.


harvestConnection

public boolean harvestConnection()
This method will ask the Reaper to harvest it. That is, if the connection is associated with a currently active federate, the federate will be forcefully resigned and removed. See the Reaper for more information.


sendCallback

public abstract void sendCallback(com.lbf.commons.messaging.MessageContext context)
                           throws Exception
This method should be implemented by all subclasses in a manner specific to the communication mechanism that is in use. It will be called whenever the RTI has a message that it wants to send to the LRC on the other end of this connection.

Throws:
Exception

close

public abstract void close(String reason)
This method should close the connection to the client. If there is any cleanup that needs to be done by the implementation (perhaps the closing of a socket, etc...) then this method is where it should be done.

The parameter provides a textual description of the reason for the closing, although it *MAY BE NULL* (so make the appropriate checks before calling methods on it).

Parameters:
reason - Textual description of why the connection is being closed. Note that this may be null, so be sure to check before using it

copyright The Portico Project 2008.