@AlfrescoPublicApi public abstract class AbstractContentTransformer2 extends AbstractContentTransformerLimits
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.
transformerDebug
transformerConfig
Modifier | Constructor and Description |
---|---|
protected |
AbstractContentTransformer2()
All transformers start with an average transformation time of 0.0 ms,
unless there is an Alfresco global property
<beanName>.time . |
Modifier and Type | Method and Description |
---|---|
protected void |
checkTransformable(org.alfresco.service.cmr.repository.ContentReader reader,
org.alfresco.service.cmr.repository.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. |
Object |
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.
|
Boolean |
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(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) |
String |
toString() |
void |
transform(org.alfresco.service.cmr.repository.ContentReader reader,
org.alfresco.service.cmr.repository.ContentWriter writer) |
void |
transform(org.alfresco.service.cmr.repository.ContentReader reader,
org.alfresco.service.cmr.repository.ContentWriter writer,
Map<String,Object> options)
Transforms the content provided by the reader and source mimetype
to the writer and target mimetype.
|
void |
transform(org.alfresco.service.cmr.repository.ContentReader reader,
org.alfresco.service.cmr.repository.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(org.alfresco.service.cmr.repository.ContentReader reader,
org.alfresco.service.cmr.repository.ContentWriter writer,
TransformationOptions options)
Method to be implemented by subclasses wishing to make use of the common infrastructural code
provided by this class.
|
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
deprecatedSetter, equals, getBeanName, getComments, getCommentsOnlySupports, getExtensionOrAny, getMimetype, getMimetypeService, getName, getSimpleName, hashCode, isExplicitTransformation, isSupportedTransformation, onlySupports, setBeanName, setExplicitTransformations, setMimetypeService, setSupportedTransformations, setTransformerConfig, setUnsupportedTransformations
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getComments, getName, isExplicitTransformation
protected AbstractContentTransformer2()
<beanName>.time
.
May also be set for given combinations of source and target mimetypes.public void setRegistry(ContentTransformerRegistry registry)
registry
- the transformer registrypublic void setMetadataExtracterConfig(MetadataExtracterConfig metadataExtracterConfig)
public void setRegisterTransformer(boolean registerTransformer)
registerTransformer
- as been available for selection.
If false
this indicates that the transformer may only be
used as part of another transformer.public String toString()
toString
in class ContentTransformerHelper
public void register()
registry
if it is present.
THIS IS A CUSTOM SPRING INIT METHODregister
in class ContentTransformerHelper
protected void checkTransformable(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options)
reader
- content readerwriter
- content writeroptions
- transformation optionsorg.alfresco.error.AlfrescoRuntimeException
- if the the transformation isn't supportedprotected abstract void transformInternal(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options) throws Exception
reader
- the source of the content to transformwriter
- the target to which to write the transformed contentoptions
- a map of options to use when performing the transformation. The map
will never be null.Exception
- exceptions will be handled by this class - subclasses can throw anythingpublic final void transform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer) throws org.alfresco.service.cmr.repository.ContentIOException
org.alfresco.service.cmr.repository.ContentIOException
transform(ContentReader, ContentWriter, Map)
,
transformInternal(ContentReader, ContentWriter, TransformationOptions)
public final void transform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options) throws org.alfresco.service.cmr.repository.ContentIOException
ContentTransformer
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.
reader
- the source of the contentwriter
- the destination of the transformed contentoptions
- transformation options, these can be nullorg.alfresco.service.cmr.repository.ContentIOException
- if an IO exception occursContentTransformer.transform(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions)
public final void transform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, Map<String,Object> options) throws org.alfresco.service.cmr.repository.ContentIOException
ContentTransformer
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.
reader
- the source of the contentwriter
- the destination of the transformed contentoptions
- options to pass to the transformer. These are transformer dependent
and may be null.org.alfresco.service.cmr.repository.ContentIOException
- if an IO exception occurspublic long getTransformationTime()
public long getTransformationTime(String sourceMimetype, String targetMimetype)
ContentTransformer
This method is used to determine, up front, which of a set of equally reliant transformers will be used for a specific transformation.
sourceMimetype
- the source mimetypetargetMimetype
- the target mimetypeprotected final void recordTime(long transformationTime)
protected final void recordTime(String sourceMimetype, String targetMimetype, long transformationTime)
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.
sourceMimetype
- StringtargetMimetype
- StringtransformationTime
- the time it took to perform the transformation.protected ExecutorService getExecutorService()
ExecutorService
to be used for timeout-aware extraction.
If no ExecutorService
has been defined a default of Executors.newCachedThreadPool()
is used during AbstractMappingMetadataExtracter.init()
.
ExecutorService
public void setExecutorService(ExecutorService executorService)
ExecutorService
to be used for timeout-aware transformation.executorService
- - ExecutorService
instance for timeoutspublic void setUseTimeoutThread(Boolean useTimeoutThread)
useTimeoutThread
- - Boolean
value which specifies timeout limiting mechanism for the current transformeruseTimeoutThread
public void setAdditionalThreadTimout(long additionalThreadTimout)
public Boolean isTransformationLimitedInternally()
protected final void recordError(String sourceMimetype, String targetMimetype, long transformationTime)
sourceMimetype
- StringtargetMimetype
- StringtransformationTime
- the time it took to perform the transformation.public Object getRetryTransformOnDifferentMimeType()
public void setRetryTransformOnDifferentMimeType(boolean retryTransformOnDifferentMimeType)
public boolean getStrictMimeTypeCheck()
public void setStrictMimeTypeCheck(boolean strictMimeTypeCheck)
Copyright © 2005–2017 Alfresco Software. All rights reserved.