de.myfoo.commonj.work
Class FooRemoteWorkItem

java.lang.Object
  extended by de.myfoo.commonj.work.FooWorkItem
      extended by de.myfoo.commonj.work.FooRemoteWorkItem
All Implemented Interfaces:
commonj.work.RemoteWorkItem, commonj.work.WorkItem, java.lang.Comparable, java.lang.Runnable

public final class FooRemoteWorkItem
extends FooWorkItem
implements commonj.work.RemoteWorkItem

Implementation of the remote work item.

Version:
1.0
Author:
Andreas Keldenich

Field Summary
 
Fields inherited from class de.myfoo.commonj.work.FooWorkItem
work
 
Constructor Summary
FooRemoteWorkItem(commonj.work.Work work, commonj.work.WorkListener wl, commonj.work.WorkManager wm)
          Creates a new instance of FooRemoteWorkItem.
 
Method Summary
 commonj.work.WorkManager getPinnedWorkManager()
          This returns a pinned WorkManager which represents the JVM that was used to execute this Work.
 void release()
          Calls the remote Work object's Work.release() method.
 
Methods inherited from class de.myfoo.commonj.work.FooWorkItem
compareTo, getResult, getStatus, run, setDaemons, setResultCollector, setStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface commonj.work.WorkItem
getResult, getStatus
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

FooRemoteWorkItem

public FooRemoteWorkItem(commonj.work.Work work,
                         commonj.work.WorkListener wl,
                         commonj.work.WorkManager wm)
Creates a new instance of FooRemoteWorkItem.

Parameters:
work - the work
wl - work listener
wm - the "remote" work manger
Method Detail

release

public void release()
Calls the remote Work object's Work.release() method. It instructs the Work associated with this RemoteWorkItem to 'stop' voluntarily. If the work has already stopped then this has no effect. The WorkItem.getStatus() can be used to determine whether it has stopped or not but the Work can always stop just after getStatus returns 'still working'. The best way to wait for such Works to release is using the WorkManager.waitForAll(java.util.Collection, long) API.

Specified by:
release in interface commonj.work.RemoteWorkItem
See Also:
RemoteWorkItem.release()

getPinnedWorkManager

public commonj.work.WorkManager getPinnedWorkManager()
This returns a pinned WorkManager which represents the JVM that was used to execute this Work. This allows subsequent remote Works to be sent to the same JVM as the one that was used to execute this WorkItem. If the remote JVM fails then subsequent schedule Works on this WorkManager will fail with a rejected exception even if the remote JVM restarts. The pinned WorkManager is associated with the JVM instance that was running as opposed to any future JVM instance.

Specified by:
getPinnedWorkManager in interface commonj.work.RemoteWorkItem
Returns:
the WorkManager associated with the JVM that was used to execute this RemoteWorkItem
See Also:
RemoteWorkItem.getPinnedWorkManager()