public abstract class AbstractParticipant extends java.lang.Object implements IParticipant
IParticipant.State
Constructor and Description |
---|
AbstractParticipant(IIdentifier.Type type) |
Modifier and Type | Method and Description |
---|---|
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
|
protected void |
checkState(IParticipant.State... states)
checks the state to see if it matches one of these, if not, it fires an
exception
|
protected void |
clearObjectManagers() |
void |
configure(java.util.Map<java.lang.String,java.lang.String> options)
configure the participant.
|
void |
connect()
connect
|
protected IAfferentObjectManager |
createAfferentObjectManager() |
protected IAgentObjectManager |
createAgentObjectManager() |
protected IEfferentCommandManager |
createEfferentCommandManager() |
protected IEfferentObjectManager |
createEfferentObjectManager() |
protected java.util.concurrent.ExecutorService |
createIOExecutorService()
creates a single thread pool executor from Mina's orderd thread pool
executor so that we can be sure the messages do actually arrive in order.
|
protected org.apache.mina.core.service.IoHandler |
createIOHandler(IIdentifier.Type type) |
protected INotificationManager |
createNotificationManager() |
protected IRealObjectManager |
createRealObjectManager() |
protected ISensorObjectManager |
createSensorObjectManager() |
void |
disconnect()
disconnect, reverting to unknown
|
void |
disconnect(boolean force)
force the system to disconnect, regardless of its current state
|
abstract IAddressingInformation |
getAddressingInformation() |
IAfferentObjectManager |
getAfferentObjectManager() |
IAgentObjectManager |
getAgentObjectManager() |
protected GeneralThreadFactory |
getCentralThreadFactory() |
IClock |
getClock()
return the clock that this participant has access to
|
IIdentifier |
getCommonRealityIdentifier() |
abstract ICredentials |
getCredentials() |
IEfferentCommandManager |
getEfferentCommandManager() |
IEfferentObjectManager |
getEfferentObjectManager() |
IIdentifier |
getIdentifier()
we don't have a valid identifier until we have connected to reality
|
protected java.util.concurrent.Executor |
getIOExecutor() |
protected org.apache.mina.core.service.IoHandler |
getIOHandler() |
protected GeneralThreadFactory |
getIOThreadFactory() |
abstract java.lang.String |
getName() |
INotificationManager |
getNotificationManager() |
static java.util.concurrent.ScheduledExecutorService |
getPeriodicExecutor()
return a shared periodic executor that can be useful in many circumstances
for periodic events
|
IRealObjectManager |
getRealObjectManager() |
ISensorObjectManager |
getSensorObjectManager() |
protected java.util.Collection<IAddressingInformation> |
getServerAddressInformation() |
IParticipant.State |
getState()
return the current state of the participant, and, if initialized, the state
of the simulation
|
void |
initialize()
called in response to a command from Reality to get everything ready to
run.
|
void |
reset(boolean clockWillBeReset)
called when we are to reset to a post-initialize state.
|
void |
resume()
resume a suspended participant and return state to started.
|
java.util.concurrent.Future<IAcknowledgement> |
send(IMessage message)
send a message to common reality.
|
protected void |
setClock(IClock clock) |
void |
setCommonRealityIdentifier(IIdentifier crId) |
void |
setIdentifier(IIdentifier identifier)
called after the connection has been established..
|
void |
shutdown()
shutdown the participant if it is stopped and disconnect
|
void |
shutdown(boolean force)
shutdown, disconnect, without checking states
|
void |
start()
called to actually start this participant
|
boolean |
stateMatches(IParticipant.State... states) |
void |
stop()
called when this participant needs to stop
|
void |
suspend()
suspend the participant if it is started.
|
IParticipant.State |
waitForState(IParticipant.State... states)
wait until the participant's state is one of these.
|
IParticipant.State |
waitForState(long waitTime,
IParticipant.State... states) |
public AbstractParticipant(IIdentifier.Type type)
public static java.util.concurrent.ScheduledExecutorService getPeriodicExecutor()
protected ISensorObjectManager createSensorObjectManager()
protected IRealObjectManager createRealObjectManager()
protected IAgentObjectManager createAgentObjectManager()
protected IAfferentObjectManager createAfferentObjectManager()
protected IEfferentObjectManager createEfferentObjectManager()
protected IEfferentCommandManager createEfferentCommandManager()
protected INotificationManager createNotificationManager()
public INotificationManager getNotificationManager()
getNotificationManager
in interface IParticipant
public IEfferentCommandManager getEfferentCommandManager()
getEfferentCommandManager
in interface IParticipant
public IRealObjectManager getRealObjectManager()
getRealObjectManager
in interface IParticipant
public void setCommonRealityIdentifier(IIdentifier crId)
public IIdentifier getCommonRealityIdentifier()
public abstract IAddressingInformation getAddressingInformation()
public abstract ICredentials getCredentials()
public abstract java.lang.String getName()
protected GeneralThreadFactory getCentralThreadFactory()
protected GeneralThreadFactory getIOThreadFactory()
protected java.util.concurrent.ExecutorService createIOExecutorService()
protected final java.util.concurrent.Executor getIOExecutor()
public void addServerService(org.commonreality.mina.transport.IMINATransportProvider transport, org.commonreality.mina.protocol.IMINAProtocolConfiguration configuration, java.net.SocketAddress address)
service
- address
- public void addClientService(org.commonreality.mina.transport.IMINATransportProvider transport, org.commonreality.mina.protocol.IMINAProtocolConfiguration configuration, java.net.SocketAddress address)
service
- address
- public final IParticipant.State waitForState(IParticipant.State... states) throws java.lang.InterruptedException
IParticipant
waitForState
in interface IParticipant
java.lang.InterruptedException
public final IParticipant.State waitForState(long waitTime, IParticipant.State... states) throws java.lang.InterruptedException
waitForState
in interface IParticipant
java.lang.InterruptedException
public final IParticipant.State getState()
IParticipant
getState
in interface IParticipant
public boolean stateMatches(IParticipant.State... states)
stateMatches
in interface IParticipant
protected void checkState(IParticipant.State... states)
states
- public void setIdentifier(IIdentifier identifier)
identifier
- public IIdentifier getIdentifier()
getIdentifier
in interface IIdentifiable
IIdentifiable.getIdentifier()
public void configure(java.util.Map<java.lang.String,java.lang.String> options) throws java.lang.Exception
IParticipant
configure
in interface IParticipant
java.lang.Exception
public void initialize() throws java.lang.Exception
initialize
in interface IParticipant
java.lang.Exception
public void start() throws java.lang.Exception
start
in interface IParticipant
java.lang.Exception
public void stop() throws java.lang.Exception
stop
in interface IParticipant
java.lang.Exception
public void suspend() throws java.lang.Exception
IParticipant
suspend
in interface IParticipant
java.lang.Exception
public void resume() throws java.lang.Exception
IParticipant
resume
in interface IParticipant
java.lang.Exception
public void reset(boolean clockWillBeReset) throws java.lang.Exception
reset
in interface IParticipant
java.lang.Exception
public void shutdown(boolean force) throws java.lang.Exception
IParticipant
shutdown
in interface IParticipant
java.lang.Exception
public void shutdown() throws java.lang.Exception
IParticipant
shutdown
in interface IParticipant
java.lang.Exception
protected void clearObjectManagers()
public void connect() throws java.lang.Exception
IParticipant
connect
in interface IParticipant
java.lang.Exception
IParticipant.connect()
public void disconnect() throws java.lang.Exception
IParticipant
disconnect
in interface IParticipant
java.lang.Exception
public void disconnect(boolean force) throws java.lang.Exception
IParticipant
disconnect
in interface IParticipant
java.lang.Exception
protected java.util.Collection<IAddressingInformation> getServerAddressInformation()
public IClock getClock()
getClock
in interface IParticipant
protected void setClock(IClock clock)
public java.util.concurrent.Future<IAcknowledgement> send(IMessage message)
send
in interface IParticipant
message
- protected org.apache.mina.core.service.IoHandler createIOHandler(IIdentifier.Type type)
protected final org.apache.mina.core.service.IoHandler getIOHandler()
public ISensorObjectManager getSensorObjectManager()
getSensorObjectManager
in interface IParticipant
public IAfferentObjectManager getAfferentObjectManager()
getAfferentObjectManager
in interface IParticipant
public IEfferentObjectManager getEfferentObjectManager()
getEfferentObjectManager
in interface IParticipant
public IAgentObjectManager getAgentObjectManager()
getAgentObjectManager
in interface IParticipant