public class ConversionServiceImpl extends DefaultComponent implements ConversionService
ConversionService
.Modifier and Type | Field and Description |
---|---|
protected Map<String,ConverterCheckResult> |
checkResultCache |
protected GlobalConfigDescriptor |
config |
static String |
CONFIG_EP |
static String |
CONVERTER_EP |
protected Map<String,ConverterDescriptor> |
converterDescriptors |
protected Thread |
gcThread |
protected static org.apache.commons.logging.Log |
log |
protected static ConversionServiceImpl |
self |
protected MimeTypeTranslationHelper |
translationHelper |
lastModified
Constructor and Description |
---|
ConversionServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
activate(ComponentContext context)
Activates the component.
|
void |
applicationStarted(ComponentContext context)
Notify the component that Nuxeo Framework finished starting all Nuxeo bundles.
|
BlobHolder |
convert(String converterName,
BlobHolder blobHolder,
Map<String,Serializable> parameters)
Converts a Blob given a converter name.
|
BlobHolder |
convertToMimeType(String destinationMimeType,
BlobHolder blobHolder,
Map<String,Serializable> parameters)
Converts a Blob given a target destination MimeType.
|
void |
deactivate(ComponentContext context)
Deactivates the component.
|
void |
endGC() |
<T> T |
getAdapter(Class<T> adapter)
Returns an object which is an instance of the given class associated with this object.
|
static String |
getCacheBasePath() |
BlobHolder |
getConversionResult(String id,
boolean cleanTransientStoreEntry)
Returns the conversion result for the given
id if any, null otherwise. |
ConversionStatus |
getConversionStatus(String id)
Returns the status of a scheduled conversion given its
id , or null if no conversion scheduled. |
static Converter |
getConverter(String converterName) |
static ConverterDescriptor |
getConverterDescriptor(String converterName) |
String |
getConverterName(String sourceMimeType,
String destinationMimeType)
Gets the convertName given a source and destination MimeType.
|
List<String> |
getConverterNames(String sourceMimeType,
String destinationMimeType)
Gets the available convertNames given a source and destination MimeType.
|
static long |
getGCIntervalInMinutes() |
static int |
getMaxCacheSizeInKB() |
List<String> |
getRegistredConverters()
Returns the names of the registered converters.
|
static boolean |
isCacheEnabled() |
ConverterCheckResult |
isConverterAvailable(String converterName)
Checks for converter availability.
|
ConverterCheckResult |
isConverterAvailable(String converterName,
boolean refresh)
Checks for converter availability.
|
boolean |
isSourceMimeTypeSupported(String converterName,
String sourceMimeType)
Returns true if the converter supports the given
sourceMimeType , false otherwise. |
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor)
Component implementation.
|
static void |
registerConverter(ConverterDescriptor desc) |
String |
scheduleConversion(String converterName,
BlobHolder blobHolder,
Map<String,Serializable> parameters)
Schedules a conversion given a converter name.
|
String |
scheduleConversionToMimeType(String destinationMimeType,
BlobHolder blobHolder,
Map<String,Serializable> parameters)
Schedules a conversion given a target mime type.
|
static void |
setGCIntervalInMinutes(long interval) |
static void |
setMaxCacheSizeInKB(int size) |
protected void |
startGC() |
void |
unregisterContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
protected void |
updateResultBlobFileName(BlobHolder srcBh,
BlobHolder resultBh) |
protected void |
updateResultBlobMimeType(BlobHolder resultBh,
ConverterDescriptor desc) |
getApplicationStartedOrder, getLastModified, registerExtension, setLastModified, setModifiedNow, unregisterExtension
protected static final org.apache.commons.logging.Log log
public static final String CONVERTER_EP
public static final String CONFIG_EP
protected final Map<String,ConverterDescriptor> converterDescriptors
protected final MimeTypeTranslationHelper translationHelper
protected final GlobalConfigDescriptor config
protected static ConversionServiceImpl self
protected final Map<String,ConverterCheckResult> checkResultCache
public ConversionServiceImpl()
public void activate(ComponentContext context)
Component
This method is called by the runtime when a component is activated.
activate
in interface Component
activate
in class DefaultComponent
context
- the runtime contextpublic void deactivate(ComponentContext context)
Component
This method is called by the runtime when a component is deactivated.
deactivate
in interface Component
deactivate
in class DefaultComponent
context
- the runtime contextpublic void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
registerContribution
in class DefaultComponent
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
unregisterContribution
in class DefaultComponent
public static Converter getConverter(String converterName)
public static ConverterDescriptor getConverterDescriptor(String converterName)
public static long getGCIntervalInMinutes()
public static void setGCIntervalInMinutes(long interval)
public static void registerConverter(ConverterDescriptor desc)
public static int getMaxCacheSizeInKB()
public static void setMaxCacheSizeInKB(int size)
public static boolean isCacheEnabled()
public static String getCacheBasePath()
public List<String> getRegistredConverters()
ConversionService
getRegistredConverters
in interface ConversionService
public BlobHolder convert(String converterName, BlobHolder blobHolder, Map<String,Serializable> parameters) throws ConversionException
ConversionService
convert
in interface ConversionService
ConversionException
protected void updateResultBlobMimeType(BlobHolder resultBh, ConverterDescriptor desc)
protected void updateResultBlobFileName(BlobHolder srcBh, BlobHolder resultBh)
public BlobHolder convertToMimeType(String destinationMimeType, BlobHolder blobHolder, Map<String,Serializable> parameters) throws ConversionException
ConversionService
convertToMimeType
in interface ConversionService
ConversionException
public List<String> getConverterNames(String sourceMimeType, String destinationMimeType)
ConversionService
getConverterNames
in interface ConversionService
public String getConverterName(String sourceMimeType, String destinationMimeType)
ConversionService
getConverterName
in interface ConversionService
public ConverterCheckResult isConverterAvailable(String converterName) throws ConversionException
ConversionService
Result can be:
ConverterNotRegistered
if converter is not registered.
Result can be taken from an internal cache.
isConverterAvailable
in interface ConversionService
ConversionException
public ConverterCheckResult isConverterAvailable(String converterName, boolean refresh) throws ConverterNotRegistered
ConversionService
Result can be:
ConverterNotRegistered
if converter is not registered.
isConverterAvailable
in interface ConversionService
ConverterNotRegistered
public boolean isSourceMimeTypeSupported(String converterName, String sourceMimeType)
ConversionService
sourceMimeType
, false otherwise.isSourceMimeTypeSupported
in interface ConversionService
public String scheduleConversion(String converterName, BlobHolder blobHolder, Map<String,Serializable> parameters)
ConversionService
Returns a conversion id to be used by ConversionService.getConversionResult(String, boolean)
.
scheduleConversion
in interface ConversionService
public String scheduleConversionToMimeType(String destinationMimeType, BlobHolder blobHolder, Map<String,Serializable> parameters)
ConversionService
Returns a conversion id to be used by ConversionService.getConversionResult(String, boolean)
.
scheduleConversionToMimeType
in interface ConversionService
public ConversionStatus getConversionStatus(String id)
ConversionService
id
, or null
if no conversion scheduled.getConversionStatus
in interface ConversionService
public BlobHolder getConversionResult(String id, boolean cleanTransientStoreEntry)
ConversionService
id
if any, null
otherwise.getConversionResult
in interface ConversionService
public <T> T getAdapter(Class<T> adapter)
Adaptable
null
if no such object can be found.getAdapter
in interface Adaptable
getAdapter
in class DefaultComponent
adapter
- the adapter class to look upnull
if this object does not have an adapter for
the given classpublic void applicationStarted(ComponentContext context)
Component
applicationStarted
in interface Component
applicationStarted
in class DefaultComponent
protected void startGC()
public void endGC()
Copyright © 2015 Nuxeo SA. All rights reserved.