GigaSpaces XAP 10.0.1 API

org.openspaces.core.executor.juc
Class RunnableTaskAdapter<T extends Serializable>

java.lang.Object
  extended by org.openspaces.core.executor.juc.RunnableTaskAdapter<T>
All Implemented Interfaces:
Externalizable, Serializable, ProcessObjectsProvider, Task<T>, TaskRoutingProvider
Direct Known Subclasses:
RunnableDistributedTaskAdapter

public class RunnableTaskAdapter<T extends Serializable>
extends Object
implements Task<T>, ProcessObjectsProvider, TaskRoutingProvider, Externalizable

An adapter allowing to execute a Runnable using Space task executors.

Author:
kimchy
See Also:
Serialized Form

Constructor Summary
RunnableTaskAdapter()
          Here just for externlizable.
RunnableTaskAdapter(Runnable runnable)
          Constructs a new runnable task adapter with the runnable to run.
RunnableTaskAdapter(Runnable runnable, T result)
          Constructs a new runnable task adapter with the runnable to run.
 
Method Summary
 T execute()
          Simply delegates the execution to Runnable.run() and returns the optional result provided in the constructor.
 Object[] getObjectsToProcess()
          Returns the callable passed so it will be processed on the node it is executed on as well.
 Object getRouting()
          Tries to extract the routing information form the task.
protected  Runnable getRunnable()
          Returns the embedded runnable.
 void readExternal(ObjectInput in)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RunnableTaskAdapter

public RunnableTaskAdapter()
Here just for externlizable.


RunnableTaskAdapter

public RunnableTaskAdapter(Runnable runnable)
Constructs a new runnable task adapter with the runnable to run.


RunnableTaskAdapter

public RunnableTaskAdapter(Runnable runnable,
                           T result)
Constructs a new runnable task adapter with the runnable to run. Will return the result after the call to run.

Method Detail

execute

public T execute()
                               throws Exception
Simply delegates the execution to Runnable.run() and returns the optional result provided in the constructor.

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

getObjectsToProcess

public Object[] getObjectsToProcess()
Returns the callable passed so it will be processed on the node it is executed on as well.

Specified by:
getObjectsToProcess in interface ProcessObjectsProvider

getRouting

public Object getRouting()
Tries to extract the routing information form the task.

Specified by:
getRouting in interface TaskRoutingProvider

getRunnable

protected Runnable getRunnable()
Returns the embedded runnable.


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 10.0.1 API

Copyright © GigaSpaces.