org.eclipse.ohf.ihe.atna.agent
Class AtnaAgentFactory

java.lang.Object
  extended by org.eclipse.ohf.ihe.atna.agent.AtnaAgentFactory

public class AtnaAgentFactory
extends java.lang.Object

Threadsafe Factory for obtaining an AtnaAgent instance for a thread, and its children.
The thread local behaviour must be enabled by calling ConfigurableInheritableThreadLocal.enableThreading(boolean). Until this is enabled, this factory will behave as if the AtnaAgent was a singleton for the JVM.
A thread which wants a distinct agent, from that of its parent should use getNewAtnaAgent(), while threads, or methods in a thread that want the current agent should use getAtnaAgent()

Since:
OHF 1.0.0
Author:
Glenn Deen glenn@almaden.ibm.com

Constructor Summary
AtnaAgentFactory()
           
 
Method Summary
static AtnaAgent getAtnaAgent()
          Returns the AtnaAgent active for the current thread.
static AtnaAgent getNewAtnaAgent()
          Creates a new AtnaAgent for current thread, and makes it the active AtnaAgent for the thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtnaAgentFactory

public AtnaAgentFactory()
Method Detail

getAtnaAgent

public static AtnaAgent getAtnaAgent()
Returns the AtnaAgent active for the current thread. AtnaAgent's are inherited and shared by child threads. If a thread needs its own agent it should call getNewAtnaAgent instead. If no Agent is active, one is created, and will be returned by subsequent calls to this method.
This would typically be the method used by objects in a thread to obtain the AtnaAgent for the thread.

Returns:

getNewAtnaAgent

public static AtnaAgent getNewAtnaAgent()
Creates a new AtnaAgent for current thread, and makes it the active AtnaAgent for the thread. Children thread will inherit this agent instance if they use getAtnaAgent().
This is the method typically used by threads when they are created to create a distinct Agent instance.

Returns: