Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

org.alfresco.repo.content.transform
Class AbstractContentTransformer2
java.lang.Object
  org.alfresco.repo.content.transform.ContentTransformerHelper
      org.alfresco.repo.content.transform.AbstractContentTransformerLimits
          org.alfresco.repo.content.transform.AbstractContentTransformer2
All Implemented Interfaces:
ContentTransformer, ContentWorker, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.Aware
Direct Known Subclasses:
ComplexContentTransformer, FailoverContentTransformer, ProxyContentTransformer

@org.alfresco.api.AlfrescoPublicApi
public abstract class AbstractContentTransformer2
extends AbstractContentTransformerLimits
Provides basic services for ContentTransformer implementations.

This class maintains the performance measures for the transformers as well, making sure that there is an extra penalty for transformers that fail regularly.

Author:
Derek Hulley, Roy Wetherall

Fields inherited from class org.alfresco.repo.content.transform.AbstractContentTransformerLimits
transformerDebug
Fields inherited from class org.alfresco.repo.content.transform.ContentTransformerHelper
transformerConfig
Constructor Summary
protected
AbstractContentTransformer2()
          All transformers start with an average transformation time of 0.0 ms, unless there is an Alfresco global property <beanName>.time.
Method Summary
protected void
checkTransformable(ContentReader reader, ContentWriter writer, TransformationOptions options)
          Convenience method to check the transformability of a transformation
protected ExecutorService
getExecutorService()
          Gets the ExecutorService to be used for timeout-aware extraction.
getRetryTransformOnDifferentMimeType()
boolean
getStrictMimeTypeCheck()
long
getTransformationTime()
long
getTransformationTime(String sourceMimetype, String targetMimetype)
          Provides an estimate, usually a worst case guess, of how long a transformation will take.
isTransformationLimitedInternally()
protected void
recordError(String sourceMimetype, String targetMimetype, long transformationTime)
          Records an error and updates the average time as if the transformation took a long time, so that it is less likely to be called again.
protected void
recordTime(long transformationTime)
          Deprecated. use method with mimetypes.
protected void
recordTime(String sourceMimetype, String targetMimetype, long transformationTime)
          Records and updates the average transformation time for this transformer.
void
register()
          Registers this instance with the registry if it is present.
void
setAdditionalThreadTimout(long additionalThreadTimout)
void
setExecutorService(ExecutorService executorService)
          Sets the ExecutorService to be used for timeout-aware transformation.
void
setMetadataExtracterConfig(org.alfresco.repo.content.metadata.MetadataExtracterConfig metadataExtracterConfig)
          The metadata extracter config.
void
setRegisterTransformer(boolean registerTransformer)
void
setRegistry(ContentTransformerRegistry registry)
          The registry to auto-register with
void
setRetryTransformOnDifferentMimeType(boolean retryTransformOnDifferentMimeType)
void
setStrictMimeTypeCheck(boolean strictMimeTypeCheck)
void
setUseTimeoutThread(Boolean useTimeoutThread)
toString()
void
transform(ContentReader reader, ContentWriter writer)
void
transform(ContentReader reader, ContentWriter writer, Map<String,Object> options)
          Transforms the content provided by the reader and source mimetype to the writer and target mimetype.
void
transform(ContentReader reader, ContentWriter writer, TransformationOptions options)
          Transforms the content provided by the reader and source mimetype to the writer and target mimetype with the provided transformation options.
protected abstract void
transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options)
          Method to be implemented by subclasses wishing to make use of the common infrastructural code provided by this class.
Methods inherited from class org.alfresco.repo.content.transform.AbstractContentTransformerLimits
getLimits, getLimits, getLimits, getMaxPages, getMaxSourceSizeKBytes, getMaxSourceSizeKBytes, getPageLimit, getReadLimitKBytes, getReadLimitTimeMs, getTimeoutMs, isPageLimitSupported, isTransformable, isTransformable, isTransformableMimetype, isTransformableSize, setLimits, setMaxPages, setMaxSourceSizeKBytes, setMimetypeLimits, setPageLimit, setPageLimitsSupported, setReaderLimits, setReadLimitKBytes, setReadLimitTimeMs, setTimeoutMs, setTransformerDebug
Methods inherited from class org.alfresco.repo.content.transform.ContentTransformerHelper
deprecatedSetter, equals, getBeanName, getComments, getCommentsOnlySupports, getExtensionOrAny, getMimetype, getMimetypeService, getName, getSimpleName, hashCode, isExplicitTransformation, isSupportedTransformation, onlySupports, setBeanName, setExplicitTransformations, setMimetypeService, setSupportedTransformations, setTransformerConfig, setUnsupportedTransformations
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.alfresco.repo.content.transform.ContentTransformer
getComments, getName, isExplicitTransformation
Constructor Detail
AbstractContentTransformer2
protected AbstractContentTransformer2()
All transformers start with an average transformation time of 0.0 ms, unless there is an Alfresco global property <beanName>.time. May also be set for given combinations of source and target mimetypes.
Method Detail
setRegistry
public void setRegistry(ContentTransformerRegistry registry)
The registry to auto-register with
Parameters:
registry - the transformer registry

setMetadataExtracterConfig
public void setMetadataExtracterConfig(org.alfresco.repo.content.metadata.MetadataExtracterConfig metadataExtracterConfig)
The metadata extracter config.

setRegisterTransformer
public void setRegisterTransformer(boolean registerTransformer)
Parameters:
registerTransformer - as been available for selection. If false this indicates that the transformer may only be used as part of another transformer.

toString
public String toString()
Overrides:
toString in class ContentTransformerHelper

register
public void register()
Registers this instance with the registry if it is present. THIS IS A CUSTOM SPRING INIT METHOD
Overrides:
register in class ContentTransformerHelper

checkTransformable
protected void checkTransformable(ContentReader reader,
                                  ContentWriter writer,
                                  TransformationOptions options)
Convenience method to check the transformability of a transformation
Parameters:
reader - content reader
writer - content writer
options - transformation options
Throws:
AlfrescoRuntimeException - if the the transformation isn't supported

transformInternal
protected abstract void transformInternal(ContentReader reader,
                                          ContentWriter writer,
                                          TransformationOptions options)
                                   throws Exception
Method to be implemented by subclasses wishing to make use of the common infrastructural code provided by this class.
Parameters:
reader - the source of the content to transform
writer - the target to which to write the transformed content
options - a map of options to use when performing the transformation. The map will never be null.
Throws:
Exception - exceptions will be handled by this class - subclasses can throw anything

transform
public final void transform(ContentReader reader,
                            ContentWriter writer)
                     throws ContentIOException
Specified by:
transform in interface ContentTransformer
Throws:
ContentIOException
See Also:
transform(ContentReader, ContentWriter, Map), transformInternal(ContentReader, ContentWriter, TransformationOptions)

transform
public final void transform(ContentReader reader,
                            ContentWriter writer,
                            TransformationOptions options)
                     throws ContentIOException
Description copied from interface: ContentTransformer
Transforms the content provided by the reader and source mimetype to the writer and target mimetype with the provided transformation options.

The transformation viability can be determined by an up front call to ContentTransformer.isTransformable(String, String, TransformationOptions).

The source and target mimetypes must be available on the ContentAccessor.getMimetype() methods of both the reader and the writer.

Both reader and writer will be closed after the transformation completes.

The provided options can be null.

Specified by:
transform in interface ContentTransformer
Parameters:
reader - the source of the content
options - transformation options, these can be null
Throws:
ContentIOException - if an IO exception occurs
See Also:
ContentTransformer.transform(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions)

transform
public final void transform(ContentReader reader,
                            ContentWriter writer,
                            Map<String,Object> options)
                     throws ContentIOException
Description copied from interface: ContentTransformer
Transforms the content provided by the reader and source mimetype to the writer and target mimetype.

The source and target mimetypes must be available on the ContentAccessor.getMimetype() methods of both the reader and the writer.

Both reader and writer will be closed after the transformation completes.

Specified by:
transform in interface ContentTransformer
Parameters:
reader - the source of the content
writer - the destination of the transformed content
options - options to pass to the transformer. These are transformer dependent and may be null.
Throws:
ContentIOException - if an IO exception occurs

getTransformationTime
public long getTransformationTime()
Specified by:
getTransformationTime in interface ContentTransformer
Returns:
Returns the calculated running average of the current transformations

getTransformationTime
public long getTransformationTime(String sourceMimetype,
                                  String targetMimetype)
Description copied from interface: ContentTransformer
Provides an estimate, usually a worst case guess, of how long a transformation will take. Null mimetype values provide the overall value for the transformer.

This method is used to determine, up front, which of a set of equally reliant transformers will be used for a specific transformation.

Specified by:
getTransformationTime in interface ContentTransformer
Parameters:
sourceMimetype - the source mimetype
targetMimetype - the target mimetype
Returns:
Returns the calculated running average of the current transformations

recordTime
protected final void recordTime(long transformationTime)
Deprecated. use method with mimetypes.

recordTime
protected final void recordTime(String sourceMimetype,
                                String targetMimetype,
                                long transformationTime)
Records and updates the average transformation time for this transformer.

Subclasses should call this after every transformation in order to keep the running average of the transformation times up to date.

This method is thread-safe. The time spent in this method is negligible so the impact will be minor.

Parameters:
sourceMimetype - String
targetMimetype - String
transformationTime - the time it took to perform the transformation.

getExecutorService
protected ExecutorService getExecutorService()
Gets the ExecutorService to be used for timeout-aware extraction.

If no ExecutorService has been defined a default of Executors.newCachedThreadPool() is used during AbstractMappingMetadataExtracter.init().

Returns:
the defined or default ExecutorService

setExecutorService
public void setExecutorService(ExecutorService executorService)
Sets the ExecutorService to be used for timeout-aware transformation.
Parameters:
executorService - - ExecutorService instance for timeouts

setUseTimeoutThread
public void setUseTimeoutThread(Boolean useTimeoutThread)
Parameters:
useTimeoutThread - - Boolean value which specifies timeout limiting mechanism for the current transformer
See Also:
useTimeoutThread

setAdditionalThreadTimout
public void setAdditionalThreadTimout(long additionalThreadTimout)

isTransformationLimitedInternally
public Boolean isTransformationLimitedInternally()

recordError
protected final void recordError(String sourceMimetype,
                                 String targetMimetype,
                                 long transformationTime)
Records an error and updates the average time as if the transformation took a long time, so that it is less likely to be called again.
Parameters:
sourceMimetype - String
targetMimetype - String
transformationTime - the time it took to perform the transformation.

getRetryTransformOnDifferentMimeType
public Object getRetryTransformOnDifferentMimeType()

setRetryTransformOnDifferentMimeType
public void setRetryTransformOnDifferentMimeType(boolean retryTransformOnDifferentMimeType)

getStrictMimeTypeCheck
public boolean getStrictMimeTypeCheck()

setStrictMimeTypeCheck
public void setStrictMimeTypeCheck(boolean strictMimeTypeCheck)

Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005–2018 Alfresco Software. All rights reserved.

Java API documentation generated with DocFlex/Javadoc 1.6.1 using JavadocPro template set.