public interface Session extends Closeable, Flushable, Link
send and receive methods,
which behave like a blocking queue with a capacity of one. Object transport
via this interface is intended for handshaking and authentication. After an
initial exchange, remote objects should be used for most communication
between endpoints.
The send/receive methods follow the pull model rather than the push
model. Calling send locally enqueues an object, but receive
makes a remote call. This behavior allows a ClassResolver to be installed prior to its first use, avoiding race
conditions.
Environment| Modifier and Type | Method and Description |
|---|---|
void |
addCloseListener(SessionCloseListener listener)
Add a listener which receives notification when this session is
closed.
|
void |
close()
Closes the session.
|
void |
flush()
|
Object |
getLocalAddress() |
Object |
getRemoteAddress() |
Object |
receive()
Receives a
Remote or Serializable object sent by the
remote session. |
Object |
receive(long timeout,
TimeUnit unit)
Receives a
Remote or Serializable object sent by the
remote session. |
void |
send(Object obj)
Sends a
Remote or Serializable object to be received by
the remote session. |
void |
send(Object obj,
long timeout,
TimeUnit unit)
Sends a
Remote or Serializable object to be received by
the remote session. |
void |
setClassLoader(ClassLoader loader)
Convenience method to use a ClassLoader for resolving classes.
|
void |
setClassResolver(ClassResolver resolver)
Can be called at most once to control how deserialized classes and
remote interfaces are resolved.
|
Object getLocalAddress()
getLocalAddress in interface LinkObject getRemoteAddress()
getRemoteAddress in interface Linkvoid send(Object obj) throws RemoteException
Remote or Serializable object to be received by
the remote session. Any failure during the send forces the session to be
closed.obj - remote or serializable object to send; can be nullRemoteExceptionvoid send(Object obj, long timeout, TimeUnit unit) throws RemoteException
Remote or Serializable object to be received by
the remote session. Any failure or timeout during the send forces the
session to be closed.obj - remote or serializable object to send; can be nulltimeout - how long to wait before timing out, in units of unitunit - a TimeUnit determining how to interpret the timeout parameterRemoteTimeoutException - if timeout elapsesRemoteExceptionObject receive() throws RemoteException
Remote or Serializable object sent by the
remote session. Any failure during the receive forces the session to be
closed.RemoteExceptionObject receive(long timeout, TimeUnit unit) throws RemoteException
Remote or Serializable object sent by the
remote session. Any failure or timeout during the receive forces the
session to be closed.timeout - how long to wait before timing out, in units of unitunit - a TimeUnit determining how to interpret the timeout parameterRemoteTimeoutException - if timeout elapsesRemoteExceptionvoid addCloseListener(SessionCloseListener listener)
IllegalArgumentException - if listener is nullvoid setClassResolver(ClassResolver resolver)
resolver - resolves deserialized classes and interfaces; pass null
to always use default resolverIllegalStateException - if resolver cannot be changedvoid setClassLoader(ClassLoader loader)
loader - resolves deserialized classes and interfaces; pass null
to always use default resolverIllegalStateException - if resolver cannot be changedvoid flush()
throws IOException
batch calls and eventual asynchronous
methods.flush in interface FlushableIOExceptionvoid close()
throws IOException
close in interface AutoCloseableclose in interface CloseableIOExceptionCopyright © 2006–2015 Cojen. All rights reserved.