java.mtsb
Class State
java.lang.Object
|
+--java.mtsb.State
-
public class State
-
extends java.lang.Object
-
implements java.io.Serializable, java.lang.Runnable
-
-
Connectors are implemented following the State design pattern. Every state
of the state transition diagram (STD) of a protocol inherits form
this class. In fact, the actual state of a connector handles the events
propagated by components. It is the current state of a connector
which really handles the propagated event. Every method that handles an
event must return a state object, indicating the next state in the State
Transition Diagram.
-
When the state object processes an event, the propagation of messages to
components must be carried out in independent threads, achieving concurrency
between the handling of events (inside connectors) and the processing of
input messages (inside components).
-
See Also:
-
Serialized Form
| Method Summary |
| void |
alterContext(Connector[]
cc, Component[] c)
|
| void |
alterContext(java.lang.String[]
connectors, java.lang.String[] components)
|
| void |
broadcast(java.kernel.Message
m)
|
| void |
broadcast(java.lang.String
to, java.lang.String message, java.lang.Object[] args)
Broadcast a
message to all components according to its name. |
| void |
broadcastByType(java.lang.String
type, java.lang.String message, java.lang.Object[] args)
|
| void |
broadcastByType(java.lang.String
to, java.lang.String type, java.lang.String message, java.lang.Object[]
args)
Mechanism for
broadcasting a message to all suitable components according to its type |
| Component |
createComponent(java.lang.String
name)
|
| Component |
createComponent(java.lang.String
name, java.lang.Object[] args)
Connectors can
create both components and other connectors. |
| Connector |
createConnector(java.lang.String
name)
|
| Connector |
createConnector(java.lang.String
name, java.lang.Object[] args)
|
| java.lang.String |
getServiceParameter(java.lang.String
name)
|
| java.lang.String |
getUserName()
|
| java.mtsb.CID |
lastEventSource()
With this methods
the connector can know information about the component (cid, ident, name,
etc.) which has propagated the event. |
| int |
lastEventSourceIdent()
|
| java.lang.String |
lastEventSourceName()
|
| java.lang.String |
lastEventSourceUSP()
|
| Component |
lookfor(java.lang.String
name)
Connectors need
to know some information about components to which the messages are destined. |
| void |
migrate(java.lang.String
destinationUSP)
It is the current
state of the connector and not the connector itself which decides when
the connector must migrate. |
| void |
run()
|
| void |
sendMessage(java.mtsb.CID
to, java.lang.String message)
|
| void |
sendMessage(java.mtsb.CID
to, java.lang.String message, java.lang.Object[] args)
|
| void |
sendMessage(Component
c, java.kernel.Message m)
|
| void |
sendMessage(Component
c, java.lang.String message, java.lang.Object[] args)
|
| void |
sendMessage(java.kernel.Message
m)
|
| void |
sendMessage(java.lang.String
to, java.lang.String message)
|
| void |
sendMessage(java.lang.String
to, java.lang.String at, int ident, java.lang.String message)
|
| void |
sendMessage(java.lang.String
to, java.lang.String at, int ident, java.lang.String message, java.lang.Object[]
args)
Connectors send
messages to components via the USP and have to specify some information
to determine the component to which the message is for. |
| void |
sendMessage(java.lang.String
to, java.lang.String message, java.lang.Object[] args)
|
| void |
sendMessage(java.lang.String
to, java.lang.String at, java.lang.String message)
|
| void |
sendMessage(java.lang.String
to, java.lang.String at, java.lang.String message, java.lang.Object[] args)
|
| void |
sendMessageByType(java.kernel.Message
m)
|
| void |
sendMessageByType(java.lang.String
type, java.lang.String message, java.lang.Object[] args)
When the connector
wants to send a message to any component that belongs to a type, nor specific
component |
| void |
start()
The class State
is itself a thread, allowing that every connector of a service can be running
independently. |
| Methods inherited from class java.lang.Object |
| equals, getClass, hashCode, notify, notifyAll, toString, wait,
wait, wait |
usp
public LocalUSP usp
cid
public java.mtsb.CID cid
parent
public Connector parent
State
public State(LocalUSP usp,
Connector parent)
State
public State(LocalUSP usp)
getUserName
public java.lang.String getUserName()
getServiceParameter
public java.lang.String getServiceParameter(java.lang.String name)
migrate
public void migrate(java.lang.String destinationUSP)
-
It is the current state of the connector and not the connector itself which
decides when the connector must migrate. By this method it notifies the
connector to which it belongs to, that it must migrate
lastEventSource
public java.mtsb.CID lastEventSource()
-
With this methods the connector can know information about the component
(cid, ident, name, etc.) which has propagated the event. This class stores
in the sender variable the CID of the object component that sent the last
message to it.
lastEventSourceUSP
public java.lang.String lastEventSourceUSP()
lastEventSourceName
public java.lang.String lastEventSourceName()
lastEventSourceIdent
public int lastEventSourceIdent()
createComponent
public Component createComponent(java.lang.String name,
java.lang.Object[] args)
-
Connectors can create both components and other connectors. Different instances
of a service might not have bound the same set of components and connectors.
This set can change, depending on the user profile or state of the running
service. A connector can decide to create a component or a connector (or
not to do it, or even to decide the type) going by its actual state or
service requirements. So, when a connector, needs to create component(s)
and/or connector(s), invokes one of these methods, that forward the creation
action to the USP of the service, that will create the required object.
createComponent
public Component createComponent(java.lang.String name)
createConnector
public Connector createConnector(java.lang.String name)
createConnector
public Connector createConnector(java.lang.String name,
java.lang.Object[] args)
alterContext
public void alterContext(java.lang.String[] connectors,
java.lang.String[] components)
alterContext
public void alterContext(Connector[] cc,
Component[] c)
lookfor
public Component lookfor(java.lang.String name)
-
Connectors need to know some information about components to which the
messages are destined. Whereas components propagate events to unknown connectors,
connectors have to specify the types of components that they connect. If
they do not know a local component reference, they can ask for it
sendMessage
public void sendMessage(java.lang.String to,
java.lang.String at,
int ident,
java.lang.String message,
java.lang.Object[] args)
-
Connectors send messages to components via the USP and have to specify
some information to determine the component to which the message is for.
The amount of information determines the components that will receive the
message. This method construct the message object that is the parameter
of the USP sendMessage() method.
sendMessage
public void sendMessage(java.lang.String to,
java.lang.String at,
java.lang.String message,
java.lang.Object[] args)
sendMessage
public void sendMessage(java.mtsb.CID to,
java.lang.String message,
java.lang.Object[] args)
sendMessage
public void sendMessage(java.lang.String to,
java.lang.String message,
java.lang.Object[] args)
sendMessage
public void sendMessage(java.lang.String to,
java.lang.String at,
int ident,
java.lang.String message)
sendMessage
public void sendMessage(java.lang.String to,
java.lang.String at,
java.lang.String message)
sendMessage
public void sendMessage(java.mtsb.CID to,
java.lang.String message)
sendMessage
public void sendMessage(java.lang.String to,
java.lang.String message)
sendMessage
public void sendMessage(java.kernel.Message m)
throws java.lang.Exception
sendMessageByType
public void sendMessageByType(java.kernel.Message m)
throws java.lang.Exception
sendMessage
public void sendMessage(Component c,
java.lang.String message,
java.lang.Object[] args)
throws java.lang.Exception
sendMessage
public void sendMessage(Component c,
java.kernel.Message m)
throws java.lang.Exception
sendMessageByType
public void sendMessageByType(java.lang.String type,
java.lang.String message,
java.lang.Object[] args)
-
When the connector wants to send a message to any component that belongs
to a type, nor specific component
broadcastByType
public void broadcastByType(java.lang.String to,
java.lang.String type,
java.lang.String message,
java.lang.Object[] args)
-
Mechanism for broadcasting a message to all suitable components according
to its type
broadcastByType
public void broadcastByType(java.lang.String type,
java.lang.String message,
java.lang.Object[] args)
broadcast
public void broadcast(java.lang.String to,
java.lang.String message,
java.lang.Object[] args)
-
Broadcast a message to all components according to its name.
broadcast
public void broadcast(java.kernel.Message m)
throws java.lang.Exception
start
public void start()
-
The class State is itself a thread, allowing that every connector of a
service can be running independently.
run
public void run()
-
Specified by:
-
run in interface java.lang.Runnable