|
Boeing Simulation 3.1 API Specification | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--objects.WhatWhere
|
+--objects.MovableWhatWhere
|
+--worldsimulator.SocketSimulatorComponentTemplate
Base class for all Socket-based components that
will interact with the ComponentizedSimulator. This class
is based on the template method pattern. This class will use
sockets to accept incoming connections.
Subclasses will in addition to behavior define the types of objects that can connect to it. Allowing for incoming connections allows for other components to gain control over this component's actions.
SocketComponentTemplate,
Serialized Form| Field Summary | |
private connect.CreatesConnection |
connection
The object that allows other components to connect to it in an opaque manner. |
private Set |
connections
A set containing all the ChannelBundle objects that are
currently connected to this component. |
private static int |
currentPort
The current port that the most recently constructed SocketSimulatorComponentTemplate object was constructed by using the default constructor. |
private static boolean |
debug
Flag for outputting debug messages. |
private static int |
DEFAULT_PORT
The port that SocketSimulatorComponentTemplate>/tt> objects will first attempt to initialize if the construct without a port assignment is called. |
private connect.ComponentEmissary |
representative
The emissary used to represent this component when forming remote connections |
private static long |
serialVersionUID
|
protected connect.ChannelBundle |
simulatorConnection
The channels over which this UCAV will communicate with
the Simulator. |
protected util.ConsumerQueue |
simulatorQueue
The multithreaded queue for reading in objects from the server. |
private ServerSocket |
ss
The ServerSocket used to receive incoming connections. |
private boolean |
started
Flag for testing whether this object has started its periodic run calls. |
private util.Ceaseable |
worker
The periodic thread responsible for calling the run method. |
| Fields inherited from class objects.WhatWhere |
dim, loc |
| Constructor Summary | |
SocketSimulatorComponentTemplate(objects.Location loc,
objects.Dimension d,
connect.CreatesConnection toSimulator)
Constructs this Component on the first available port. |
|
SocketSimulatorComponentTemplate(objects.Location loc,
objects.Dimension d,
connect.CreatesConnection toSimulator,
int listeningPort)
Constructs the Component and connects it to the server. |
|
| Method Summary | |
protected abstract boolean |
accept(Class requestingType)
Returns whether this component will accept a connection from the the requesting object of the speicifed type. |
protected abstract boolean |
allowMethod(util.MethodRequest request)
Returns true if this object accepts the method being invoked upon itself. |
void |
connect(connect.CreatesConnection cc)
Attempts to form a connection between this Component to the component reached by this ComponentEmissary. |
protected static void |
debug(String s)
Emits a message if the debug flag is enabled. |
abstract boolean |
equals(Object other)
Extending classes should define behavior that would ensure equality across a network. |
protected connect.ComponentEmissary |
getComponentEmissary()
Returns the ComponentEmissary that represents this object. |
connect.CreatesConnection |
getConnection()
Returns the CreatesConnection that connects to this component. |
private static int |
getNextAvailablePort()
Returns the first available port to construct a ServerSocket. |
objects.WhatWhere |
getObject()
Returns an instance of this object. |
protected Runnable |
getOverrunLogic()
Returns the overrun logic should the time of execution of the SimulatorObject exceed the specified period. |
protected abstract long |
getStepCost()
Returns the time interval in milliseconds in which the step function may be called and return. |
protected abstract long |
getUpdatePeriod()
Returns the time in milliseconds between subsequent calls of the periodic step function. |
abstract int |
hashCode()
Extending classes should define behavior that would ensure equality across a network. |
boolean |
isStarted()
Returns whether the object has begun periodic movements. |
protected abstract void |
processIncomingConnection(Class hostType,
connect.ChannelBundle acceptedConnection)
Handles the bevahior of this component when another component initiates the connection to this component. |
protected abstract void |
processOutgoingConnection(Class hostType,
connect.ChannelBundle acceptedConnection)
Handles the bevahior of this component when it initiates a connection to a remote component |
private void |
readObject(ObjectInputStream in)
Reads in the object using the default serailization methods and then sets the started flag to false. |
void |
run()
Calls the periodic step function. |
private void |
startListeningThread()
Receives incoming connection requests, tests for admission acceptance and then passes the ChannelBundle
and Class to the subclass for
additional processing. |
void |
startPeriodicMovements()
Starts the WorkerThread that moves this UCAV, and begins processing MethodRequest
objects sent to this component from the ComponentizedSimulator. |
private void |
startSimulatorRequestThread()
This method handles MethodRequest objects that are sent to this
object from the ComponentizedSimulator. |
abstract void |
step()
Extending classes should define a unit step behavior that will be periodically called. |
protected void |
stopPeriodicRun()
Finishes processing the current call of run, and then exits the periodic thread. |
| Methods inherited from class objects.MovableWhatWhere |
setLoc, setLoc |
| Methods inherited from class objects.WhatWhere |
bound, getCenter, getDimensions, getDistance, getHeight, getLoc, getWidth, isEastOf, isNorthOf, isSouthOf, isWestOf, overlaps |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface objects.Locatable |
getDistance, getLoc, isEastOf, isNorthOf, isSouthOf, isWestOf |
| Field Detail |
private static final long serialVersionUID
protected transient connect.ChannelBundle simulatorConnection
UCAV will communicate with
the Simulator.
protected transient util.ConsumerQueue simulatorQueue
private boolean started
private transient util.Ceaseable worker
RealtimeThread,
WorkerThreadprivate transient ServerSocket ss
private final transient Set connections
ChannelBundle objects that are
currently connected to this component.
private connect.CreatesConnection connection
private connect.ComponentEmissary representative
private static final int DEFAULT_PORT
private static int currentPort
private static boolean debug
| Constructor Detail |
public SocketSimulatorComponentTemplate(objects.Location loc,
objects.Dimension d,
connect.CreatesConnection toSimulator,
int listeningPort)
ServerSocket, then this component
will continue its operation but will not listen for incoming
connections.
listeningPort - the port that this socket-based
Component use to receiving
incoming connections
public SocketSimulatorComponentTemplate(objects.Location loc,
objects.Dimension d,
connect.CreatesConnection toSimulator)
| Method Detail |
protected abstract boolean accept(Class requestingType)
protected abstract boolean allowMethod(util.MethodRequest request)
public void connect(connect.CreatesConnection cc)
connect in interface ComponentSocketComponentTemplate.allowMethod(util.MethodRequest)protected static void debug(String s)
public abstract boolean equals(Object other)
equals in class Objectprotected connect.ComponentEmissary getComponentEmissary()
public connect.CreatesConnection getConnection()
getConnection in interface Componentprivate static int getNextAvailablePort()
ServerSocket.
public final objects.WhatWhere getObject()
protected Runnable getOverrunLogic()
RealtimeThreadprotected abstract long getStepCost()
step()protected abstract long getUpdatePeriod()
step()public abstract int hashCode()
hashCode in class Objectpublic boolean isStarted()
protected abstract void processOutgoingConnection(Class hostType,
connect.ChannelBundle acceptedConnection)
connect(connect.CreatesConnection)
protected abstract void processIncomingConnection(Class hostType,
connect.ChannelBundle acceptedConnection)
connect(connect.CreatesConnection)public final void run()
run in interface Runnablestep()private void startListeningThread()
ChannelBundle
and Class to the subclass for
additional processing.
public final void startPeriodicMovements()
WorkerThread that moves this UCAV, and begins processing MethodRequest
objects sent to this component from the ComponentizedSimulator.
private void startSimulatorRequestThread()
MethodRequest objects that are sent to this
object from the ComponentizedSimulator.
public abstract void step()
run()protected final void stopPeriodicRun()
private final void readObject(ObjectInputStream in)
throws IOException,
ClassNotFoundException
IOException
ClassNotFoundExceptionstarted,
isStarted()
|
Boeing Simulation 3.1 API Specification | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||