org.apfloat.samples
Class RemoteOperationExecutor

java.lang.Object
  extended byorg.apfloat.samples.RemoteOperationExecutor
All Implemented Interfaces:
OperationExecutor

public class RemoteOperationExecutor
extends Object
implements OperationExecutor

Class to call an OperationServer to execute Operations remotely.

Version:
1.0
Author:
Mikko Tommila

Constructor Summary
RemoteOperationExecutor(String host, int port)
          Create a new client that will connect to the server running at the specified host and port.
 
Method Summary
 Object execute(Operation operation)
          Execute an operation remotely.
 BackgroundOperation executeBackground(Operation operation)
          Execute an operation remotely.
 String getHost()
          Returns the host name.
 int getPort()
          Returns the host port.
 int getWeight()
          Returns the relative weight of this executor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteOperationExecutor

public RemoteOperationExecutor(String host,
                               int port)
Create a new client that will connect to the server running at the specified host and port.

Parameters:
host - Hostname of the remote server.
port - Port of the remote server.
Method Detail

execute

public Object execute(Operation operation)
Execute an operation remotely. This method will block until the return value has been received.

Specified by:
execute in interface OperationExecutor
Parameters:
operation - The operation to execute remotely.
Returns:
The result of the operation.
Throws:
RuntimeException - In case of network error or if the return value class is unknown.

executeBackground

public BackgroundOperation executeBackground(Operation operation)
Execute an operation remotely. This method starts a new thread running the remote call and returns immediately.

Specified by:
executeBackground in interface OperationExecutor
Parameters:
operation - The operation to execute remotely.
Returns:
A BackgroundOperation for retrieving the result of the operation later.

getWeight

public int getWeight()
Description copied from interface: OperationExecutor
Returns the relative weight of this executor. The weights of different operation executors can be used to distribute work more equally.

Specified by:
getWeight in interface OperationExecutor
Returns:
The relative weight of this operation executor.

getHost

public String getHost()
Returns the host name.

Returns:
The host name.

getPort

public int getPort()
Returns the host port.

Returns:
The host port.