public class RemoteProxy extends Object implements IRemoteProxyMaker
| Modifier and Type | Field and Description |
|---|---|
long |
callTimeoutInMillis
Setup the timeout for calls.
|
boolean |
closeIfTimedOut
If this is true then the connection is closed if a timeout should occur.
|
String |
defaultTargetName
The default name for the target remote object, which can be null.
|
Class[] |
interfaces
This is the set of interfaces each proxy Object will implement.
|
boolean |
multiThreaded
By default a single-threaded model is used - which is the most
memory efficient implementation.
|
ClassLoader |
proxyClassLoader
The ClassLoader to use for proxy creation.
|
OPTION_CLOSE_ON_TIMEOUT, OPTION_IS_MULTITHREADED| Constructor and Description |
|---|
RemoteProxy()
After calling this constructor you must set the interfaces member
to hold the list of interfaces proxy objects will implement.
|
RemoteProxy(Class interfaceClass)
Create a RemoteProxy to implement a single interface, in single threaded
mode with no special ClassLoader.
|
RemoteProxy(Class[] interfaces,
boolean multiThreaded)
Create a RemoteProxy and set the interfaces list and multiThreaded option.
|
RemoteProxy(Class interfaceClass,
int iRemoteProxyMakerOptions,
ClassLoader proxyClassLoader)
Create a RemoteProxy and set the interfaces list to hold a single interface.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the connection, after which calls to any proxies created will fail.
|
Object |
createProxy()
Create an Object that implements the interfaces by making remote calls
to a peer object across the connection specified in setConnection.
|
Object |
createProxy(String targetName)
Create an Object that implements the interfaces by making remote calls
to a peer object across the connection specified in setConnection.
|
Object |
createTestConnection(Object serverObject)
Create a local MemoryStream connection across which remote calls will
be made.
|
static void |
createTestStreams(InputStream[] inputs,
OutputStream[] outputs)
Create input and output streams connected to each other via MemoryStreams.
|
Handle |
getRunningHandle()
Get a Handle that can be used to monitor the connection.
|
long |
getTimeOut()
Get the timeout for receiving responses from remote calls in
milliseconds.
|
boolean |
isOpen()
Return if the connection is open.
|
Handle |
makeServerObject(Object serverObject,
Object inputChannel,
Object outputChannel)
Used on the server side to make a connection over the input/output channels such that the
specified serverObject acts as a server Object for incoming remote
method calls on the inputChannel.
|
void |
setConnection(Object input,
Object output)
Setup the connection.
|
void |
setConnection(Socket connection)
Setup the connection.
|
void |
setTimeOut(long timeoutInMillis)
Set the timeout for receiving responses from remote calls.
|
public Class[] interfaces
public boolean multiThreaded
public long callTimeoutInMillis
public boolean closeIfTimedOut
public String defaultTargetName
public ClassLoader proxyClassLoader
public RemoteProxy()
public RemoteProxy(Class interfaceClass, int iRemoteProxyMakerOptions, ClassLoader proxyClassLoader)
interfaceClass - the interface that proxy objects will implement.iRemoteProxyMakerOptions - any of the IRemoteProxyMaker.OPTION_XXXproxyClassLoader - an optional ClassLoader to be used when making the proxy.
values ORed together.public RemoteProxy(Class[] interfaces, boolean multiThreaded)
interfaces - the list of interfaces that proxy objects will implement.multiThreaded - true for multithreaded implementations, false for single threaded.public RemoteProxy(Class interfaceClass)
interfaceClass - the interface the proxy will implement.public long getTimeOut()
IRemoteProxyMakergetTimeOut in interface IRemoteProxyMakerpublic void setTimeOut(long timeoutInMillis)
IRemoteProxyMakersetTimeOut in interface IRemoteProxyMakertimeoutInMillis - the maximum time in milliseconds
to wait for a response from the remote object.public void setConnection(Object input, Object output) throws IOException
setConnection in interface IRemoteProxyMakerinput - - this can be an InputStream, a BlockInputStream or a Socket.output - - this can be an OutputStream, a BlockOutputStream or a Socket.IOException - on any IO error.public void setConnection(Socket connection) throws IOException
connection - - a connected Socket.IOExceptionpublic boolean isOpen()
isOpen in interface IRemoteProxyMakerpublic void close()
close in interface IRemoteProxyMakerpublic Handle getRunningHandle()
getRunningHandle in interface IRemoteProxyMakerpublic Object createProxy(String targetName)
targetName - the name of the target object, which may be null.public Object createProxy()
createProxy in interface IRemoteProxyMakerpublic Object createTestConnection(Object serverObject) throws IOException
createTestConnection in interface IRemoteProxyMakerserverObject - the serverObject that will have calls invoked on it
over the connection link.IOException - on any IO error, which should be none since a
MemoryStream is used.public static void createTestStreams(InputStream[] inputs, OutputStream[] outputs)
inputs - an array of 2 InputStreams. inputs[0] and outputs[0] should
be used by one side of the connection and inputs[1] and outputs[1] should
be used on the other side.outputs - an array of 2 OutputStreams. inputs[0] and outputs[0] should
be used by one side of the connection and inputs[1] and outputs[1] should
be used on the other side.public Handle makeServerObject(Object serverObject, Object inputChannel, Object outputChannel) throws IOException
This RemoteProxy should have been setup to handle a single interface and the serverObject must implement that interface.
makeServerObject in interface IRemoteProxyMakerserverObject - the object that implements the interface.inputChannel - this can be an InputStream, a BlockInputStream or
a Socket.outputChannel - this can be an OutputStream, a BlockOutputStream or
a Socket.IOException - on any IO error.