org.alfresco.repo.content.transform
Class TransformerDebug

java.lang.Object
  extended by org.alfresco.repo.content.transform.TransformerDebug

public class TransformerDebug
extends java.lang.Object

Debugs transformers selection and activity.

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) 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), 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 Summary
TransformerDebug(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
          Constructor
 
Method Summary
 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.
 boolean isEnabled()
          Indicates if any logging is required.
 void popAvailable()
          Called after working out what transformers are available and any resulting transform has been called.
 void popTransform()
          Called after performing a transform.
 void pushAvailable(java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype)
          Called prior to working out what transformers are available.
 void pushTransform(ContentTransformer transformer, java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, long sourceSize)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformerDebug

public TransformerDebug(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
Constructor

Method Detail

pushAvailable

public void pushAvailable(java.lang.String fromUrl,
                          java.lang.String sourceMimetype,
                          java.lang.String targetMimetype)
Called prior to working out what transformers are available.


pushTransform

public void pushTransform(ContentTransformer transformer,
                          java.lang.String fromUrl,
                          java.lang.String sourceMimetype,
                          java.lang.String targetMimetype,
                          long sourceSize)
Called prior to performing a transform.


unavailableTransformer

public void unavailableTransformer(ContentTransformer transformer,
                                   long maxSourceSizeKBytes)
Called to identify a transformer that cannot be used during working out available transformers.


availableTransformers

public void availableTransformers(java.util.List transformers,
                                  long sourceSize,
                                  java.lang.String calledFrom)
Called once all available transformers have been identified.


popAvailable

public void popAvailable()
Called after working out what transformers are available and any resulting transform has been called.


popTransform

public void popTransform()
Called after performing a transform.


isEnabled

public boolean isEnabled()
Indicates if any logging is required.


setDebugOutput

public static boolean setDebugOutput(boolean debugOutput)
Enable or disable debug log output. Normally used to hide calls to getTransformer as trace rather than debug level log messages. There are lots of these and it makes it hard to see what is going on.

Parameters:
debugOutput - if true both debug and trace is generated. Otherwise all output is trace.
Returns:
the original value.

debug

public void debug(java.lang.String message)
Log a message prefixed with the current transformation reference.

Parameters:
message -

debug

public 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.

Parameters:
message -

setCause

public 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.



Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.