public final class Client extends java.lang.Object implements ISynchAsynchConnection
Modifier and Type | Field and Description |
---|---|
protected long |
closeTimeout |
protected ID |
containerID |
static long |
DEFAULT_CLOSE_TIMEOUT |
static int |
DEFAULT_MAX_BUFFER_MSG |
static int |
DEFAULT_RCVR_PRIORITY |
static int |
DEFAULT_SNDR_PRIORITY |
static int |
DEFAULT_WAIT_INTERVAL |
protected ISynchAsynchEventHandler |
handler |
protected java.io.ObjectInputStream |
inputStream |
protected boolean |
isClosing |
protected int |
keepAlive |
protected java.lang.Thread |
keepAliveThread |
protected java.io.ObjectOutputStream |
outputStream |
protected java.lang.Object |
outputStreamLock |
protected PingMessage |
ping |
protected java.lang.Object |
pingLock |
protected PingResponseMessage |
pingResp |
protected java.util.Map |
properties |
static java.lang.String |
PROTOCOL |
protected SimpleFIFOQueue |
queue |
protected java.lang.Thread |
rcvThread |
protected java.lang.Thread |
sendThread |
protected java.net.Socket |
socket |
protected boolean |
waitForPing |
Constructor and Description |
---|
Client(ISynchAsynchEventHandler handler,
int keepAlive) |
Client(java.net.Socket aSocket,
java.io.ObjectInputStream iStream,
java.io.ObjectOutputStream oStream,
ISynchAsynchEventHandler handler) |
Client(java.net.Socket aSocket,
java.io.ObjectInputStream iStream,
java.io.ObjectOutputStream oStream,
ISynchAsynchEventHandler handler,
int maxmsgs) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(IConnectionListener l)
Add comm layer event listener
|
java.lang.Object |
connect(ID remote,
java.lang.Object data,
int timeout)
Connect to a remote process
|
protected java.net.Socket |
createConnectSocket(java.net.URI remote,
int timeout) |
protected void |
debug(java.lang.String msg) |
void |
disconnect()
Disconnect
|
java.lang.Object |
getAdapter(java.lang.Class clazz) |
ID |
getLocalID()
Get local ID for this connection
|
java.lang.Object |
getOutputStreamLock() |
java.util.Map |
getProperties()
Get properties for this connection
|
boolean |
isConnected() |
boolean |
isStarted() |
protected java.net.URI |
parseRemoteID(ID remote) |
void |
queueObject(ID recipient,
java.io.Serializable obj) |
void |
removeListener(IConnectionListener l)
remove comm layer event listener
|
void |
sendAsynch(ID recipient,
byte[] obj)
Send data asynchronously.
|
void |
sendAsynch(ID recipient,
java.lang.Object obj) |
java.io.Serializable |
sendObject(ID recipient,
java.io.Serializable obj) |
java.lang.Object |
sendSynch(ID rec,
byte[] obj)
Send data synchronously, blocking until a result is received
|
java.lang.Object |
sendSynch(ID rec,
java.lang.Object obj) |
void |
setCloseTimeout(long t) |
void |
setProperties(java.util.Map props) |
void |
start()
Start connection
|
void |
stop()
Stop connection
|
protected void |
traceStack(java.lang.String msg,
java.lang.Throwable e) |
public static final java.lang.String PROTOCOL
public static final int DEFAULT_SNDR_PRIORITY
public static final int DEFAULT_RCVR_PRIORITY
public static final long DEFAULT_CLOSE_TIMEOUT
public static final int DEFAULT_MAX_BUFFER_MSG
public static final int DEFAULT_WAIT_INTERVAL
protected java.net.Socket socket
protected java.io.ObjectOutputStream outputStream
protected java.io.ObjectInputStream inputStream
protected ISynchAsynchEventHandler handler
protected SimpleFIFOQueue queue
protected int keepAlive
protected java.lang.Thread sendThread
protected java.lang.Thread rcvThread
protected java.lang.Thread keepAliveThread
protected boolean isClosing
protected boolean waitForPing
protected PingMessage ping
protected PingResponseMessage pingResp
protected long closeTimeout
protected java.util.Map properties
protected ID containerID
protected java.lang.Object pingLock
protected final java.lang.Object outputStreamLock
public Client(java.net.Socket aSocket, java.io.ObjectInputStream iStream, java.io.ObjectOutputStream oStream, ISynchAsynchEventHandler handler) throws java.io.IOException
java.io.IOException
public Client(java.net.Socket aSocket, java.io.ObjectInputStream iStream, java.io.ObjectOutputStream oStream, ISynchAsynchEventHandler handler, int maxmsgs) throws java.io.IOException
java.io.IOException
public Client(ISynchAsynchEventHandler handler, int keepAlive)
public ID getLocalID()
IConnection
getLocalID
in interface IConnection
public void removeListener(IConnectionListener l)
IConnection
removeListener
in interface IConnection
l
- the listener to removepublic void addListener(IConnectionListener l)
IConnection
addListener
in interface IConnection
l
- the listener to addpublic boolean isConnected()
isConnected
in interface IConnection
public boolean isStarted()
isStarted
in interface IConnection
protected java.net.Socket createConnectSocket(java.net.URI remote, int timeout) throws ECFException
remote
- remote URItimeout
- timeoutECFException
- if socket cannot be created for input parametersprotected java.net.URI parseRemoteID(ID remote) throws ECFException
remote
- the remtoe IDECFException
- if remote ID cannot be parsedpublic java.lang.Object connect(ID remote, java.lang.Object data, int timeout) throws ECFException
IConnection
connect
in interface IConnection
remote
- the identity of the remote to connect to. Must not be null
.data
- any data to send with the connection request (e.g. password or
other authentication data)timeout
- the timeout (in ms) for the connection to occurECFException
- thrown if some problem with connectpublic void setCloseTimeout(long t)
public void start()
IConnection
start
in interface IConnection
public void stop()
IConnection
stop
in interface IConnection
public void disconnect()
IConnection
disconnect
in interface IConnection
public void sendAsynch(ID recipient, byte[] obj) throws java.io.IOException
IAsynchConnection
sendAsynch
in interface IAsynchConnection
recipient
- the ID of the intended receiverobj
- the data to sendjava.io.IOException
- thrown if data cannot be sent (e.g. disconnected)public void sendAsynch(ID recipient, java.lang.Object obj) throws java.io.IOException
java.io.IOException
public void queueObject(ID recipient, java.io.Serializable obj) throws java.io.IOException
java.io.IOException
public java.io.Serializable sendObject(ID recipient, java.io.Serializable obj) throws java.io.IOException
java.io.IOException
public java.lang.Object sendSynch(ID rec, java.lang.Object obj) throws java.io.IOException
java.io.IOException
public java.lang.Object sendSynch(ID rec, byte[] obj) throws java.io.IOException
ISynchConnection
sendSynch
in interface ISynchConnection
rec
- the receiver to receive the synchronous requestobj
- the data to sendjava.io.IOException
- thrown if sending cannot occur (e.g. not connected)public java.util.Map getProperties()
IConnection
getProperties
in interface IConnection
public java.lang.Object getAdapter(java.lang.Class clazz)
getAdapter
in interface org.eclipse.core.runtime.IAdaptable
protected void debug(java.lang.String msg)
protected void traceStack(java.lang.String msg, java.lang.Throwable e)
public void setProperties(java.util.Map props)
public java.lang.Object getOutputStreamLock()