|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.isolate.IsolateMessage
An IsolateMessage
wraps the various types that can be sent
through a Link
, or on an isolate start
invocation or for redirecting an isolate's "standard" I/O.
IsolateMessage
s are immutable and may be sent on multiple
links simultaneously or serially.
Many of the various objects that can be referenced from an
IsolateMessage
are not immutable, and changes to those
objects which are visible before the message is sent will be reflected in the message which is
transferred across the link.
An IsolateMessageVisitor
can be used to dynamically determine
the contents of an IsolateMessage
.
The null
reference cannot be sent via an IsolateMessage
.
Field Summary | |
static java.lang.isolate.IsolateMessage |
EMPTY_MESSAGE
The empty message. |
Method Summary | |
void |
acceptVisitor(java.lang.isolate.IsolateMessageVisitor visitor)
Gets the content of this message via the given message visitor. |
boolean |
equals(Object obj)
Tests this IsolateMessage for equality with the given object. |
byte[] |
getByteArray()
Gets a reference to the byte array wrapped in this message. |
ByteBuffer |
getByteBuffer()
Gets a reference to the ByteBuffer object wrapped in this
message. |
java.lang.isolate.IsolateMessage[] |
getComposite()
Copies the IsolateMessages wrapped in this message to an array. |
DatagramChannel |
getDatagramChannel()
Gets a reference to the DatagramChannel wrapped in this
message. |
DatagramSocket |
getDatagramSocket()
Gets a reference to the DatagramSocket wrapped in this
message. |
FileChannel |
getFileChannel()
Gets a reference to the FileChannel wrapped in this
message. |
FileInputStream |
getFileInputStream()
Gets a reference to the FileInputStream wrapped in this
message. |
FileOutputStream |
getFileOutputStream()
Gets a reference to the FileOutputStream wrapped in this
message. |
java.lang.isolate.Isolate |
getIsolate()
Gets a reference to the Isolate object wrapped in this message. |
java.lang.isolate.IsolateEvent |
getIsolateEvent()
Gets a reference to the IsolateEvent wrapped in this message. |
java.lang.isolate.Link |
getLink()
Gets a reference to the Link object wrapped in this message. |
Pipe.SinkChannel |
getPipeSinkChannel()
Gets a reference to the Pipe.SinkChannel wrapped in this message. |
Pipe.SourceChannel |
getPipeSourceChannel()
Gets a reference to the Pipe.SourceChannel wrapped in this message. |
Object |
getSerializable()
Gets a reference to the object wrapped in this message. |
ServerSocket |
getServerSocket()
Gets a reference to the ServerSocket wrapped in this message. |
ServerSocketChannel |
getServerSocketChannel()
Gets a reference to the ServerSocketChannel wrapped in this message. |
Socket |
getSocket()
Gets a reference to the Socket wrapped in this message. |
SocketChannel |
getSocketChannel()
Gets a reference to the SocketChannel wrapped in this message. |
String |
getString()
Gets a reference to the String wrapped in this message. |
static java.lang.isolate.IsolateMessage |
newByteArrayMessage(byte[] b)
Creates an IsolateMessage for copying the given
byte array across a Link . |
static java.lang.isolate.IsolateMessage |
newByteBufferMessage(ByteBuffer b)
Creates an IsolateMessage for copying the given
ByteBuffer across a Link . |
static java.lang.isolate.IsolateMessage |
newCompositeMessage(java.lang.isolate.IsolateMessage[] messages)
Creates an IsolateMessage for sending the given
IsolateMessages across a Link atomically. |
static java.lang.isolate.IsolateMessage |
newDatagramChannelMessage(DatagramChannel d)
Creates an IsolateMessage for sending the given
DatagramChannel across a Link . |
static java.lang.isolate.IsolateMessage |
newDatagramSocketMessage(DatagramSocket s)
Creates an IsolateMessage for sending the given
DatagramSocket across a Link . |
static java.lang.isolate.IsolateMessage |
newFileChannelMessage(FileChannel f)
Creates an IsolateMessage for sending the given
FileChannel across a Link . |
static java.lang.isolate.IsolateMessage |
newFileInputStreamMessage(FileInputStream s)
Creates an IsolateMessage for sending the given
FileInputStream across a Link . |
static java.lang.isolate.IsolateMessage |
newFileOutputStreamMessage(FileOutputStream s)
Creates an IsolateMessage for sending the given
FileOutputStream across a Link . |
static java.lang.isolate.IsolateMessage |
newIsolateEventMessage(java.lang.isolate.IsolateEvent ie)
Creates an IsolateMessage for sending the given
IsolateEvent across a Link . |
static java.lang.isolate.IsolateMessage |
newIsolateMessage(java.lang.isolate.Isolate i)
Creates an IsolateMessage for sending the given Isolate instance
Link . |
static java.lang.isolate.IsolateMessage |
newLinkMessage(java.lang.isolate.Link l)
Creates an IsolateMessage for sending the given link
handle on a Link . |
static java.lang.isolate.IsolateMessage |
newPipeSinkChannelMessage(Pipe.SinkChannel ps)
Creates an IsolateMessage for sending the given
Pipe.SinkChannel across a Link . |
static java.lang.isolate.IsolateMessage |
newPipeSourceChannelMessage(Pipe.SourceChannel ps)
Creates an IsolateMessage for sending the given
Pipe.SourceChannel across a Link . |
static java.lang.isolate.IsolateMessage |
newSerializableMessage(Object o)
Creates an IsolateMessage for sending the given
serializable object across a Link . |
static java.lang.isolate.IsolateMessage |
newServerSocketChannelMessage(ServerSocketChannel s)
Creates an IsolateMessage for sending the given
ServerSocketChannel across a Link . |
static java.lang.isolate.IsolateMessage |
newServerSocketMessage(ServerSocket s)
Creates an IsolateMessage for sending the given
ServerSocket across a Link . |
static java.lang.isolate.IsolateMessage |
newSocketChannelMessage(SocketChannel s)
Creates an IsolateMessage for sending the given
SocketChannel across a Link . |
static java.lang.isolate.IsolateMessage |
newSocketMessage(Socket s)
Creates an IsolateMessage for sending the given
Socket across a Link . |
static java.lang.isolate.IsolateMessage |
newStringMessage(String s)
Creates an IsolateMessage for sending the given
String across a Link . |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.isolate.IsolateMessage EMPTY_MESSAGE
null
, as null
cannot be sent across
a link or included in a composite message.
The empty message has no contents. All of the "get"
operations will throw an IllegalStateException
when
invoked on the empty message.
There is only once instance of the empty message,
so ==
may be used to compare a message to the empty
message.
Method Detail |
public static java.lang.isolate.IsolateMessage newIsolateMessage(java.lang.isolate.Isolate i)
IsolateMessage
for sending the given Isolate
instance
Link
.
If the given isolate has not been
started an IllegalStateException
will be thrown.
i
- the Isolate
to wrap in an IsolateMessage
IsolateMessage
that wraps the given Isolate
object
NullPointerException
- if i
is null
IllegalStateException
- if the given isolate has not been startedLink.send(IsolateMessage)
,
getIsolate()
public static java.lang.isolate.IsolateMessage newLinkMessage(java.lang.isolate.Link l)
IsolateMessage
for sending the given link
handle on a Link
.
l
- the Link
to wrap in an IsolateMessage
IsolateMessage
that wraps the given link
NullPointerException
- if l
is nullLink.send(IsolateMessage)
,
getLink()
public static java.lang.isolate.IsolateMessage newByteBufferMessage(ByteBuffer b)
IsolateMessage
for copying the given
ByteBuffer
across a Link
.
The entire capacity of the ByteBuffer
contents will
be copied into the receiver isolate. The receiver's
ByteBuffer
will have the same Buffer.capacity()
,
Buffer.mark()
, Buffer.limit()
, and Buffer.position()
as the given ByteBuffer
.
If the contents of the given ByteBuffer
(or its
underlying array) are changed after the IsolateMessage
is created,
such changes will be reflected in the ByteBuffer
sent to
a receiver. However, once a ByteBuffer
has been sent to
a receiver, changes in the source buffer will not be reflected in
the receiver's buffer.
b
- the ByteBuffer
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given ByteBuffer
NullPointerException
- if b
is nullLink.send(IsolateMessage)
,
getByteBuffer()
public static java.lang.isolate.IsolateMessage newByteArrayMessage(byte[] b)
IsolateMessage
for copying the given
byte array across a Link
.
If the contents of the given byte array are changed after the
IsolateMessage
is created, such changes will be reflected in the
byte array given to a receiver. However, once a byte array has
been sent to a receiver, changes in the source array will not be
reflected in the receiver's array.
b
- the byte array to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given byte array
NullPointerException
- if b
is nullLink.send(IsolateMessage)
,
getByteArray()
public static java.lang.isolate.IsolateMessage newStringMessage(String s)
IsolateMessage
for sending the given
String
across a Link
.
s
- the byte array to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given String
NullPointerException
- if s
is nullLink.send(IsolateMessage)
,
getString()
public static java.lang.isolate.IsolateMessage newSocketMessage(Socket s)
IsolateMessage
for sending the given
Socket
across a Link
.
Only java.net.Socket
objects created by the platform default socket
implementation are supported by this method. Passing an
unsupported Socket
instance to this method will result in an
IllegalArgumentException
.
s
- the Socket
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given Socket
NullPointerException
- if s
is null
IllegalArgumentException
- if s
is not of a specific type supported by the implementationLink.send(IsolateMessage)
,
getSocket()
public static java.lang.isolate.IsolateMessage newServerSocketMessage(ServerSocket s)
IsolateMessage
for sending the given
ServerSocket
across a Link
.
Only java.net.ServerSocket
objects created by the platform default
socket implementation are supported by this method.
Passing an unsupported ServerSocket
instance to this method will result in
an IllegalArgumentException
.
s
- the ServerSocket
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given ServerSocket
NullPointerException
- if s
is null
IllegalArgumentException
- if s
is not of a specific type supported by the implementationLink.send(IsolateMessage)
,
getServerSocket()
public static java.lang.isolate.IsolateMessage newDatagramSocketMessage(DatagramSocket s)
IsolateMessage
for sending the given
DatagramSocket
across a Link
.
Only java.net.DatagramSocket
objects created by the platform default
socket implementation are supported by this method.
Passing an unsupported DatagramSocket
instance to this method will result in
an IllegalArgumentException
.
s
- the DatagramSocket
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given DatagramSocket
NullPointerException
- if s
is null
IllegalArgumentException
- if s
is not of a specific type supported by the implementationLink.send(IsolateMessage)
,
getDatagramSocket()
public static java.lang.isolate.IsolateMessage newFileInputStreamMessage(FileInputStream s)
IsolateMessage
for sending the given
FileInputStream
across a Link
.
s
- the FileInputStream
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given FileInputStream
NullPointerException
- if s
is nullLink.send(IsolateMessage)
,
getFileInputStream()
public static java.lang.isolate.IsolateMessage newFileOutputStreamMessage(FileOutputStream s)
IsolateMessage
for sending the given
FileOutputStream
across a Link
.
s
- the FileOutputStream
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given FileOutputStream
NullPointerException
- if s
is nullLink.send(IsolateMessage)
,
getFileOutputStream()
public static java.lang.isolate.IsolateMessage newSerializableMessage(Object o)
IsolateMessage
for sending the given
serializable object across a Link
.
Sending the returned message across a Link via
Link.send
behaves as if
the contained object was first serialized by an invocation of
ObjectOutputStream.writeObject
. If
serialization of the object would
have any visible side-effects they will occur when send
is
invoked.
Note that logical serialization and associated side-effects occur only when the message is sent, and on each such occasion. Consequently if the message is never sent no serialization or serialization side- effects will occur, and if the message is sent more than once serialization and serialization side-effects will occur each time.
Also note that the object is not copied when the message is created, but is contained by reference, hence that any changes to it's non- transient mutable state which occur between message creation and the first send, or between subsequent sends will be visible in the logical copies of the object obtained by the receiving isolate.
o
- the Serializable
object to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given Serializable
NullPointerException
- if o
is nullLink.send(IsolateMessage)
,
getSerializable()
public static java.lang.isolate.IsolateMessage newPipeSinkChannelMessage(Pipe.SinkChannel ps)
IsolateMessage
for sending the given
Pipe.SinkChannel
across a Link
.
Only java.nio.channel.Pipe.SinkChannel
objects
created by the platform default channel provider are supported by
this method. Passing an unsupported
Pipe.SinkChannel
instance to this method will result
in an IllegalArgumentException
.
ps
- the Pipe.SinkChannel
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given Pipe.SinkChannel
NullPointerException
- if ps
is nullLink.send(IsolateMessage)
,
getPipeSinkChannel()
public static java.lang.isolate.IsolateMessage newPipeSourceChannelMessage(Pipe.SourceChannel ps)
IsolateMessage
for sending the given
Pipe.SourceChannel
across a Link
.
Only java.nio.channel.Pipe.SourceChannel
objects
created by the platform default channel provider are supported by
this method. Passing an unsupported
Pipe.SourceChannel
instance to this method will
result in an IllegalArgumentException
.
ps
- the Pipe.SourceChannel
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given Pipe.SourceChannel
NullPointerException
- if ps
is nullLink.send(IsolateMessage)
,
getPipeSourceChannel()
public static java.lang.isolate.IsolateMessage newIsolateEventMessage(java.lang.isolate.IsolateEvent ie)
IsolateMessage
for sending the given
IsolateEvent
across a Link
.
ie
- the IsolateEvent
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given IsolateEvent
NullPointerException
- if ie
is nullLink.send(IsolateMessage)
,
getIsolateEvent()
public static java.lang.isolate.IsolateMessage newCompositeMessage(java.lang.isolate.IsolateMessage[] messages)
IsolateMessage
for sending the given
IsolateMessages
across a Link
atomically.
Note that only the IsolateMessage
reference elements of the
given array are copied during construction of the composite message and
that no reference to the array itself is retained. Consequently subsequent
modification of the array will have no effect on the contents of the
returned composite message.
messages
- an array containing the messages to wrap in an
IsolateMessage
IsolateMessage
that wraps the given array of messages
NullPointerException
- if messages
is null
IllegalArgumentException
- if the messages
parameter
is non-null but contains a null
referenceLink.send(IsolateMessage)
,
getComposite()
public java.lang.isolate.Isolate getIsolate()
Isolate
object wrapped in this message.
Isolate
object wrapped in this message
IllegalStateException
- if this message does not contain an Isolate
newIsolateMessage(java.lang.isolate.Isolate)
public java.lang.isolate.Link getLink()
Link
object wrapped in this message.
Link
object wrapped in this message
IllegalStateException
- if this message does not contain a Link
newLinkMessage(java.lang.isolate.Link)
public ByteBuffer getByteBuffer()
ByteBuffer
object wrapped in this
message.
ByteBuffer
object wrapped in
this message.
IllegalStateException
- if this message does not contain a ByteBuffer
newByteBufferMessage(java.nio.ByteBuffer)
public byte[] getByteArray()
IllegalStateException
- if this message does not contain a byte arraynewByteArrayMessage(byte[])
public String getString()
String
wrapped in this message.
String
wrapped in this message
IllegalStateException
- if this message does not contain a String
newStringMessage(java.lang.String)
public Socket getSocket()
Socket
wrapped in this message.
Socket
wrapped in this message
IllegalStateException
- if this message does not contain a Socket
newSocketMessage(java.net.Socket)
public ServerSocket getServerSocket()
ServerSocket
wrapped in this message.
ServerSocket
wrapped in this message
IllegalStateException
- if this message does not contain a ServerSocket
newServerSocketMessage(java.net.ServerSocket)
public Object getSerializable() throws LinkSerializationException
If this message was received from a link the first
invocation of getSerializable
will return an object created
as if by an invocation of ObjectInputStream.readObject
on the serialized
representation contained in this message.
Subsequent invocations of this method will return the same object
returned by the first invocation. Consequently, deserialization (including any
possible side effects) happens no more than once.
Note that if getSerializable
is never invoked during
the lifetime of this message, neither deserialization nor its
possible side effects will occur.
If this message was not received from a link, i.e., if it was created by the current isolate, the object returned will be the same as the object supplied as the argument to the newSerializableMessage factory method that created it. In this case, an invocation of this method will not result in any serialization or deserialization or their side effects.
If there are errors deserializing an object, subsequent
attempts to invoke this method will result in an
IllegalStateException
.
IllegalStateException
- if this message does not contain a serialized object
LinkSerializationException
- if a Serialization error occurrednewSerializableMessage(java.lang.Object)
public Pipe.SinkChannel getPipeSinkChannel()
Pipe.SinkChannel
wrapped in this message.
Pipe.SinkChannel
wrapped in this message
IllegalStateException
- if this message does not contain a Pipe.SinkChannel
newPipeSinkChannelMessage(java.nio.channels.Pipe.SinkChannel)
public Pipe.SourceChannel getPipeSourceChannel()
Pipe.SourceChannel
wrapped in this message.
Pipe.SourceChannel
wrapped in this message
IllegalStateException
- if this message does not contain a Pipe.SourceChannel
newPipeSourceChannelMessage(java.nio.channels.Pipe.SourceChannel)
public java.lang.isolate.IsolateEvent getIsolateEvent()
IsolateEvent
wrapped in this message.
IsolateEvent
wrapped in this message
IllegalStateException
- if this message does not contain an IsolateEvent
newIsolateEventMessage(java.lang.isolate.IsolateEvent)
public java.lang.isolate.IsolateMessage[] getComposite()
IsolateMessages
wrapped in this message to an array.
IsolateMessages
wrapped in this message.
IllegalStateException
- if this message is not a composite messagenewCompositeMessage(java.lang.isolate.IsolateMessage[])
public void acceptVisitor(java.lang.isolate.IsolateMessageVisitor visitor) throws LinkSerializationException
visitor
. This is a convenience method for
processing or dispatching isolate messages with unknown content.
visitor
- The message visitor on which to invoke the appropriate method
NullPointerException
- if visitor
is null
IllegalStateException
- if the message receiver is unable to process
the content of this message
LinkSerializationException
- if a serialization error occurred while
deserializing a serializablepublic boolean equals(Object obj)
IsolateMessage
for equality with the given object.
Returns true
if and only if obj
is not
null
and is an IsolateMessage
and
contains a reference ==
to the reference in this.
equals
in class Object
obj
- The object to be compared
true
if the objects are the same; false
otherwisepublic DatagramSocket getDatagramSocket()
DatagramSocket
wrapped in this
message.
DatagramSocket
wrapped in this message
IllegalStateException
- if this message does not contain a DatagramSocket
newDatagramSocketMessage(java.net.DatagramSocket)
public FileInputStream getFileInputStream()
FileInputStream
wrapped in this
message.
FileInputStream
wrapped in this
message.
IllegalStateException
- if this message does not contain a FileInputStream
newFileInputStreamMessage(java.io.FileInputStream)
public FileOutputStream getFileOutputStream()
FileOutputStream
wrapped in this
message.
FileOutputStream
wrapped in this message
IllegalStateException
- if this message does not contain a FileOutputStream
newFileOutputStreamMessage(java.io.FileOutputStream)
public static java.lang.isolate.IsolateMessage newSocketChannelMessage(SocketChannel s)
IsolateMessage
for sending the given
SocketChannel
across a Link
.
Only socket channel objects created by the platform default socket
implementation are supported by IsolateMessage
. Passing a
non-supported socket type to this method will result in an
IllegalArgumentException
.
s
- the SocketChannel
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given SocketChannel
NullPointerException
- if s
is null
IllegalArgumentException
- if s
is not of a specific type supported by the implementationLink.send(IsolateMessage)
,
getSocketChannel()
public static java.lang.isolate.IsolateMessage newServerSocketChannelMessage(ServerSocketChannel s)
IsolateMessage
for sending the given
ServerSocketChannel
across a Link
.
Only server socket channel objects created by the platform default
socket implementation are supported by IsolateMessage
.
Passing a non-supported socket type to this method will result in
an IllegalArgumentException
.
s
- the ServerSocketChannel
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given ServerSocketChannel
NullPointerException
- if s
is null
IllegalArgumentException
- if s
is not of a specific type supported by the implementationLink.send(IsolateMessage)
,
getServerSocketChannel()
public static java.lang.isolate.IsolateMessage newDatagramChannelMessage(DatagramChannel d)
IsolateMessage
for sending the given
DatagramChannel
across a Link
.
Only DatagramChannel objects created by the platform default
socket implementation are supported by IsolateMessage
.
Passing a non-supported socket type to this method will result in
an IllegalArgumentException
.
d
- the DatagramChannel
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given DatagramChannel
NullPointerException
- if s
is null
IllegalArgumentException
- if s
is not of a specific type supported by the implementationLink.send(IsolateMessage)
,
getDatagramChannel()
public static java.lang.isolate.IsolateMessage newFileChannelMessage(FileChannel f)
IsolateMessage
for sending the given
FileChannel
across a Link
.
Only java.nio.channel.FileChannel
objects created
by the platform default channel provider are supported by this
method. Passing an unsupported FileChannel
instance
to this method will result in an
IllegalArgumentException
.
f
- the FileChannel
to wrap in an IsolateMessage
IsolateMessage
that contains a reference to the given FileChannel
NullPointerException
- if s
is nullLink.send(IsolateMessage)
,
getFileChannel()
public SocketChannel getSocketChannel()
SocketChannel
wrapped in this message.
SocketChannel
wrapped in this message
IllegalStateException
- if this message does not contain a SocketChannel
newSocketChannelMessage(java.nio.channels.SocketChannel)
public ServerSocketChannel getServerSocketChannel()
ServerSocketChannel
wrapped in this message.
ServerSocketChannel
wrapped in this message
IllegalStateException
- if this message does not contain a ServerSocketChannel
newServerSocketChannelMessage(java.nio.channels.ServerSocketChannel)
public DatagramChannel getDatagramChannel()
DatagramChannel
wrapped in this
message.
DatagramChannel
wrapped in this message
IllegalStateException
- if this message does not contain a DatagramChannel
newDatagramChannelMessage(java.nio.channels.DatagramChannel)
public FileChannel getFileChannel()
FileChannel
wrapped in this
message.
FileChannel
wrapped in this message
IllegalStateException
- if this message does not contain a FileChannel
newFileChannelMessage(java.nio.channels.FileChannel)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |