org.apache.cocoon.environment
Class CocoonRunnable

java.lang.Object
  extended byorg.apache.cocoon.environment.internal.EnvironmentHelper.AbstractCocoonRunnable
      extended byorg.apache.cocoon.environment.CocoonRunnable
All Implemented Interfaces:
Runnable

public class CocoonRunnable
extends org.apache.cocoon.environment.internal.EnvironmentHelper.AbstractCocoonRunnable

A Runnable wrapper or base class that inherits the execution context of the thread creating it, as it was at the time of creation.

It is meant to be used when processing of a request is to be split across several cooperating threads (e.g. parallel aggregation).

Note: a CocoonRunnable should not live longer than the end of the execution of the request in the creating thread, otherwise some unexpected behaviours may happen because the parent's environment has been released.

Since:
2.1.8
Version:
$Id: CocoonRunnable.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Constructor Summary
CocoonRunnable()
          Creates an empty CocoonRunnable and copies the environment context of the calling thread, for later use when calling doRun().
CocoonRunnable(Runnable target)
          Wraps an existing Runnable and copies the environment context of the calling thread, for later use when the Runnable's run() method is called.
 
Method Summary
protected  void doRun()
          Does the actual job, in the environment of the creating thread.
 
Methods inherited from class org.apache.cocoon.environment.internal.EnvironmentHelper.AbstractCocoonRunnable
run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CocoonRunnable

public CocoonRunnable()
Creates an empty CocoonRunnable and copies the environment context of the calling thread, for later use when calling doRun(). Users of this constructor will override the doRun() method where the actual job gets done.


CocoonRunnable

public CocoonRunnable(Runnable target)
Wraps an existing Runnable and copies the environment context of the calling thread, for later use when the Runnable's run() method is called.

Parameters:
target - the wrapped Runnable
Method Detail

doRun

protected void doRun()
Does the actual job, in the environment of the creating thread. Calls the wrapped Runnable if one was given, and does nothing otherwise.



Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.