GigaSpaces XAP 7.1 API

org.openspaces.remoting
Class ExecutorRemotingTask<T extends Serializable>

java.lang.Object
  extended by org.openspaces.remoting.ExecutorRemotingTask<T>
All Implemented Interfaces:
AsyncResultsReducer<ExecutorRemotingTask.InternalExecutorResult<T>,List<AsyncResult<ExecutorRemotingTask.InternalExecutorResult<T>>>>, Externalizable, Serializable, ClusterInfoAware, DistributedTask<ExecutorRemotingTask.InternalExecutorResult<T>,List<AsyncResult<ExecutorRemotingTask.InternalExecutorResult<T>>>>, Task<ExecutorRemotingTask.InternalExecutorResult<T>>, TaskRoutingProvider, SpaceRemotingInvocation, ApplicationContextAware

public class ExecutorRemotingTask<T extends Serializable>
extends Object
implements DistributedTask<ExecutorRemotingTask.InternalExecutorResult<T>,List<AsyncResult<ExecutorRemotingTask.InternalExecutorResult<T>>>>, ApplicationContextAware, ClusterInfoAware, TaskRoutingProvider, SpaceRemotingInvocation, Externalizable

A Task that can be used to simulate remote invcation with SpaceRemotingServiceExporter. When executed, the task searches for a service exporter (first under the hardwired name serviceExporter, then any bean that define this class), and based on paramters passed on the task itself (such as method name, lookup name and arguments) invokes service methods that are registered with the service exporter.

Author:
kimchy
See Also:
Serialized Form

Nested Class Summary
static class ExecutorRemotingTask.InternalExecutorException
          A wrapper executor exception that holds more information on the exception, such as the instance id.
static class ExecutorRemotingTask.InternalExecutorResult<T extends Serializable>
          A wrapper executor result that holds more information on the exception, such as the instance id.
 
Constructor Summary
ExecutorRemotingTask()
          Should not be used.
ExecutorRemotingTask(String lookupName, String methodName, RemotingUtils.MethodHash methodHash, Object[] arguments)
           
 
Method Summary
 ExecutorRemotingTask.InternalExecutorResult<T> execute()
          Computes a result, or throws an exception if unable to do so.
 Object[] getArguments()
          The arguments for the service method execution.
 String getLookupName()
          The lookup name of the service.
 Object[] getMetaArguments()
          Meta arguments that can be passed as part of the invocation.
 RemotingUtils.MethodHash getMethodHash()
           
 String getMethodName()
          The method name of the service that will be executed.
 Integer getRouting()
          Returns the routing of the task.
 void readExternal(ObjectInput in)
           
 List<AsyncResult<ExecutorRemotingTask.InternalExecutorResult<T>>> reduce(List<AsyncResult<ExecutorRemotingTask.InternalExecutorResult<T>>> results)
           
 void setApplicationContext(ApplicationContext applicationContext)
           
 void setClusterInfo(ClusterInfo clusterInfo)
          Sets the cluster information.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutorRemotingTask

public ExecutorRemotingTask()
Should not be used. Used for externalizable.


ExecutorRemotingTask

public ExecutorRemotingTask(String lookupName,
                            String methodName,
                            RemotingUtils.MethodHash methodHash,
                            Object[] arguments)
Method Detail

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
Specified by:
setApplicationContext in interface ApplicationContextAware

setClusterInfo

public void setClusterInfo(ClusterInfo clusterInfo)
Description copied from interface: ClusterInfoAware
Sets the cluster information.

Note, the cluster information is obtained externally from the application context which means that this feature need to be supported by specific containers (and is not supported by plain Spring application context). This means that beans that implement ClusterInfoAware should take into account the fact that the cluster info provided might be null.

Specified by:
setClusterInfo in interface ClusterInfoAware
Parameters:
clusterInfo - The cluster information to be injected

execute

public ExecutorRemotingTask.InternalExecutorResult<T> execute()
                                                                            throws Exception
Description copied from interface: Task
Computes a result, or throws an exception if unable to do so.

Specified by:
execute in interface Task<ExecutorRemotingTask.InternalExecutorResult<T extends Serializable>>
Returns:
computed result
Throws:
Exception - if unable to compute a result

reduce

public List<AsyncResult<ExecutorRemotingTask.InternalExecutorResult<T>>> reduce(List<AsyncResult<ExecutorRemotingTask.InternalExecutorResult<T>>> results)
                                                                                              throws Exception
Specified by:
reduce in interface AsyncResultsReducer<ExecutorRemotingTask.InternalExecutorResult<T extends Serializable>,List<AsyncResult<ExecutorRemotingTask.InternalExecutorResult<T extends Serializable>>>>
Throws:
Exception

getRouting

public Integer getRouting()
Description copied from interface: TaskRoutingProvider
Returns the routing of the task.

Specified by:
getRouting in interface TaskRoutingProvider
Specified by:
getRouting in interface SpaceRemotingInvocation

getLookupName

public String getLookupName()
Description copied from interface: SpaceRemotingInvocation
The lookup name of the service. Usually the actual interface class name that is proxied on the client side and implemented on the server side.

Specified by:
getLookupName in interface SpaceRemotingInvocation

getMethodName

public String getMethodName()
Description copied from interface: SpaceRemotingInvocation
The method name of the service that will be executed.

Specified by:
getMethodName in interface SpaceRemotingInvocation

getMethodHash

public RemotingUtils.MethodHash getMethodHash()

getArguments

public Object[] getArguments()
Description copied from interface: SpaceRemotingInvocation
The arguments for the service method execution.

Specified by:
getArguments in interface SpaceRemotingInvocation

getMetaArguments

public Object[] getMetaArguments()
Description copied from interface: SpaceRemotingInvocation
Meta arguments that can be passed as part of the invocation. This arguments are not used to invoke the method, but can be used to control ceratin pluggable invocation "aspects".

Specified by:
getMetaArguments in interface SpaceRemotingInvocation

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

GigaSpaces XAP 7.1 API

Copyright © GigaSpaces.