Package de.christofreichardt.diagnosis
Class QueueTracer<T extends AbstractTracer>
java.lang.Object
de.christofreichardt.diagnosis.AbstractTracer
de.christofreichardt.diagnosis.QueueTracer<T>
- Type Parameters:
T- the wrapped tracer
- Direct Known Subclasses:
OueueNetTracer,QueueFileTracer,QueueNullTracer
A special tracer intended for the use by a bounded blocking queue. This is an option to retrieve tracer within a multi-threaded environment
when we cannot control the creation of the threads. An example would be applications within a container that manages a thread pool. This tracer
honors the contract of an
AbstractTracer but does so by wrapping and delegating to another AbstractTracer. In particular the
current tracing context will be automatically cleared when calling wayout() and the method stack remains empty afterwards. Thus the tracer
can be reused for another thread's tracing context without any danger to create a memory leak.
- Author:
- Christof Reichardt
-
Nested Class Summary
Nested classes/interfaces inherited from class de.christofreichardt.diagnosis.AbstractTracer
AbstractTracer.Exception -
Field Summary
FieldsFields inherited from class de.christofreichardt.diagnosis.AbstractTracer
VERSION -
Constructor Summary
ConstructorsConstructorDescriptionQueueTracer(String name, T tracer) Constructor expects the tracer name and the to be wrapped tracer instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidDelegates to the corresponding method of the wrapped tracer.voidclose()Closes the wrapped tracer.Delegates to the corresponding method of the wrapped tracer.Delegates to the corresponding method of the wrapped tracer.intDelegates to the corresponding method of the wrapped tracer.Delegates to the corresponding method of the wrapped tracer.protected AbstractThreadMapDelegates to the corresponding method of the wrapped tracer.voidDelegates to the corresponding method of the wrapped tracer by using the config parameter global to all queued tracer.voidinitCurrentTracingContext(int debugLevel, boolean online) Delegates to the corresponding method of the wrapped tracer.booleanDelegates to the corresponding method of the wrapped tracer.booleanisOpened()Delegates to the corresponding method of the wrapped tracer.voidlogException(LogLevel logLevel, Throwable throwable, Class clazz, String methodName) Delegates to the corresponding method of the wrapped tracer.voidlogMessage(LogLevel logLevel, String message, Class clazz, String methodName) Delegates to the corresponding method of the wrapped tracer.voidopen()Opens the wrapped tracer.out()Delegates to the corresponding method of the wrapped tracer.protected IndentablePrintStreamout(int level) Delegates to the corresponding method of the wrapped tracer.protected voidreadConfiguration(XPath xpath, Node node) Reads the configuration for this particular tracer instance by evaluating the given node with the given xpath engine.protected voidsetAutoflush(boolean autoflush) Sets the autoflush mode of the wrapped tracervoidsetBufferSize(int bufferSize) Sets the buffer size of the wrapped tracer.wayout()Delegates to the corresponding method of the wrapped tracer.Methods inherited from class de.christofreichardt.diagnosis.AbstractTracer
entry, formatStreamErrorState, formatVersionInfo, getBufferedOutputStream, getName, getNullPrintStream, getTracePrintStream, setBufferedOutputStream, setOpened, setTracePrintStream, substitute
-
Field Details
-
tracer
Some tracer.
-
-
Constructor Details
-
QueueTracer
Constructor expects the tracer name and the to be wrapped tracer instance.- Parameters:
name- the name of the tracertracer- the to be wrapped tracer
-
-
Method Details
-
getSyncObject
Delegates to the corresponding method of the wrapped tracer.- Overrides:
getSyncObjectin classAbstractTracer- Returns:
- the sync object of the wrapped tracer
-
getBufferSize
public int getBufferSize()Delegates to the corresponding method of the wrapped tracer.- Overrides:
getBufferSizein classAbstractTracer- Returns:
- the buffer size of the wrapped tracer
-
isAutoflush
public boolean isAutoflush()Delegates to the corresponding method of the wrapped tracer.- Overrides:
isAutoflushin classAbstractTracer- Returns:
- indicates the autoflush mode of the wrapped tracer
-
isOpened
public boolean isOpened()Delegates to the corresponding method of the wrapped tracer.- Overrides:
isOpenedin classAbstractTracer- Returns:
- indicates if the wrapped tracer is openend
-
setBufferSize
public void setBufferSize(int bufferSize) Sets the buffer size of the wrapped tracer.- Overrides:
setBufferSizein classAbstractTracer- Parameters:
bufferSize- the bufferSize to set
-
setAutoflush
protected void setAutoflush(boolean autoflush) Sets the autoflush mode of the wrapped tracer- Overrides:
setAutoflushin classAbstractTracer- Parameters:
autoflush- the autoflush to set
-
readConfiguration
protected void readConfiguration(XPath xpath, Node node) throws XPathExpressionException, AbstractTracer.Exception Description copied from class:AbstractTracerReads the configuration for this particular tracer instance by evaluating the given node with the given xpath engine.- Overrides:
readConfigurationin classAbstractTracer- Parameters:
xpath- the xpath enginenode- the config node- Throws:
XPathExpressionException- indicates xpath problemsAbstractTracer.Exception- indicates problems when configuring certain tracer instances
-
open
public void open()Opens the wrapped tracer.- Specified by:
openin classAbstractTracer
-
close
public void close()Closes the wrapped tracer.- Specified by:
closein classAbstractTracer
-
initCurrentTracingContext
public void initCurrentTracingContext()Delegates to the corresponding method of the wrapped tracer by using the config parameter global to all queued tracer.- Overrides:
initCurrentTracingContextin classAbstractTracer
-
initCurrentTracingContext
public void initCurrentTracingContext(int debugLevel, boolean online) Delegates to the corresponding method of the wrapped tracer.- Overrides:
initCurrentTracingContextin classAbstractTracer- Parameters:
debugLevel- controls the extent of the outputonline- a value of false delivers no output of the current thread at all whereas a value of true delivers output controlled by debugLevel
-
entry
Delegates to the corresponding method of the wrapped tracer.- Overrides:
entryin classAbstractTracer- Parameters:
returnType- the return type of the method as string representationclazz- the class to which that method belongmethodSignature- the remaining method signature (without return type) inclusive parameter as string representation- Returns:
- the TraceMethod which has been put onto the stack - a mere data object for internal use primarily. May be null.
-
entry
Delegates to the corresponding method of the wrapped tracer.- Overrides:
entryin classAbstractTracer- Parameters:
returnType- the return type of the method as string representationobject- the object that owns the methodmethodSignature- the remaining method signature (without return type) inclusive parameter as string representation- Returns:
- the TraceMethod which has been put onto the stack - a mere data object for internal use primarily. May be null.
-
logMessage
Delegates to the corresponding method of the wrapped tracer.- Overrides:
logMessagein classAbstractTracer- Parameters:
logLevel- one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVEREmessage- the to be logged messageclazz- the originating classmethodName- the originating method
-
logException
Delegates to the corresponding method of the wrapped tracer.- Overrides:
logExceptionin classAbstractTracer- Parameters:
logLevel- one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVEREthrowable- the to be logged throwableclazz- the originating classmethodName- the name of the relevant method
-
getThreadMap
Delegates to the corresponding method of the wrapped tracer.- Overrides:
getThreadMapin classAbstractTracer- Returns:
- the thread map of the wrapped tracer
-
wayout
Delegates to the corresponding method of the wrapped tracer. Besides it checks if the stack size of the current tracing context has decreased to zero. If so then the current tracing context will be cleared.- Overrides:
wayoutin classAbstractTracer- Returns:
- the TraceMethod which has been popped from the stack - a mere data object for internal use primarily. May be null.
-
out
Delegates to the corresponding method of the wrapped tracer.- Overrides:
outin classAbstractTracer- Returns:
- an
IndentablePrintStream
-
out
Delegates to the corresponding method of the wrapped tracer.- Overrides:
outin classAbstractTracer- Parameters:
level- the level of the to be printed data- Returns:
- an
IndentablePrintStream
-
clearCurrentTracingContext
public void clearCurrentTracingContext()Delegates to the corresponding method of the wrapped tracer.- Overrides:
clearCurrentTracingContextin classAbstractTracer
-