Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.automation
Interface AutomationService

All Known Implementing Classes:
OperationServiceImpl

public interface AutomationService

Service providing an operation registry and operation execution methods. The operation registry is thread-safe and optimized for lookups. Progress monitor for asynchronous executions is not yet implemented.

Author:
Bogdan Stefanescu

Method Summary
 CompiledChain compileChain(Class<?> inputType, OperationChain chain)
          Builds the operation chain given a context.
 CompiledChain compileChain(Class<?> inputType, OperationParameters... chain)
          Same as previous but takes an array of operation parameters
<T> T
getAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType)
          Adapts an object to a target type if possible otherwise throws an exception.
 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.
 boolean isTypeAdaptable(Class<?> typeToAdapt, Class<?> targetType)
          Checks whether or not the given type is adaptable into the target type.
 void putOperation(Class<?> type)
          Registers an operation given its class.
 void putOperation(Class<?> type, boolean replace)
          Registers an operation given its class.
 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 removeOperation(Class<?> key)
          Removes an operation given its class.
 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, String chainId)
          Same as previous but for managed chains identified by an ID.
 Object run(OperationContext ctx, String id, Map<String,Object> params)
          Shortcut to execute a single operation described by the given ID and map of parameters
 

Method Detail

putOperation

void putOperation(Class<?> type)
                  throws OperationException
Registers an operation given its class. The operation class MUST be annotated using Operation annotation. If an operation having the same ID exists an exception will be thrown.

Throws:
OperationException

putOperation

void putOperation(Class<?> type,
                  boolean replace)
                  throws OperationException
Registers an operation given its class. The operation class MUST be annotated using Operation annotation. If the replace argument is true then any existing operation having the same ID will replaced with this one.

Throws:
OperationException

removeOperation

void removeOperation(Class<?> key)
Removes an operation given its class. If the operation was not registered does nothing.


getOperations

OperationType[] getOperations()
Gets all operation types that was registered.


getOperation

OperationType getOperation(String id)
                           throws OperationNotFoundException
Gets an operation type given its ID. Throws an exception if the operation is not found.

Throws:
OperationNotFoundException

compileChain

CompiledChain compileChain(Class<?> inputType,
                           OperationChain chain)
                           throws Exception,
                                  InvalidChainException
Builds 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) then InvalidChainException is thrown. The returned object can be used to run the chain.

Throws:
Exception
InvalidChainException

compileChain

CompiledChain compileChain(Class<?> inputType,
                           OperationParameters... chain)
                           throws Exception,
                                  InvalidChainException
Same as previous but takes an array of operation parameters

Throws:
Exception
InvalidChainException

run

Object run(OperationContext ctx,
           OperationChain chain)
           throws OperationException,
                  InvalidChainException,
                  Exception
Builds 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) then InvalidChainException is thrown.

Throws:
OperationException
InvalidChainException
Exception

run

Object run(OperationContext ctx,
           String chainId)
           throws OperationException,
                  InvalidChainException,
                  Exception
Same 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

Throws:
OperationException
InvalidChainException
Exception

run

Object run(OperationContext ctx,
           String id,
           Map<String,Object> params)
           throws OperationException,
                  InvalidChainException,
                  Exception
Shortcut to execute a single operation described by the given ID and map of parameters

Throws:
OperationException
InvalidChainException
Exception

putOperationChain

void putOperationChain(OperationChain chain)
                       throws OperationException
Registers a parametrized operation chain. This chain can be executed later by calling run and passing the chain ID. If a chain having the same ID exists an exception is thrown

Throws:
OperationException

putOperationChain

void putOperationChain(OperationChain chain,
                       boolean replace)
                       throws OperationException
Registers a parametrized operation chain. This chain can be executed later by calling 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.

Throws:
OperationException

removeOperationChain

void removeOperationChain(String id)
Removes a registered operation chain given its ID. Do nothing if the chain was not registered.


getOperationChain

OperationChain getOperationChain(String id)
                                 throws OperationNotFoundException
Gets a registered operation chain.

Throws:
OperationNotFoundException

getOperationChains

List<OperationChain> getOperationChains()
Gets a list of all registered chains

Returns:
the list or an empty list if no registered chains exists

putTypeAdapter

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.


removeTypeAdapter

void removeTypeAdapter(Class<?> accept,
                       Class<?> produce)
Removes a type adapter


getTypeAdapter

TypeAdapter getTypeAdapter(Class<?> accept,
                           Class<?> produce)
Gets a type adapter for the input type accept and the output type produce. Returns null if no adapter was registered for these types.


getAdaptedValue

<T> T getAdaptedValue(OperationContext ctx,
                      Object toAdapt,
                      Class<?> targetType)
                  throws Exception
Adapts 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.

Throws:
Exception

isTypeAdaptable

boolean isTypeAdaptable(Class<?> typeToAdapt,
                        Class<?> targetType)
Checks 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


getDocumentation

List<OperationDocumentation> getDocumentation()
Generates 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.


Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.