org.curjent.agent
Class SingletonTask

java.lang.Object
  extended by org.curjent.agent.SingletonTask
All Implemented Interfaces:
AgentTasks

public class SingletonTask
extends Object
implements AgentTasks

Source for one task.

This implementation is not thread-safe.


Field Summary
private  Object task
          Non-null if available or null if acquired.
 
Constructor Summary
SingletonTask(Object task)
          Singleton source for the given task.
 
Method Summary
 Object acquire()
          Returns the task used to construct this singleton.
 void release(Object task)
          Releases the given task, making it available to be acquired again.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

task

private Object task
Non-null if available or null if acquired.

Constructor Detail

SingletonTask

public SingletonTask(Object task)
Singleton source for the given task.

Throws:
NullPointerException - Argument is null.
Method Detail

acquire

public Object acquire()
               throws Throwable
Returns the task used to construct this singleton. Returns null if the task is currently acquired.

Specified by:
acquire in interface AgentTasks
Throws:
Throwable - An unexpected error.
See Also:
Agent.newInstance(AgentLoader, Class[], AgentTasks, Class)

release

public void release(Object task)
             throws Throwable
Releases the given task, making it available to be acquired again.

Specified by:
release in interface AgentTasks
Throws:
NullPointerException - Argument is null.
IllegalStateException - Task was already released.
Throwable - An unexpected error.


Copyright 2009-2011 Tom Landon
Apache License 2.0