org.e2etrace.trace
Class AbstractTraceSessionManager

java.lang.Object
  extended by org.e2etrace.trace.AbstractTraceSessionManager
All Implemented Interfaces:
ITraceSessionManager
Direct Known Subclasses:
DefaultTraceSessionManager, ThreadedTraceSessionManager

public abstract class AbstractTraceSessionManager
extends Object
implements ITraceSessionManager

Base class for all trace session manager implementations.

The base class automatically loads a trace configuration if a property e2etrace.configuration has been defined. This property must contain the name of a valid e2etrace configuration file. For example, if -De2etrace.configuration=e2etrace.properties is passed on the command line of the application, the respective file will be looked up in the classpath and loaded into an instance of PropertiesTraceConfig. The base class applies the following rules to determine the correct configuration class for a file name:

If e2etrace.configuration has not been defined, a default trace configuration (see DefaultTraceConfig will be used for the trace session manager.

If tracing has been disabled in the trace config, getCurrentSession will always return a NOOP trace session (see NoopTraceSession.

Author:
Gunther Popp

Constructor Summary
protected AbstractTraceSessionManager()
          Constructor.
 
Method Summary
protected abstract  void assignCurrentSession(ITraceSession session)
          CALL-BACK: Forward a newly assigned current trace session to sub-classes.
 ITraceConfig getConfig()
          Returns the current trace configuration.
 ITraceSession getCurrentSession()
          Returns the current (active) trace session.
protected abstract  ITraceSession requestCurrentSession()
          CALL-BACK: Request the current trace session from sub-classes.
 void setConfig(ITraceConfig config)
          Assign a new trace configuration to the session manager.
 void setCurrentSession(ITraceSession session)
          Sets the current (active) trace session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.e2etrace.trace.ITraceSessionManager
releaseCurrentSession
 

Constructor Detail

AbstractTraceSessionManager

protected AbstractTraceSessionManager()
Constructor.

Method Detail

requestCurrentSession

protected abstract ITraceSession requestCurrentSession()
CALL-BACK: Request the current trace session from sub-classes.

This call-back is triggered for every invokation of getCurrentSession.

Returns:
current (active) trace session

assignCurrentSession

protected abstract void assignCurrentSession(ITraceSession session)
CALL-BACK: Forward a newly assigned current trace session to sub-classes.

This call-back is triggered for every invokation of setCurrentSession.

Parameters:
session - new current (active) trace session

setConfig

public final void setConfig(ITraceConfig config)
Assign a new trace configuration to the session manager.

The configuration will be used by the manager itself and all trace sessions under its control.

Specified by:
setConfig in interface ITraceSessionManager
Parameters:
config - trace configuration

getConfig

public final ITraceConfig getConfig()
Returns the current trace configuration.

Specified by:
getConfig in interface ITraceSessionManager
Returns:
trace configuration

getCurrentSession

public ITraceSession getCurrentSession()
Returns the current (active) trace session.

If no current trace session has been assigned yet using setCurrentSession or if releaseCurrentSession has been called, a NoopTraceSession will be returned. This allows, for example, the execution of unit-tests for classes that contain enterStep/leaveStep without intializing a trace session first.

Specified by:
getCurrentSession in interface ITraceSessionManager
Returns:
trace session

setCurrentSession

public void setCurrentSession(ITraceSession session)
Sets the current (active) trace session.

Specified by:
setCurrentSession in interface ITraceSessionManager
Parameters:
session - new current trace session


Copyright © 2013 Gunther Popp. All Rights Reserved.