|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ix.util.IPC
public class IPC
Support for interprocess communication in a framework that allows different communication strategies to be used in a uniform way. Some simple strategies, such as one that sends serialized objects via sockets, are included.
The framework specifies certain entities only a in very general way. Communication strategies that are meant to be interchangeable must therefore follow shared conventions - not enforced by the framework - chiefly concerning the objects used to represent "destinations" and implementations of the InputMessage interface.
Note that a "destination" need not contain all the information needed for communication with the corresponding agent. Instead, the destination may be merely a name, perhaps as a String, with the rest of the information stored elsewhere.
Nested Class Summary | |
---|---|
static class |
IPC.BasicDestinationTable
A HashMap implementation of the DestinationTable interface. |
static class |
IPC.BasicInputMessage
A minimal implementation of InputMessage. |
static class |
IPC.BrokenConnectionException
|
static class |
IPC.BufferedMessageListener
A MessageListener that enqueues messages for processing in a separate thread of the listener's own. |
static interface |
IPC.CommunicationStrategy
An object that determines how various IPC operations are performed. |
static interface |
IPC.Connection
An object that can send and receive. |
static interface |
IPC.DestinationTable
A mapping from destination names to the data needed to establish connections with the corresponding agents. |
static class |
IPC.EmptyCommunicationStrategy
A strategy that just throws an exception whenever the agent tries to send. |
static interface |
IPC.InputMessage
An object that represents an incoming message. |
static class |
IPC.IPCException
The exception thrown by IPC methods. |
static interface |
IPC.MessageListener
An object that is notified when a message is received. |
static class |
IPC.SimpleIXCommunicationStrategy
An ObjectStream communication strategy for I-X agents. |
static class |
IPC.SimpleIXXMLCommunicationStrategy
An XMLObjectStream communication strategy for I-X agents. |
static interface |
IPC.SocketlikeCommunicationStrategy
A CommunicationStrategy that provides "connections" analogous to sockets and a visible mapping from destination names to the data needed to establish a connection. |
static class |
IPC.XMLObjectStreamCommunicationStrategy
A version of ObjectStreamCommunicationStrategy that encodes the message contents in XML rather than serializing. |
Field Summary | |
---|---|
(package private) static IPC.CommunicationStrategy |
communicationStrategy
The communication strategy used by the static methods of this class that do not have a communication strategy as a parameter. |
(package private) static java.util.List |
ipcListeners
Listeners that can observe messages as they're sent and received. |
(package private) static java.lang.Object |
thisAgentAsDestination
|
Method Summary | |
---|---|
static void |
addIPCListener(IPCListener listener)
|
protected static IPC.CommunicationStrategy |
evalStrategyExpr(java.lang.String e)
Evaluate the description of a ParameterizedCommStrategy . |
static void |
fireMessageReceived(IPC.InputMessage message)
|
static void |
fireMessageSent(java.lang.Object dest,
java.lang.Object contents)
|
static void |
fireSendingMessage(java.lang.Object dest,
java.lang.Object contents)
|
static IPC.CommunicationStrategy |
getCommunicationStrategy()
Returns the communication strategy used by the static methods of this class that do not have a communication strategy as a parameter. |
static IPC.CommunicationStrategy |
makeCommunicationStrategy(java.lang.String strategyName)
Returns a CommunicationStrategy based on a name, name, that is either an expression containing a colon, a special abbreviation or the name of a class. |
static void |
sendObject(java.lang.Object destination,
java.lang.Object contents)
Sends an object to the specified destination using the global communication strategy. |
static void |
setCommunicationStrategy(IPC.CommunicationStrategy s)
Sets the communication strategy used by the static methods of this class that do not have a communication strategy as a parameter. |
static void |
setCommunicationStrategy(java.lang.String strategyName)
Sets the communication strategy used by the static methods of this class that do not have a communication strategy as a parameter. |
static void |
setupServer(java.lang.Object destination,
IPC.MessageListener listener)
Does what is required for this agent to receive messages sent using the global communication strategy. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static IPC.CommunicationStrategy communicationStrategy
static java.lang.Object thisAgentAsDestination
static java.util.List ipcListeners
Method Detail |
---|
public static IPC.CommunicationStrategy getCommunicationStrategy()
public static void setCommunicationStrategy(IPC.CommunicationStrategy s)
public static void setCommunicationStrategy(java.lang.String strategyName)
strategyName
is interpreted by the
makeCommunicationStrategy(String)
method.
public static IPC.CommunicationStrategy makeCommunicationStrategy(java.lang.String strategyName)
evalStrategyExpr(String)
; otherwise, the
algorithm is as follows, with Name standing for
name with its first character changed to upper case:
SimpleIXCommunicationStrategy
;
SimpleIXXMLCommunicationStrategy
;
IllegalArgumentException
.
IPC.SimpleIXCommunicationStrategy
,
IPC.SimpleIXXMLCommunicationStrategy
,
setCommunicationStrategy(String strategyName)
protected static IPC.CommunicationStrategy evalStrategyExpr(java.lang.String e)
ParameterizedCommStrategy
.
The syntax is name:args where name
is the name of a ParameterizedCommStrategy and args is
a comma-separated list. The interpretation of the arguments
is up to the parameterized comm strategy, but usually the
arguments will be comm strategy names or expressions.
Some strategies that expect more than one strategy as parameters
use the syntax default:strategyExpr to say
which strategy is the default.
Examples:
tracing:xml wrapper:somepack.subpack.SomeCommunicationStrategy dispatching:jabber,default:xml,tracing:xml dispatching:jabber,xml,default:tracing:xml random:this,might,be,anythingThere's an obvious problem if one of the parameter strategies expects muliple parameters of its own. For example, "
tracing:dispatching:a,b,c
" will give
the tracing strategy parameters "dispatching:a",
"b", and "c". If this becomes a problem
in practice, we'll define a parser that can handle
parenthesized subexpressions.
public static void sendObject(java.lang.Object destination, java.lang.Object contents)
If the object being sent implements the Sendable
interface and has a null sender-id, the sender-id will be
set to the "destination" recorded by the setupServer
method. (The sender-id is actually set in a clone of the
original object so that the original isn't modified.)
setupServer(Object destination, MessageListener listener)
public static void setupServer(java.lang.Object destination, IPC.MessageListener listener)
The destination is recorded and will be used by the
sendObject method to fill in the sender-id of
Sendable
objects.
public static void addIPCListener(IPCListener listener)
public static void fireSendingMessage(java.lang.Object dest, java.lang.Object contents)
public static void fireMessageSent(java.lang.Object dest, java.lang.Object contents)
public static void fireMessageReceived(IPC.InputMessage message)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |