org.commonreality.participant.impl
Class AbstractParticipant

java.lang.Object
  extended by org.commonreality.participant.impl.AbstractParticipant
All Implemented Interfaces:
java.io.Serializable, IIdentifiable, IParticipant
Direct Known Subclasses:
AbstractAgent, AbstractSensor, DefaultReality

public abstract class AbstractParticipant
extends java.lang.Object
implements IParticipant

Skeleton participant that handles the majority of tasks. A participants life cycle works like this: Sometime after instantiation, connect will be called which will establish the connection to CommonReality. When common reality is ready to start, it will signal that all sensors and agents should initialize. afetr initializing, start will be signaled. suspend and resume may be called while running The simulation will run for some amount of time, until stop will be called. then either reset or shutdown may be called. shutdown should then disconnect.

Author:
developer
See Also:
Serialized Form

Constructor Summary
AbstractParticipant(IIdentifier.Type type)
           
 
Method Summary
 void addClientService(org.commonreality.mina.transport.IMINATransportProvider transport, org.commonreality.mina.protocol.IMINAProtocolConfiguration configuration, java.net.SocketAddress address)
          specify what transport, protocol and address we can use to connect to another participant (usually, just common reality)
 void addServerService(org.commonreality.mina.transport.IMINATransportProvider transport, org.commonreality.mina.protocol.IMINAProtocolConfiguration configuration, java.net.SocketAddress address)
          specify what transport, protocol and address we can accessed on
 void configure(java.util.Map<java.lang.String,java.lang.String> options)
           
 void connect()
           
 void disconnect()
           
abstract  IAddressingInformation getAddressingInformation()
           
 IAfferentObjectManager getAfferentObjectManager()
           
 IAgentObjectManager getAgentObjectManager()
           
 IClock getClock()
          return the clock that this participant has access to
abstract  ICredentials getCredentials()
           
 IEfferentCommandManager getEfferentCommandManager()
           
 IEfferentObjectManager getEfferentObjectManager()
           
 IIdentifier getIdentifier()
          we don't have a valid identifier until we have connected to reality
abstract  java.lang.String getName()
           
 IRealObjectManager getRealObjectManager()
           
 ISensorObjectManager getSensorObjectManager()
           
 void initialize()
          called in response to a command from Reality to get everything ready to run.
 boolean isConnected()
           
 boolean isInitialized()
           
 boolean isStarted()
           
 boolean isSuspended()
           
 void reset(boolean clockWillBeReset)
          called when we are to reset to a post-initialize state.
 void resume()
           
 java.util.concurrent.Future<IAcknowledgement> send(IMessage message)
          send a message to common reality.
 void setIdentifier(IIdentifier identifier)
          called after the connection has been established..
 void shutdown()
           
 void start()
          called to actually start this participant
 void stop()
          called when this participant needs to stop
 void suspend()
           
 void waitForConnection()
           
 void waitForInitialization()
           
 void waitForResumption()
           
 void waitForStart()
           
 void waitForStop()
           
 void waitForSuspension()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractParticipant

public AbstractParticipant(IIdentifier.Type type)
Method Detail

getEfferentCommandManager

public IEfferentCommandManager getEfferentCommandManager()
Specified by:
getEfferentCommandManager in interface IParticipant
Returns:

getRealObjectManager

public IRealObjectManager getRealObjectManager()
Specified by:
getRealObjectManager in interface IParticipant

getAddressingInformation

public abstract IAddressingInformation getAddressingInformation()

getCredentials

public abstract ICredentials getCredentials()

getName

public abstract java.lang.String getName()

addServerService

public void addServerService(org.commonreality.mina.transport.IMINATransportProvider transport,
                             org.commonreality.mina.protocol.IMINAProtocolConfiguration configuration,
                             java.net.SocketAddress address)
specify what transport, protocol and address we can accessed on

Parameters:
service -
address -

addClientService

public void addClientService(org.commonreality.mina.transport.IMINATransportProvider transport,
                             org.commonreality.mina.protocol.IMINAProtocolConfiguration configuration,
                             java.net.SocketAddress address)
specify what transport, protocol and address we can use to connect to another participant (usually, just common reality)

Parameters:
service -
address -

setIdentifier

public void setIdentifier(IIdentifier identifier)
called after the connection has been established..

Parameters:
identifier -

getIdentifier

public IIdentifier getIdentifier()
we don't have a valid identifier until we have connected to reality

Specified by:
getIdentifier in interface IIdentifiable
Returns:
identifier
See Also:
IIdentifiable.getIdentifier()

isInitialized

public final boolean isInitialized()
Specified by:
isInitialized in interface IParticipant

waitForInitialization

public final void waitForInitialization()
                                 throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

isStarted

public final boolean isStarted()
Specified by:
isStarted in interface IParticipant

waitForStart

public final void waitForStart()
                        throws java.lang.InterruptedException
Specified by:
waitForStart in interface IParticipant
Throws:
java.lang.InterruptedException

waitForStop

public final void waitForStop()
                       throws java.lang.InterruptedException
Specified by:
waitForStop in interface IParticipant
Throws:
java.lang.InterruptedException

isSuspended

public final boolean isSuspended()
Specified by:
isSuspended in interface IParticipant

waitForSuspension

public final void waitForSuspension()
                             throws java.lang.InterruptedException
Specified by:
waitForSuspension in interface IParticipant
Throws:
java.lang.InterruptedException

waitForResumption

public final void waitForResumption()
                             throws java.lang.InterruptedException
Specified by:
waitForResumption in interface IParticipant
Throws:
java.lang.InterruptedException

isConnected

public final boolean isConnected()
Specified by:
isConnected in interface IParticipant

waitForConnection

public final void waitForConnection()
                             throws java.lang.InterruptedException
Specified by:
waitForConnection in interface IParticipant
Throws:
java.lang.InterruptedException

configure

public void configure(java.util.Map<java.lang.String,java.lang.String> options)
               throws java.lang.Exception
Specified by:
configure in interface IParticipant
Throws:
java.lang.Exception

initialize

public void initialize()
                throws java.lang.Exception
called in response to a command from Reality to get everything ready to run.

Specified by:
initialize in interface IParticipant
Throws:
java.lang.Exception

start

public void start()
           throws java.lang.Exception
called to actually start this participant

Specified by:
start in interface IParticipant
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
called when this participant needs to stop

Specified by:
stop in interface IParticipant
Throws:
java.lang.Exception

suspend

public void suspend()
             throws java.lang.Exception
Specified by:
suspend in interface IParticipant
Throws:
java.lang.Exception

resume

public void resume()
            throws java.lang.Exception
Specified by:
resume in interface IParticipant
Throws:
java.lang.Exception

reset

public void reset(boolean clockWillBeReset)
           throws java.lang.Exception
called when we are to reset to a post-initialize state. this impl attempts to reset the clock if it is INetworked or ISettabl

Specified by:
reset in interface IParticipant
Throws:
java.lang.Exception

shutdown

public void shutdown()
              throws java.lang.Exception
Specified by:
shutdown in interface IParticipant
Throws:
java.lang.Exception

connect

public void connect()
             throws java.lang.Exception
Specified by:
connect in interface IParticipant
Throws:
java.lang.Exception
See Also:
IParticipant.connect()

disconnect

public void disconnect()
                throws java.lang.Exception
Specified by:
disconnect in interface IParticipant
Throws:
java.lang.Exception

getClock

public IClock getClock()
return the clock that this participant has access to

Specified by:
getClock in interface IParticipant
Returns:

send

public java.util.concurrent.Future<IAcknowledgement> send(IMessage message)
send a message to common reality. We also cache any data requests going out and store them temporarily. they will not be applied to the respective object manager until we get confirmation from CR

Specified by:
send in interface IParticipant
Parameters:
message -
Returns:

getSensorObjectManager

public ISensorObjectManager getSensorObjectManager()
Specified by:
getSensorObjectManager in interface IParticipant

getAfferentObjectManager

public IAfferentObjectManager getAfferentObjectManager()
Specified by:
getAfferentObjectManager in interface IParticipant

getEfferentObjectManager

public IEfferentObjectManager getEfferentObjectManager()
Specified by:
getEfferentObjectManager in interface IParticipant

getAgentObjectManager

public IAgentObjectManager getAgentObjectManager()
Specified by:
getAgentObjectManager in interface IParticipant