com.gigaspaces.grid.worker
Class TaskWorker

java.lang.Object
  extended by com.gigaspaces.grid.worker.AbstractSpaceWorker
      extended by com.gigaspaces.grid.worker.TaskWorker
All Implemented Interfaces:
GigaSpaceWorker, java.lang.Runnable

public class TaskWorker
extends AbstractSpaceWorker

The TaskWorker provides an implementation of a GigaSpaceWorker that repeatedly takes Task objects from a JavaSpace and invokes the Task.execute() method.

The TaskWorker additionally allows a the use of a WeakHashMap or a HashMap to store information processed by Task entry objects as follows:


Field Summary
static java.lang.Long defaultLeaseTime
           
static long defaultTransactionLeaseTime
           
protected  net.jini.core.entry.Entry template
           
 
Fields inherited from class com.gigaspaces.grid.worker.AbstractSpaceWorker
COMPONENT
 
Constructor Summary
TaskWorker(org.jini.rio.core.jsb.ServiceBeanContext context)
          Create a TaskWorker
 
Method Summary
protected  net.jini.core.entry.Entry doExecute(net.jini.core.entry.Entry entry, java.util.Map map)
          Perform the execute on the Task Entry and return an Entry
protected  boolean getKeepAlive()
          Get the keepAlive property
protected  java.util.Map getTaskEntryMap()
          Get the parameter Map
protected  java.lang.Thread getWorkerThread()
          Set the running worker thread property
 void run()
           
 void setSpace(net.jini.space.JavaSpace space)
          Override parent's setSpace to obtain a transaction manager if this utility is configured to use transaction support
protected  void setWorkerThread(java.lang.Thread thread)
          Set the running worker thread property
 void shutdown()
          Shutdown the worker
 
Methods inherited from class com.gigaspaces.grid.worker.AbstractSpaceWorker
getBackLog, getID, getSpace, getStackTraceAsString, getWatch, getWatchRegistry, setID, setWatchRegistry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

template

protected net.jini.core.entry.Entry template

defaultTransactionLeaseTime

public static final long defaultTransactionLeaseTime
See Also:
Constant Field Values

defaultLeaseTime

public static final java.lang.Long defaultLeaseTime
Constructor Detail

TaskWorker

public TaskWorker(org.jini.rio.core.jsb.ServiceBeanContext context)
           throws java.lang.Exception
Create a TaskWorker

Parameters:
context -
Throws:
java.lang.Exception
Method Detail

setSpace

public void setSpace(net.jini.space.JavaSpace space)
Override parent's setSpace to obtain a transaction manager if this utility is configured to use transaction support

Specified by:
setSpace in interface GigaSpaceWorker
Overrides:
setSpace in class AbstractSpaceWorker
See Also:
GigaSpaceWorker.setSpace(JavaSpace)

shutdown

public void shutdown()
              throws java.lang.InterruptedException
Shutdown the worker

Throws:
java.lang.InterruptedException

getKeepAlive

protected boolean getKeepAlive()
Get the keepAlive property


setWorkerThread

protected void setWorkerThread(java.lang.Thread thread)
Set the running worker thread property


getWorkerThread

protected java.lang.Thread getWorkerThread()
Set the running worker thread property


getTaskEntryMap

protected java.util.Map getTaskEntryMap()
Get the parameter Map


doExecute

protected net.jini.core.entry.Entry doExecute(net.jini.core.entry.Entry entry,
                                              java.util.Map map)
                                       throws java.lang.SecurityException,
                                              java.lang.NoSuchMethodException,
                                              java.lang.IllegalArgumentException,
                                              java.lang.IllegalAccessException,
                                              java.lang.reflect.InvocationTargetException
Perform the execute on the Task Entry and return an Entry

Throws:
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException

run

public void run()


Copyright (c) 2007 GigaSpaces Technologies, Inc.
All Rights Reserved.