ewe.io
Class RemoteCallTask

java.lang.Object
  extended byewe.io.RemoteCallTask

public class RemoteCallTask
extends Object

A RemoteCallTask provides an easy way to create an object that is to be controlled remotely via RemoteCalls, or to act as a local proxy for a remote object that will be controlled via RemoteCalls.

The usual way to use this is to construct it using a Steaming connection that has been made between the two communicating entities and then provide methods for servicing the remote calls. That is to say, the default method of setup is to have incoming remote calls be invoked on this very object.


Field Summary
 RemoteCallHandler handler
          This is the handler used for incoming/outgoing calls.
 
Constructor Summary
RemoteCallTask()
          Create a new RemoteCallTask.
RemoteCallTask(InputStream in, OutputStream out)
          Create a new RemoteCallTask that automatically calls start() with the specified streams.
RemoteCallTask(InputStream in, OutputStream out, Object target)
          Create a new RemoteCallTask that automatically calls start() with the specified streams and target object.
RemoteCallTask(Stream stream)
          Create a new RemoteCallTask that automatically calls start() with the specified stream.
RemoteCallTask(Stream stream, Object target)
          Create a new RemoteCallTask that automatically calls start() with the specified stream and target object.
 
Method Summary
 void close()
          Close the handler, and the stream.
protected  void connectionClosed()
          This gets called when the connection between the two RemoteHandlers is closed.
 RemoteCall newCall(String method)
          Get a new RemoteCall to be invoked on the object on the other side of the connection.
 void setEncryption(DataProcessor decryptor, DataProcessor encryptor)
          Set the encryption/decryption to be used by the RemoteCallHandler.
 void setEncryption(String password)
          Set the encryption/decryption to be used by the RemoteCallHandler.
 void setKeys(EncryptionKey remotePublicKey, EncryptionKey localPrivateKey)
          Set the public/private keys for the remote calls.
 void start(InputStream in, OutputStream out, Object targetObject)
          Create a new RemoteCallHandler ready for calls.
 void start(RemoteCallHandler handler)
          Start using a predefined handler.
 void start(Stream stream)
          Create a new RemoteCallHandler ready for calls.
 void start(Stream stream, Object targetObject)
          Create a new RemoteCallHandler ready for calls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

handler

public RemoteCallHandler handler
This is the handler used for incoming/outgoing calls. It is created using one of the start methods.

Constructor Detail

RemoteCallTask

public RemoteCallTask()
Create a new RemoteCallTask. You will need to call one of the start() methods before you can use it.


RemoteCallTask

public RemoteCallTask(Stream stream)
Create a new RemoteCallTask that automatically calls start() with the specified stream. Incoming remote calls will be invoked on this RemoteCallTask object.

Parameters:
stream - A stream that will be used for Remote Call handling.

RemoteCallTask

public RemoteCallTask(Stream stream,
                      Object target)
Create a new RemoteCallTask that automatically calls start() with the specified stream and target object.

Parameters:
stream - A stream that will be used for Remote Call handling.
target - The target object that incoming remote calls will be invoked on. If it is null then incoming remote calls will be invoked on this object.

RemoteCallTask

public RemoteCallTask(InputStream in,
                      OutputStream out,
                      Object target)
Create a new RemoteCallTask that automatically calls start() with the specified streams and target object.

Parameters:
in - the input stream to the remote application.
out - the output stream to the remote application.
target - The target object that incoming remote calls will be invoked on. If it is null then incoming remote calls will be invoked on this object.

RemoteCallTask

public RemoteCallTask(InputStream in,
                      OutputStream out)
Create a new RemoteCallTask that automatically calls start() with the specified streams. Incoming remote calls will be invoked on this object.

Parameters:
in - the input stream to the remote application.
out - the output stream to the remote application.
Method Detail

start

public void start(RemoteCallHandler handler)
Start using a predefined handler.


start

public void start(Stream stream,
                  Object targetObject)
Create a new RemoteCallHandler ready for calls.

Parameters:
stream - A stream that will be used for Remote Call handling. Incoming remote calls will be invoked on this RemoteCallTask object.
targetObject - The target object that incoming remote calls will be invoked on.

start

public void start(Stream stream)
Create a new RemoteCallHandler ready for calls.

Parameters:
stream - A stream that will be used for Remote Call handling. Incoming remote calls will be invoked on this RemoteCallTask object.

start

public void start(InputStream in,
                  OutputStream out,
                  Object targetObject)
Create a new RemoteCallHandler ready for calls.

Parameters:
in - the input stream to the remote application.
out - the output stream to the remote application.

setEncryption

public void setEncryption(String password)
                   throws IOException
Set the encryption/decryption to be used by the RemoteCallHandler.

Throws:
IOException

setEncryption

public void setEncryption(DataProcessor decryptor,
                          DataProcessor encryptor)
                   throws IOException
Set the encryption/decryption to be used by the RemoteCallHandler.

Throws:
IOException

setKeys

public void setKeys(EncryptionKey remotePublicKey,
                    EncryptionKey localPrivateKey)
             throws IOException
Set the public/private keys for the remote calls.

Throws:
IOException

newCall

public RemoteCall newCall(String method)
Get a new RemoteCall to be invoked on the object on the other side of the connection. You can use the call() method on the returned RemoteCall.

Parameters:
method - The method name.

connectionClosed

protected void connectionClosed()
This gets called when the connection between the two RemoteHandlers is closed. You must override this to do something useful.


close

public void close()
Close the handler, and the stream.