Class OperationServiceImpl
java.lang.Object
org.nuxeo.ecm.automation.core.impl.OperationServiceImpl
- All Implemented Interfaces:
AutomationAdmin,AutomationService
The operation registry is thread safe and optimized for modifications at startup and lookups at runtime.
- Author:
- Bogdan Stefanescu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AdapterKeyedRegistryAdapter registry.protected final AutomationFilterRegistryprotected final ChainExceptionRegistryprotected final OperationChainCompilerstatic final Stringprotected final OperationTypeRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompileChain(Class<?> inputType, OperationChain chain) Builds the operation chain given a context.compileChain(Class<?> inputType, OperationParameters... ops) Same as previous but takes an array of operation parametersvoidFlush compiled chains to handle hot-reload<T> TgetAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType) Adapts an object to a target type if possible otherwise throws an exception.protected CatchChainExceptiongetCatchChainExceptionByPriority(CatchChainException catchChainException, CatchChainException catchChainExceptionItem) getChainException(String onChainId) protected StringgetChainExceptionToRun(OperationContext ctx, String operationTypeId, OperationException oe) Generates a documentation model for all registered operations.getOperation(String id) Gets an operation type given its ID.protected OperationChainGets all operation types that was registered.getTypeAdapter(Class<?> accept, Class<?> produce) Gets a type adapter for the input type accept and the output type produce.static Class<?>getTypeForPrimitive(Class<?> primitiveType) booleanhasChainException(String onChainId) booleanhasOperation(String id) booleanisTypeAdaptable(Class<?> typeToAdapt, Class<?> targetType) Checks whether or not the given type is adaptable into the target type.voidputAutomationFilter(AutomationFilter automationFilter) voidputChainException(ChainException exceptionChain) voidputOperation(Class<?> type) Registers an operation given its class.voidputOperation(Class<?> type, boolean replace) Registers an operation given its class.voidputOperation(Class<?> type, boolean replace, String contributingComponent) Registers an operation given its class.voidputOperation(Class<?> type, boolean replace, String contributingComponent, List<WidgetDefinition> widgetDefinitionList) voidputOperation(OperationType op, boolean replace) Registers an operation given it's type.voidputTypeAdapter(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.voidremoveAutomationFilter(AutomationFilter automationFilter) voidremoveExceptionChain(ChainException exceptionChain) voidremoveOperation(Class<?> key) Removes an operation given its class.voidremoveOperation(OperationType type) Removes an operation given it's type.voidremoveTypeAdapter(Class<?> accept, Class<?> produce) Removes a type adapterrun(OperationContext ctx, String operationId) Same as previous but for managed chains identified by an ID.run(OperationContext ctx, String operationId, Map<String, ?> args) Shortcut to execute a single operation described by the given ID and map of parametersrun(OperationContext ctx, OperationChain chain) Builds and runs the operation chain given a context.runInNewTx(OperationContext ctx, String chainId, Map<String, ?> chainParameters, Integer timeout, boolean rollbackGlobalOnError) This running method execute operation process through a new transaction.static OperationParameters[]
-
Field Details
-
EXPORT_ALIASES_CONFIGURATION_PARAM
- See Also:
-
operations
-
chainExceptionRegistry
-
automationFilterRegistry
-
compiler
-
adapters
Adapter registry.
-
-
Constructor Details
-
OperationServiceImpl
public OperationServiceImpl()
-
-
Method Details
-
run
Description copied from interface:AutomationServiceSame as previous but for managed chains identified by an ID. For managed chains always use this method since the compiled chain is cached and run will be faster- Specified by:
runin interfaceAutomationService- Throws:
OperationException
-
run
public Object run(OperationContext ctx, String operationId, Map<String, ?> args) throws OperationExceptionDescription copied from interface:AutomationServiceShortcut to execute a single operation described by the given ID and map of parameters- Specified by:
runin interfaceAutomationService- Throws:
OperationException
-
run
Description copied from interface:AutomationServiceBuilds and runs the operation chain given a context. If the context input object or the chain cannot be resolved (no path can be found through all the operation in the chain) thenInvalidChainExceptionis thrown.- Specified by:
runin interfaceAutomationService- Throws:
OperationException
-
runInNewTx
public Object runInNewTx(OperationContext ctx, String chainId, Map<String, ?> chainParameters, Integer timeout, boolean rollbackGlobalOnError) throws OperationExceptionDescription copied from interface:AutomationServiceThis running method execute operation process through a new transaction.- Specified by:
runInNewTxin interfaceAutomationService- Parameters:
ctx- the operation context.chainId- the chain Id.chainParameters- chain parameters.timeout- Transaction timeout.rollbackGlobalOnError- Rollback or not transaction after failing.- Throws:
OperationException
-
getChainExceptionToRun
protected String getChainExceptionToRun(OperationContext ctx, String operationTypeId, OperationException oe) throws OperationException - Throws:
OperationException- Since:
- 5.7.3 Fetch the right chain id to run when catching exception for given chain failure.
-
getCatchChainExceptionByPriority
protected CatchChainException getCatchChainExceptionByPriority(CatchChainException catchChainException, CatchChainException catchChainExceptionItem) - Since:
- 5.7.3
-
toParams
-
getOperationChain
- Throws:
OperationNotFoundException
-
flushCompiledChains
public void flushCompiledChains()Description copied from interface:AutomationAdminFlush compiled chains to handle hot-reload- Specified by:
flushCompiledChainsin interfaceAutomationAdmin
-
putOperation
Description copied from interface:AutomationServiceRegisters an operation given its class. The operation class MUST be annotated usingOperationannotation. If an operation having the same ID exists an exception will be thrown.- Specified by:
putOperationin interfaceAutomationService- Throws:
OperationException
-
putOperation
Description copied from interface:AutomationServiceRegisters an operation given its class. The operation class MUST be annotated usingOperationannotation. If thereplaceargument is true then any existing operation having the same ID will replaced with this one.- Specified by:
putOperationin interfaceAutomationService- Throws:
OperationException
-
putOperation
public void putOperation(Class<?> type, boolean replace, String contributingComponent) throws OperationException Description copied from interface:AutomationServiceRegisters an operation given its class. The operation class MUST be annotated usingOperationannotation. If thereplaceargument 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 operation- Specified by:
putOperationin interfaceAutomationService- Throws:
OperationException
-
putOperation
public void putOperation(Class<?> type, boolean replace, String contributingComponent, List<WidgetDefinition> widgetDefinitionList) throws OperationException - Specified by:
putOperationin interfaceAutomationService- Throws:
OperationException
-
putOperation
Description copied from interface:AutomationServiceRegisters an operation given it's type.- Specified by:
putOperationin interfaceAutomationService- Throws:
OperationException
-
removeOperation
Description copied from interface:AutomationServiceRemoves an operation given its class. If the operation was not registered does nothing.- Specified by:
removeOperationin interfaceAutomationService
-
removeOperation
Description copied from interface:AutomationServiceRemoves an operation given it's type. If the operation was not registered does nothing.- Specified by:
removeOperationin interfaceAutomationService
-
getOperations
Description copied from interface:AutomationServiceGets all operation types that was registered.- Specified by:
getOperationsin interfaceAutomationService
-
getOperation
Description copied from interface:AutomationServiceGets an operation type given its ID. Throws an exception if the operation is not found.- Specified by:
getOperationin interfaceAutomationService- Throws:
OperationNotFoundException
-
hasOperation
- Specified by:
hasOperationin interfaceAutomationService- Parameters:
id- operation ID.- Returns:
- true if operation registry contains the given operation.
- Since:
- 5.7.2
-
compileChain
public CompiledChain compileChain(Class<?> inputType, OperationParameters... ops) throws OperationException Description copied from interface:AutomationServiceSame as previous but takes an array of operation parameters- Specified by:
compileChainin interfaceAutomationService- Throws:
OperationException
-
compileChain
public CompiledChain compileChain(Class<?> inputType, OperationChain chain) throws OperationException Description copied from interface:AutomationServiceBuilds the operation chain given a context. If the context input object or the chain cannot be resolved (no path can be found through all the operation in the chain) thenInvalidChainExceptionis thrown. The returned object can be used to run the chain.- Specified by:
compileChainin interfaceAutomationService- Throws:
OperationException
-
putTypeAdapter
Description copied from interface:AutomationServiceRegisters a new type adapter that can adapt an instance of the accepted type into one of the produced type.- Specified by:
putTypeAdapterin interfaceAutomationService
-
removeTypeAdapter
Description copied from interface:AutomationServiceRemoves a type adapter- Specified by:
removeTypeAdapterin interfaceAutomationService
-
getTypeAdapter
Description copied from interface:AutomationServiceGets a type adapter for the input type accept and the output type produce. Returns null if no adapter was registered for these types.- Specified by:
getTypeAdapterin interfaceAutomationService
-
isTypeAdaptable
Description copied from interface:AutomationServiceChecks whether or not the given type is adaptable into the target type. An instance of an adaptable type can be converted into an instance of the target type.This is a shortcut to
getTypeAdapter(typeToAdapt, targetType) != null- Specified by:
isTypeAdaptablein interfaceAutomationService
-
getAdaptedValue
public <T> T getAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType) throws OperationException Description copied from interface:AutomationServiceAdapts an object to a target type if possible otherwise throws an exception. The method must be called in an operation execution with a valid operation context.- Specified by:
getAdaptedValuein interfaceAutomationService- Throws:
OperationException
-
getDocumentation
Description copied from interface:AutomationServiceGenerates a documentation model for all registered operations. The documentation model is generated from operation annotations and can be used in UI tools to describe operations. The returned list is sorted using operation ID. Optional method.- Specified by:
getDocumentationin interfaceAutomationService- Throws:
OperationException
-
getTypeForPrimitive
-
putChainException
- Specified by:
putChainExceptionin interfaceAutomationService- Since:
- 5.7.3
-
removeExceptionChain
- Specified by:
removeExceptionChainin interfaceAutomationService- Since:
- 5.7.3
-
getChainExceptions
- Specified by:
getChainExceptionsin interfaceAutomationService- Since:
- 5.7.3
-
getChainException
- Specified by:
getChainExceptionin interfaceAutomationService- Since:
- 5.7.3
-
hasChainException
- Specified by:
hasChainExceptionin interfaceAutomationService- Since:
- 5.7.3
-
putAutomationFilter
- Specified by:
putAutomationFilterin interfaceAutomationService- Since:
- 5.7.3
-
removeAutomationFilter
- Specified by:
removeAutomationFilterin interfaceAutomationService- Since:
- 5.7.3
-
getAutomationFilter
- Specified by:
getAutomationFilterin interfaceAutomationService- Since:
- 5.7.3
-
getAutomationFilters
- Specified by:
getAutomationFiltersin interfaceAutomationService- Since:
- 5.7.3
-