L - The type of the local serverR - The type of the remote serverpublic class Link<L,R> extends Thread implements Closeable
Thread.State, Thread.UncaughtExceptionHandlerMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
Link(Class<R> remoteType,
DataInputStream in,
DataOutputStream out,
Executor es)
Create a new link based on an Data in/output stream.
|
Link(Class<R> remoteType,
InputStream in,
OutputStream out,
Executor es)
Create a new link based on an in/output stream.
|
Link(Class<R> type,
Socket socket,
Executor es)
Create a new link based on a socket.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close this link.
|
DataInputStream |
getInput()
Get the input stream
|
DataOutputStream |
getOutput()
Get the output stream
|
R |
getRemote()
Get the proxy to the remote peer.
|
boolean |
isOpen()
Answer if this link is open
|
void |
open(L local)
Open the stream by providing the local interface to use
|
void |
run()
The thread method that receives the messages from the input stream
|
static <L,R> Closeable |
server(String name,
Class<R> type,
int port,
String host,
Function<Link<L,R>,L> local,
boolean localOnly,
ExecutorService es)
Create a server.
|
static <L,R> Closeable |
server(String name,
Class<R> type,
ServerSocket server,
Function<Link<L,R>,L> local,
boolean localOnly,
Executor es)
Create a server.
|
void |
setRemote(Object remote)
Change the object used for the remote.
|
protected void |
terminate(Exception t) |
void |
transfer(Object result)
Transfer the link to another and close this link object
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic Link(Class<R> remoteType, InputStream in, OutputStream out, Executor es)
remoteType - the remote typein - the incoming messages streamout - where messages are send topublic Link(Class<R> remoteType, DataInputStream in, DataOutputStream out, Executor es)
remoteType - the remote typein - the incoming messages streamout - where messages are send topublic Link(Class<R> type, Socket socket, Executor es) throws IOException
type - the type of the remotesocket - the socketIOExceptionpublic void open(L local)
local - the local serverpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic R getRemote()
public void run()
public static <L,R> Closeable server(String name, Class<R> type, int port, String host, Function<Link<L,R>,L> local, boolean localOnly, ExecutorService es) throws IOException
name - the name of the servertype - the remote typeport - the local porthost - on which host to registerlocal - the local's peer interfacelocalOnly - only accept calls from the local hostIOExceptionpublic static <L,R> Closeable server(String name, Class<R> type, ServerSocket server, Function<Link<L,R>,L> local, boolean localOnly, Executor es)
name - the name of the servertype - the remote typeserver - the Socket Serverlocal - the local's peer interfacelocalOnly - only accept calls from the local hostpublic boolean isOpen()
public DataOutputStream getOutput()
public DataInputStream getInput()
public void setRemote(Object remote)
remote - peerpublic void transfer(Object result) throws Exception
result - the result of the call that caused the transferExceptionprotected void terminate(Exception t)
Copyright © 2021. All rights reserved.