public class TransformerDebug
extends java.lang.Object
As transformations are frequently composed of lower level transformations, log
messages include a prefix to identify the transformation. A numeric dot notation
is used (such as 123.1.2
indicating the second third level transformation
of the 123rd top level transformation).
In order to track of the nesting of transforms, this class has a stack to represent
the Transformers. Each Transformer calls TransformerDebug.pushTransform(org.alfresco.repo.content.transform.ContentTransformer, java.lang.String, java.lang.String, java.lang.String, long, org.alfresco.service.cmr.repository.TransformationOptions)
at the start of a
transform and TransformerDebug.popTransform()
at the end. However the top level transform may
be selected from a list of available transformers. To record this activity,
TransformerDebug.pushAvailable(java.lang.String, java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions)
, TransformerDebug.unavailableTransformer(org.alfresco.repo.content.transform.ContentTransformer, long)
(to record the reason a
transformer is rejected), TransformerDebug.availableTransformers(java.util.List, long, java.lang.String)
(to record the available
transformers) and TransformerDebug.popAvailable()
are called.
Constructor and Description |
---|
TransformerDebug(org.alfresco.service.cmr.repository.NodeService nodeService,
org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
activeTransformer(int mimetypePairCount,
ContentTransformer transformer,
java.lang.String sourceMimetype,
java.lang.String targetMimetype,
long maxSourceSizeKBytes,
java.lang.Boolean explicit,
boolean firstMimetypePair) |
void |
activeTransformer(java.lang.String sourceMimetype,
java.lang.String targetMimetype,
int transformerCount,
ContentTransformer transformer,
long maxSourceSizeKBytes,
java.lang.Boolean explicit,
boolean firstTransformer) |
void |
availableTransformers(java.util.List transformers,
long sourceSize,
java.lang.String calledFrom)
Called once all available transformers have been identified.
|
void |
debug(java.lang.String message)
Log a message prefixed with the current transformation reference.
|
void |
debug(java.lang.String message,
java.lang.Throwable t)
Log a message prefixed with the current transformation reference
and include a exception, suppressing the stack trace if repeated
as we return up the stack of transformers.
|
java.lang.String |
fileSize(long size) |
java.lang.String |
getFileName(TransformationOptions options,
boolean firstLevel,
long sourceSize) |
java.lang.String |
getName(ContentTransformer transformer) |
void |
inactiveTransformer(ContentTransformer transformer) |
boolean |
isEnabled()
Indicates if any logging is required.
|
java.lang.String |
ms(long time) |
void |
popAvailable()
Called after working out what transformers are available and any
resulting transform has been called.
|
void |
popIsTransformableSize()
Called after returning from a nested isTransformable.
|
void |
popMisc()
Removes a frame from the stack.
|
void |
popTransform()
Called after performing a transform.
|
void |
pushAvailable(java.lang.String fromUrl,
java.lang.String sourceMimetype,
java.lang.String targetMimetype,
TransformationOptions options)
Called prior to working out what transformers are available.
|
void |
pushIsTransformableSize(ContentTransformer transformer)
Called prior to calling a nested isTransformable.
|
void |
pushMisc()
Adds a new level to the stack to get a new request number or nesting number.
|
void |
pushTransform(ContentTransformer transformer,
java.lang.String fromUrl,
java.lang.String sourceMimetype,
java.lang.String targetMimetype,
long sourceSize,
TransformationOptions options)
Called prior to performing a transform.
|
java.lang.Throwable |
setCause(java.lang.Throwable t)
Sets the cause of a transformation failure, so that only the
message of the Throwable is reported later rather than the full
stack trace over and over.
|
static boolean |
setDebugOutput(boolean debugOutput)
Enable or disable debug log output.
|
void |
unavailableTransformer(ContentTransformer transformer,
long maxSourceSizeKBytes)
Called to identify a transformer that cannot be used during working out
available transformers.
|
public TransformerDebug(org.alfresco.service.cmr.repository.NodeService nodeService, org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
public void pushAvailable(java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
public void pushTransform(ContentTransformer transformer, java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, long sourceSize, TransformationOptions options)
public void pushMisc()
public void pushIsTransformableSize(ContentTransformer transformer)
public void unavailableTransformer(ContentTransformer transformer, long maxSourceSizeKBytes)
public void availableTransformers(java.util.List transformers, long sourceSize, java.lang.String calledFrom)
public void inactiveTransformer(ContentTransformer transformer)
public void activeTransformer(int mimetypePairCount, ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, long maxSourceSizeKBytes, java.lang.Boolean explicit, boolean firstMimetypePair)
public void activeTransformer(java.lang.String sourceMimetype, java.lang.String targetMimetype, int transformerCount, ContentTransformer transformer, long maxSourceSizeKBytes, java.lang.Boolean explicit, boolean firstTransformer)
public void popAvailable()
public void popTransform()
public void popMisc()
public void popIsTransformableSize()
public boolean isEnabled()
public static boolean setDebugOutput(boolean debugOutput)
debugOutput
- if true
both debug and trace is generated. Otherwise all output is trace.public void debug(java.lang.String message)
message
- public void debug(java.lang.String message, java.lang.Throwable t)
message
- public java.lang.Throwable setCause(java.lang.Throwable t)
public java.lang.String getName(ContentTransformer transformer)
public java.lang.String getFileName(TransformationOptions options, boolean firstLevel, long sourceSize)
public java.lang.String ms(long time)
public java.lang.String fileSize(long size)
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.