|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.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(ContentReader reader,
ContentWriter writer,
TransformationOptions options)
Convenience method to check the transformability of a transformation |
protected java.lang.String |
getMimetype(ContentAccessor content)
Convenience to fetch and check the mimetype for the given content |
protected MimetypeService |
getMimetypeService()
|
long |
getTransformationTime()
Provides an estimate, usually a worst case guess, of how long a transformation will take. |
boolean |
isExplicitTransformation(java.lang.String sourceMimetype,
java.lang.String targetMimetype,
TransformationOptions options)
Default implementation, override if need to extend logic |
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 |
setExplicitTransformations(java.util.List explicitTransformations)
|
void |
setMimetypeService(MimetypeService mimetypeService)
Helper setter of the mimetype service. |
void |
setRegistry(ContentTransformerRegistry registry)
The registry to auto-register with |
java.lang.String |
toString()
|
void |
transform(ContentReader reader,
ContentWriter writer)
|
void |
transform(ContentReader reader,
ContentWriter writer,
java.util.Map 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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.alfresco.repo.content.transform.ContentTransformer |
|---|
isTransformable |
| Constructor Detail |
|---|
protected AbstractContentTransformer2()
| Method Detail |
|---|
public void setRegistry(ContentTransformerRegistry registry)
registry - the transformer registrypublic void setMimetypeService(MimetypeService mimetypeService)
mimetypeService - protected MimetypeService getMimetypeService()
public void setExplicitTransformations(java.util.List explicitTransformations)
public java.lang.String toString()
toString in class java.lang.Objectpublic void register()
registry
if it is present.
protected java.lang.String getMimetype(ContentAccessor content)
content - the reader/writer for the content
org.alfresco.error.AlfrescoRuntimeException - if the content doesn't have a mimetype
protected void checkTransformable(ContentReader reader,
ContentWriter writer,
TransformationOptions options)
reader - content readerwriter - content writeroptions - transformation options
org.alfresco.error.AlfrescoRuntimeException - if the the transformation isn't supported
protected abstract void transformInternal(ContentReader reader,
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 anything
public final void transform(ContentReader reader,
ContentWriter writer)
throws ContentIOException
transform in interface ContentTransformerContentIOExceptionAbstractContentTransformer2.transform(ContentReader, ContentWriter, Map),
#transformInternal(ContentReader, ContentWriter, Map)
public final void transform(ContentReader reader,
ContentWriter writer,
TransformationOptions options)
throws 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 ContentTransformerreader - the source of the contentwriter - the destination of the transformed contentoptions - transformation options, these can be null
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(ContentReader reader,
ContentWriter writer,
java.util.Map options)
throws 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 ContentTransformerreader - 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.
ContentIOException - if an IO exception occurs
public boolean isExplicitTransformation(java.lang.String sourceMimetype,
java.lang.String targetMimetype,
TransformationOptions options)
isExplicitTransformation in interface ContentTransformersourceMimetype - the source mimetypetargetMimetype - the target mimetypeoptions - the transformation options
ContentTransformer.isExplicitTransformation(java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions)public long getTransformationTime()
ContentTransformerThis 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 ContentTransformerprotected 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 | ||||||||