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
AutomationService
run
in interface AutomationService
OperationException
public Object run(OperationContext ctx, OperationChain chain) throws OperationException
AutomationService
InvalidChainException
is thrown.run
in interface AutomationService
OperationException
public Object run(OperationContext ctx, String operationId, Map<String,Object> runtimeParameters) throws OperationException
run
in interface AutomationService
OperationException
public Object runInNewTx(OperationContext ctx, String chainId, Map chainParameters, Integer timeout, boolean rollbackGlobalOnError) throws OperationException
runInNewTx
in interface AutomationService
ctx
- the operation context.chainId
- the chain Id.chainParameters
- chain parameters.timeout
- Transaction timeout.rollbackGlobalOnError
- Rollback or not transaction after failing.OperationException
public 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.OperationException
protected String getChainExceptionToRun(OperationContext ctx, String operationTypeId, OperationException oe) throws OperationException
OperationException
protected CatchChainException getCatchChainExceptionByPriority(CatchChainException catchChainException, CatchChainException catchChainExceptionItem)
public static OperationParameters[] toParams(String... ids)
public void putOperationChain(OperationChain chain) throws OperationException
AutomationService
run
and passing the chain ID. If a chain
having the same ID exists an exception is thrownputOperationChain
in interface AutomationService
OperationException
public void putOperationChain(OperationChain chain, boolean replace) throws OperationException
AutomationService
run
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 AutomationService
OperationException
public void removeOperationChain(String id)
AutomationService
removeOperationChain
in interface AutomationService
public OperationChain getOperationChain(String id) throws OperationNotFoundException
AutomationService
getOperationChain
in interface AutomationService
OperationNotFoundException
public List<OperationChain> getOperationChains()
AutomationService
getOperationChains
in interface AutomationService
public void flushCompiledChains()
AutomationAdmin
flushCompiledChains
in interface AutomationAdmin
public void putOperation(Class<?> type) throws OperationException
AutomationService
Operation
annotation.
If an operation having the same ID exists an exception will be thrown.putOperation
in interface AutomationService
OperationException
public void putOperation(Class<?> type, boolean replace) throws OperationException
AutomationService
Operation
annotation.
If the replace
argument is true then any existing operation having the same ID will replaced with
this one.putOperation
in interface AutomationService
OperationException
public void putOperation(Class<?> type, boolean replace, String contributingComponent) throws OperationException
AutomationService
Operation
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 AutomationService
OperationException
public void putOperation(Class<?> type, boolean replace, String contributingComponent, List<WidgetDefinition> widgetDefinitionList) throws OperationException
putOperation
in interface AutomationService
OperationException
public void putOperation(OperationType op, boolean replace) throws OperationException
AutomationService
putOperation
in interface AutomationService
OperationException
public void removeOperation(Class<?> key)
AutomationService
removeOperation
in interface AutomationService
public void removeOperation(OperationType type)
AutomationService
removeOperation
in interface AutomationService
public OperationType[] getOperations()
AutomationService
getOperations
in interface AutomationService
public OperationType getOperation(String id) throws OperationNotFoundException
AutomationService
getOperation
in interface AutomationService
OperationNotFoundException
public boolean hasOperation(String id)
hasOperation
in interface AutomationService
id
- operation ID.public CompiledChain compileChain(Class<?> inputType, OperationChain chain) throws OperationException
AutomationService
InvalidChainException
is thrown. The returned
object can be used to run the chain.compileChain
in interface AutomationService
OperationException
public CompiledChain compileChain(Class<?> inputType, OperationParameters... operations) throws OperationException
AutomationService
compileChain
in interface AutomationService
OperationException
public void putTypeAdapter(Class<?> accept, Class<?> produce, TypeAdapter adapter)
AutomationService
putTypeAdapter
in interface AutomationService
public void removeTypeAdapter(Class<?> accept, Class<?> produce)
AutomationService
removeTypeAdapter
in interface AutomationService
public TypeAdapter getTypeAdapter(Class<?> accept, Class<?> produce)
AutomationService
getTypeAdapter
in interface AutomationService
public boolean isTypeAdaptable(Class<?> typeToAdapt, Class<?> targetType)
AutomationService
This is a shortcut to getTypeAdapter(typeToAdapt, targetType) != null
isTypeAdaptable
in interface AutomationService
public <T> T getAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType) throws OperationException
AutomationService
getAdaptedValue
in interface AutomationService
OperationException
public List<OperationDocumentation> getDocumentation() throws OperationException
AutomationService
getDocumentation
in interface AutomationService
OperationException
public static Class<?> getTypeForPrimitive(Class<?> primitiveType)
public void putChainException(ChainException exceptionChain)
putChainException
in interface AutomationService
public void removeExceptionChain(ChainException exceptionChain)
removeExceptionChain
in interface AutomationService
public ChainException[] getChainExceptions()
getChainExceptions
in interface AutomationService
public ChainException getChainException(String onChainId)
getChainException
in interface AutomationService
public boolean hasChainException(String onChainId)
hasChainException
in interface AutomationService
public void putAutomationFilter(AutomationFilter automationFilter)
putAutomationFilter
in interface AutomationService
public void removeAutomationFilter(AutomationFilter automationFilter)
removeAutomationFilter
in interface AutomationService
public AutomationFilter getAutomationFilter(String id)
getAutomationFilter
in interface AutomationService
public AutomationFilter[] getAutomationFilters()
getAutomationFilters
in interface AutomationService
Copyright © 2016 Nuxeo SA. All rights reserved.