L - The type of the local serverR - The type of the remote serverpublic class Link<L,R>
extends java.lang.Thread
implements java.io.Closeable
| Constructor and Description |
|---|
Link(java.lang.Class<R> remoteType,
java.io.DataInputStream in,
java.io.DataOutputStream out,
java.util.concurrent.Executor es)
Create a new link based on an Data in/output stream.
|
Link(java.lang.Class<R> remoteType,
java.io.InputStream in,
java.io.OutputStream out,
java.util.concurrent.Executor es)
Create a new link based on an in/output stream.
|
Link(java.lang.Class<R> type,
java.net.Socket socket,
java.util.concurrent.Executor es)
Create a new link based on a socket.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close this link.
|
java.io.DataInputStream |
getInput()
Get the input stream
|
java.io.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> java.io.Closeable |
server(java.lang.String name,
java.lang.Class<R> type,
int port,
java.lang.String host,
java.util.function.Function<Link<L,R>,L> local,
boolean localOnly,
java.util.concurrent.ExecutorService es)
Create a server.
|
static <L,R> java.io.Closeable |
server(java.lang.String name,
java.lang.Class<R> type,
java.net.ServerSocket server,
java.util.function.Function<Link<L,R>,L> local,
boolean localOnly,
java.util.concurrent.Executor es)
Create a server.
|
void |
setRemote(java.lang.Object remote)
Change the object used for the remote.
|
protected void |
terminate(java.lang.Exception t) |
void |
transfer(java.lang.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(java.lang.Class<R> remoteType, java.io.InputStream in, java.io.OutputStream out, java.util.concurrent.Executor es)
remoteType - the remote typein - the incoming messages streamout - where messages are send topublic Link(java.lang.Class<R> remoteType, java.io.DataInputStream in, java.io.DataOutputStream out, java.util.concurrent.Executor es)
remoteType - the remote typein - the incoming messages streamout - where messages are send topublic Link(java.lang.Class<R> type, java.net.Socket socket, java.util.concurrent.Executor es) throws java.io.IOException
type - the type of the remotesocket - the socketjava.io.IOExceptionpublic void open(L local)
local - the local serverpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic R getRemote()
public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic static <L,R> java.io.Closeable server(java.lang.String name,
java.lang.Class<R> type,
int port,
java.lang.String host,
java.util.function.Function<Link<L,R>,L> local,
boolean localOnly,
java.util.concurrent.ExecutorService es)
throws java.io.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 hostjava.io.IOExceptionpublic static <L,R> java.io.Closeable server(java.lang.String name,
java.lang.Class<R> type,
java.net.ServerSocket server,
java.util.function.Function<Link<L,R>,L> local,
boolean localOnly,
java.util.concurrent.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 java.io.DataOutputStream getOutput()
public java.io.DataInputStream getInput()
public void setRemote(java.lang.Object remote)
remote - peerpublic void transfer(java.lang.Object result)
throws java.lang.Exception
result - the result of the call that caused the transferjava.lang.Exceptionprotected void terminate(java.lang.Exception t)
Copyright (c) aQute SARL (2000, 2019) and others. All Rights Reserved.