public class OperationServiceImpl extends Object implements AutomationService, AutomationAdmin
| Modifier and Type | Class and Description |
|---|---|
protected static class |
OperationServiceImpl.CacheKey |
| Modifier and Type | Field and Description |
|---|---|
protected AdapterKeyedRegistry |
adapters
Adapter registry.
|
protected AutomationFilterRegistry |
automationFilterRegistry |
protected ChainExceptionRegistry |
chainExceptionRegistry |
protected Map<OperationServiceImpl.CacheKey,org.nuxeo.ecm.automation.core.impl.CompiledChainImpl> |
compiledChains |
protected OperationTypeRegistry |
operations |
| Constructor and Description |
|---|
OperationServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
CompiledChain |
compileChain(Class<?> inputType,
OperationChain chain)
Builds the operation chain given a context.
|
CompiledChain |
compileChain(Class<?> inputType,
OperationParameters... operations)
Same as previous but takes an array of operation parameters
|
void |
flushCompiledChains()
Flush compiled chains to handle hot-reload
|
<T> T |
getAdaptedValue(OperationContext ctx,
Object toAdapt,
Class<?> targetType)
Adapts an object to a target type if possible otherwise throws an exception.
|
AutomationFilter |
getAutomationFilter(String id) |
AutomationFilter[] |
getAutomationFilters() |
protected CatchChainException |
getCatchChainExceptionByPriority(CatchChainException catchChainException,
CatchChainException catchChainExceptionItem) |
ChainException |
getChainException(String onChainId) |
ChainException[] |
getChainExceptions() |
protected String |
getChainExceptionToRun(OperationContext ctx,
String operationTypeId,
OperationException oe) |
List<OperationDocumentation> |
getDocumentation()
Generates a documentation model for all registered operations.
|
OperationType |
getOperation(String id)
Gets an operation type given its ID.
|
OperationChain |
getOperationChain(String id)
Gets a registered operation chain.
|
List<OperationChain> |
getOperationChains()
Gets a list of all registered chains
|
OperationType[] |
getOperations()
Gets all operation types that was registered.
|
TypeAdapter |
getTypeAdapter(Class<?> accept,
Class<?> produce)
Gets a type adapter for the input type accept and the output type produce.
|
static Class<?> |
getTypeForPrimitive(Class<?> primitiveType) |
boolean |
hasChainException(String onChainId) |
boolean |
hasOperation(String id) |
boolean |
isTypeAdaptable(Class<?> typeToAdapt,
Class<?> targetType)
Checks whether or not the given type is adaptable into the target type.
|
void |
putAutomationFilter(AutomationFilter automationFilter) |
void |
putChainException(ChainException exceptionChain) |
void |
putOperation(Class<?> type)
Registers an operation given its class.
|
void |
putOperation(Class<?> type,
boolean replace)
Registers an operation given its class.
|
void |
putOperation(Class<?> type,
boolean replace,
String contributingComponent)
Registers an operation given its class.
|
void |
putOperation(Class<?> type,
boolean replace,
String contributingComponent,
List<WidgetDefinition> widgetDefinitionList) |
void |
putOperation(OperationType op,
boolean replace)
Registers an operation given it's type.
|
void |
putOperationChain(OperationChain chain)
Registers a parametrized operation chain.
|
void |
putOperationChain(OperationChain chain,
boolean replace)
Registers a parametrized operation chain.
|
void |
putTypeAdapter(Class<?> accept,
Class<?> produce,
TypeAdapter adapter)
Registers a new type adapter that can adapt an instance of the accepted type into one of the produced type.
|
void |
removeAutomationFilter(AutomationFilter automationFilter) |
void |
removeExceptionChain(ChainException exceptionChain) |
void |
removeOperation(Class<?> key)
Removes an operation given its class.
|
void |
removeOperation(OperationType type)
Removes an operation given it's type.
|
void |
removeOperationChain(String id)
Removes a registered operation chain given its ID.
|
void |
removeTypeAdapter(Class<?> accept,
Class<?> produce)
Removes a type adapter
|
Object |
run(OperationContext ctx,
OperationChain chain)
Builds and runs the operation chain given a context.
|
Object |
run(OperationContext ctx,
OperationType operationType,
Map<String,Object> params) |
Object |
run(OperationContext ctx,
String operationId)
Same as previous but for managed chains identified by an ID.
|
Object |
run(OperationContext ctx,
String operationId,
Map<String,Object> runtimeParameters)
TODO avoid creating a temporary chain and then compile it.
|
Object |
runInNewTx(OperationContext ctx,
String chainId,
Map chainParameters,
Integer timeout,
boolean rollbackGlobalOnError)
This running method execute operation process through a new transaction.
|
static OperationParameters[] |
toParams(String... ids) |
protected final OperationTypeRegistry operations
protected final ChainExceptionRegistry chainExceptionRegistry
protected final AutomationFilterRegistry automationFilterRegistry
protected Map<OperationServiceImpl.CacheKey,org.nuxeo.ecm.automation.core.impl.CompiledChainImpl> compiledChains
protected AdapterKeyedRegistry adapters
public OperationServiceImpl()
public Object run(OperationContext ctx, String operationId) throws OperationException
AutomationServicerun in interface AutomationServiceOperationExceptionpublic Object run(OperationContext ctx, OperationChain chain) throws OperationException
AutomationServiceInvalidChainException is thrown.run in interface AutomationServiceOperationExceptionpublic Object run(OperationContext ctx, String operationId, Map<String,Object> runtimeParameters) throws OperationException
run in interface AutomationServiceOperationExceptionpublic Object runInNewTx(OperationContext ctx, String chainId, Map chainParameters, Integer timeout, boolean rollbackGlobalOnError) throws OperationException
runInNewTx in interface AutomationServicectx - the operation context.chainId - the chain Id.chainParameters - chain parameters.timeout - Transaction timeout.rollbackGlobalOnError - Rollback or not transaction after failing.OperationExceptionpublic Object run(OperationContext ctx, OperationType operationType, Map<String,Object> params) throws OperationException
ctx - the operation context.operationType - a chain or an operation.params - The chain parameters.OperationExceptionprotected String getChainExceptionToRun(OperationContext ctx, String operationTypeId, OperationException oe) throws OperationException
OperationExceptionprotected CatchChainException getCatchChainExceptionByPriority(CatchChainException catchChainException, CatchChainException catchChainExceptionItem)
public static OperationParameters[] toParams(String... ids)
public void putOperationChain(OperationChain chain) throws OperationException
AutomationServicerun and passing the chain ID. If a chain
having the same ID exists an exception is thrownputOperationChain in interface AutomationServiceOperationExceptionpublic void putOperationChain(OperationChain chain, boolean replace) throws OperationException
AutomationServicerun and passing the chain ID. If the
replace attribute is true then any chain already registered under the
same id will be replaced otherwise an exception is thrown.putOperationChain in interface AutomationServiceOperationExceptionpublic void removeOperationChain(String id)
AutomationServiceremoveOperationChain in interface AutomationServicepublic OperationChain getOperationChain(String id) throws OperationNotFoundException
AutomationServicegetOperationChain in interface AutomationServiceOperationNotFoundExceptionpublic List<OperationChain> getOperationChains()
AutomationServicegetOperationChains in interface AutomationServicepublic void flushCompiledChains()
AutomationAdminflushCompiledChains in interface AutomationAdminpublic void putOperation(Class<?> type) throws OperationException
AutomationServiceOperation annotation.
If an operation having the same ID exists an exception will be thrown.putOperation in interface AutomationServiceOperationExceptionpublic void putOperation(Class<?> type, boolean replace) throws OperationException
AutomationServiceOperation annotation.
If the replace argument is true then any existing operation having the same ID will replaced with
this one.putOperation in interface AutomationServiceOperationExceptionpublic void putOperation(Class<?> type, boolean replace, String contributingComponent) throws OperationException
AutomationServiceOperation annotation.
If the replace argument is true then any existing operation having the same ID will replaced with
this one. Third argument represents the name of the component registring the operationputOperation in interface AutomationServiceOperationExceptionpublic void putOperation(Class<?> type, boolean replace, String contributingComponent, List<WidgetDefinition> widgetDefinitionList) throws OperationException
putOperation in interface AutomationServiceOperationExceptionpublic void putOperation(OperationType op, boolean replace) throws OperationException
AutomationServiceputOperation in interface AutomationServiceOperationExceptionpublic void removeOperation(Class<?> key)
AutomationServiceremoveOperation in interface AutomationServicepublic void removeOperation(OperationType type)
AutomationServiceremoveOperation in interface AutomationServicepublic OperationType[] getOperations()
AutomationServicegetOperations in interface AutomationServicepublic OperationType getOperation(String id) throws OperationNotFoundException
AutomationServicegetOperation in interface AutomationServiceOperationNotFoundExceptionpublic boolean hasOperation(String id)
hasOperation in interface AutomationServiceid - operation ID.public CompiledChain compileChain(Class<?> inputType, OperationChain chain) throws OperationException
AutomationServiceInvalidChainException is thrown. The returned
object can be used to run the chain.compileChain in interface AutomationServiceOperationExceptionpublic CompiledChain compileChain(Class<?> inputType, OperationParameters... operations) throws OperationException
AutomationServicecompileChain in interface AutomationServiceOperationExceptionpublic void putTypeAdapter(Class<?> accept, Class<?> produce, TypeAdapter adapter)
AutomationServiceputTypeAdapter in interface AutomationServicepublic void removeTypeAdapter(Class<?> accept, Class<?> produce)
AutomationServiceremoveTypeAdapter in interface AutomationServicepublic TypeAdapter getTypeAdapter(Class<?> accept, Class<?> produce)
AutomationServicegetTypeAdapter in interface AutomationServicepublic boolean isTypeAdaptable(Class<?> typeToAdapt, Class<?> targetType)
AutomationService
This is a shortcut to getTypeAdapter(typeToAdapt, targetType) != null
isTypeAdaptable in interface AutomationServicepublic <T> T getAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType) throws OperationException
AutomationServicegetAdaptedValue in interface AutomationServiceOperationExceptionpublic List<OperationDocumentation> getDocumentation() throws OperationException
AutomationServicegetDocumentation in interface AutomationServiceOperationExceptionpublic static Class<?> getTypeForPrimitive(Class<?> primitiveType)
public void putChainException(ChainException exceptionChain)
putChainException in interface AutomationServicepublic void removeExceptionChain(ChainException exceptionChain)
removeExceptionChain in interface AutomationServicepublic ChainException[] getChainExceptions()
getChainExceptions in interface AutomationServicepublic ChainException getChainException(String onChainId)
getChainException in interface AutomationServicepublic boolean hasChainException(String onChainId)
hasChainException in interface AutomationServicepublic void putAutomationFilter(AutomationFilter automationFilter)
putAutomationFilter in interface AutomationServicepublic void removeAutomationFilter(AutomationFilter automationFilter)
removeAutomationFilter in interface AutomationServicepublic AutomationFilter getAutomationFilter(String id)
getAutomationFilter in interface AutomationServicepublic AutomationFilter[] getAutomationFilters()
getAutomationFilters in interface AutomationServiceCopyright © 2015 Nuxeo SA. All rights reserved.