public class OperationServiceImpl extends Object implements AutomationService
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() |
<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() |
ChainException |
getChainException(String onChainId) |
ChainException[] |
getChainExceptions() |
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)
Deprecated.
|
List<OperationChain> |
getOperationChains()
Deprecated.
|
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(OperationType op,
boolean replace) |
void |
putOperationChain(OperationChain chain)
Deprecated.
|
void |
putOperationChain(OperationChain chain,
boolean replace)
Deprecated.
|
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 |
removeOperationChain(String id)
Deprecated.
|
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.
|
static OperationParameters[] |
toParams(String... ids) |
public Object run(OperationContext ctx, String operationId) throws Exception
AutomationService
run
in interface AutomationService
Exception
public Object run(OperationContext ctx, OperationChain chain) throws Exception
AutomationService
InvalidChainException
is thrown.run
in interface AutomationService
Exception
public Object run(OperationContext ctx, String operationId, Map<String,Object> runtimeParameters) throws Exception
run
in interface AutomationService
Exception
public Object run(OperationContext ctx, OperationType operationType, Map<String,Object> params) throws Exception
ctx
- the operation context.operationType
- a chain or an operation.params
- The chain parameters.Exception
public static OperationParameters[] toParams(String... ids)
@Deprecated public void putOperationChain(OperationChain chain) throws OperationException
putOperationChain
in interface AutomationService
OperationException
@Deprecated public void putOperationChain(OperationChain chain, boolean replace) throws OperationException
putOperationChain
in interface AutomationService
OperationException
@Deprecated public void removeOperationChain(String id)
removeOperationChain
in interface AutomationService
@Deprecated public OperationChain getOperationChain(String id) throws OperationNotFoundException
getOperationChain
in interface AutomationService
OperationNotFoundException
@Deprecated public List<OperationChain> getOperationChains()
getOperationChains
in interface AutomationService
public void flushCompiledChains()
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(OperationType op, boolean replace) throws OperationException
OperationException
public void removeOperation(Class<?> key)
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 Exception, InvalidChainException
AutomationService
InvalidChainException
is thrown.
The returned object can be used to run the chain.compileChain
in interface AutomationService
Exception
InvalidChainException
public CompiledChain compileChain(Class<?> inputType, OperationParameters... operations) throws Exception, InvalidChainException
AutomationService
compileChain
in interface AutomationService
Exception
InvalidChainException
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 Exception
AutomationService
getAdaptedValue
in interface AutomationService
Exception
public List<OperationDocumentation> getDocumentation() throws OperationException
AutomationService
getDocumentation
in interface AutomationService
OperationException
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 © 2013 Nuxeo SA. All Rights Reserved.