copyright The Portico Project 2008.

org.portico.binding.jvm
Class JVMClientConnection

java.lang.Object
  extended by org.portico.lrc.LRCConnection
      extended by org.portico.binding.jvm.JVMClientConnection

public class JVMClientConnection
extends LRCConnection

The client side connection for the JVM Binding. This class will route requests for the 3 non-federation bound requests (create,destroy and join) directly to the RTIExec (getting access to it through the JVMBootstrap. On join, it will create a new JVMServerConnection. From then on, it will route any requests to the server connections incoming message handler (which will route it to the RTI request sink).


Field Summary
protected  com.lbf.commons.messaging.IMessageHandler bootstrap
           
protected  JVMServerConnection server
           
 
Fields inherited from class org.portico.lrc.LRCConnection
logger, lrc
 
Constructor Summary
JVMClientConnection()
           
 
Method Summary
private  void bootstrapCreate(com.lbf.commons.messaging.MessageContext context)
          Passes the create-federation reqeust directly onto the RTI.
private  void bootstrapDestroy(com.lbf.commons.messaging.MessageContext context)
          Passes the destroy-federation reqeust directly onto the RTI.
private  void bootstrapJoin(com.lbf.commons.messaging.MessageContext context)
          Pass the join request directly to the RTI execution.
 void close()
          Doesn't do anything in the JVM connection
 void configure(com.lbf.commons.utils.Bag<String,?> properties)
          When this method is executed, it will attempt to gain a reference to the JVMBootstrap, through which it can gain access to the RTI.
private  void fireMessage(com.lbf.commons.messaging.MessageContext context)
          This method passes the given request directly to the RTI for processing.
 void sendMessage(com.lbf.commons.messaging.MessageContext context)
          Sends the given message to the RTI.
 void startup()
          Doesn't do anything in the JVM connection
 
Methods inherited from class org.portico.lrc.LRCConnection
receiveCallback, receiveCallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected JVMServerConnection server

bootstrap

protected com.lbf.commons.messaging.IMessageHandler bootstrap
Constructor Detail

JVMClientConnection

public JVMClientConnection()
Method Detail

configure

public void configure(com.lbf.commons.utils.Bag<String,?> properties)
               throws com.lbf.commons.config.ConfigurationException
When this method is executed, it will attempt to gain a reference to the JVMBootstrap, through which it can gain access to the RTI. It will check the static JVMBootstrap.INSTANCE for this reference. If it is null, it means that there is no active RTI (that contains the JVM bootstrap). As such, it tries to start an RTI first. Once the RTI has been started, the JVMBootstrap.INSTANCE variable should have been populated and the reference is now taken and stored.

Overrides:
configure in class LRCConnection
Throws:
com.lbf.commons.config.ConfigurationException

startup

public void startup()
Doesn't do anything in the JVM connection

Specified by:
startup in class LRCConnection

close

public void close()
Doesn't do anything in the JVM connection

Specified by:
close in class LRCConnection

sendMessage

public void sendMessage(com.lbf.commons.messaging.MessageContext context)
                 throws Exception
Sends the given message to the RTI. If the request is a create,join or destroy message, it is sent to the bootstrap handler (see Bootstrap.getBootstrapHandler()).

If the request is a resign request, it sends the message to the associated federation and then does some local cleanup if the result is a success.

If the request is any other type of message, it just attempts to fire it straight to the federation using the fireMessage(MessageContext) method.

Specified by:
sendMessage in class LRCConnection
Throws:
Exception

fireMessage

private void fireMessage(com.lbf.commons.messaging.MessageContext context)
This method passes the given request directly to the RTI for processing. If there is no reference to the federation (as will be the case before the federate has joined), an exception is packaged into the context and processing ends. If an exception occurs during processing, it is packaged as an error response in the context and the method will return.


bootstrapCreate

private void bootstrapCreate(com.lbf.commons.messaging.MessageContext context)
Passes the create-federation reqeust directly onto the RTI. There should always be a reference to the RTI, if one could not be obtained, the connection would have never been successfully started.


bootstrapDestroy

private void bootstrapDestroy(com.lbf.commons.messaging.MessageContext context)
Passes the destroy-federation reqeust directly onto the RTI. There should always be a reference to the RTI, if one could not be obtained, the connection would have never been successfully started.


bootstrapJoin

private void bootstrapJoin(com.lbf.commons.messaging.MessageContext context)
Pass the join request directly to the RTI execution. It first creates an instance of the JVMServerConnection class, connecting it to this JVMClientConnection. That connection is then passed as part of the join request and is stored in the RTI so that the federate can be contacted for callbacks.

If the join request is successful, the server connection is stored locally. Through it, a reference to the federation can be obtained so that requests can be passed on. If the join is not successful, the reference isn't stored and no link is made.


copyright The Portico Project 2008.