|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.content.transform.ContentTransformerHelper
org.alfresco.repo.content.transform.AbstractContentTransformer2
public abstract class AbstractContentTransformer2
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.
Constructor Summary | |
---|---|
protected |
AbstractContentTransformer2()
All transformers start with an average transformation time of 0.0ms. |
Method Summary | |
---|---|
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 |
long |
getTransformationTime()
Provides an estimate, usually a worst case guess, of how long a transformation will take. |
protected void |
recordTime(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 |
setRegistry(ContentTransformerRegistry registry)
The registry to auto-register with |
java.lang.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,
java.util.Map 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. |
Methods inherited from class org.alfresco.repo.content.transform.ContentTransformerHelper |
---|
getMimetype, getMimetypeService, isExplicitTransformation, setExplicitTransformations, setMimetypeService |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.alfresco.repo.content.transform.ContentTransformer |
---|
isExplicitTransformation, isTransformable |
Constructor Detail |
---|
protected AbstractContentTransformer2()
Method Detail |
---|
public void setRegistry(ContentTransformerRegistry registry)
registry
- the transformer registrypublic java.lang.String toString()
toString
in class java.lang.Object
public void register()
registry
if it is present.
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 options
org.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 java.lang.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.
java.lang.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
transform
in interface ContentTransformer
org.alfresco.service.cmr.repository.ContentIOException
AbstractContentTransformer2.transform(ContentReader, ContentWriter, Map)
,
#transformInternal(ContentReader, ContentWriter, Map)
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.
transform
in interface ContentTransformer
reader
- the source of the contentwriter
- the destination of the transformed contentoptions
- transformation options, these can be null
org.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, java.util.Map options) throws org.alfresco.service.cmr.repository.ContentIOException
ContentTransformer
The transformation viability can be determined by an up front call
to #getReliability(String, String)
.
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.
transform
in interface ContentTransformer
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()
ContentTransformer
This method is used to determine, up front, which of a set of equally reliant transformers will be used for a specific transformation.
getTransformationTime
in interface ContentTransformer
protected final void recordTime(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.
transformationTime
- the time it took to perform the transformation.
The value may be 0.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |