Class ConnectorServiceImpl
- java.lang.Object
-
- org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl
-
- All Implemented Interfaces:
ConnectorService
public class ConnectorServiceImpl extends java.lang.Object implements ConnectorService
- Author:
- Baptiste Mesta, Yanyan Liu, Matthieu Chaffotte, Elias Ricken de Medeiros, Celine Souchet
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCONNECTOR_CACHE_NAME-
Fields inherited from interface org.bonitasoft.engine.core.connector.ConnectorService
DONE, FAILED, SKIPPED, TO_BE_EXECUTED, TO_RE_EXECUTE
-
-
Constructor Summary
Constructors Constructor Description ConnectorServiceImpl(CacheService cacheService, ConnectorExecutor connectorExecutor, ExpressionResolverService expressionResolverService, OperationService operationService, DependencyService dependencyService, ClassLoaderService classLoaderService, TimeTracker timeTracker, ProcessResourcesService processResourcesService, ConnectorExecutionTimeLogger connectorExecutionTimeLogger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnectorImplementation(java.lang.Long processDefinitionId, java.lang.String name, byte[] content)protected java.lang.StringbuildConnectorImplementationKey(long rootDefinitionId, java.lang.String connectorId, java.lang.String version)protected voidcheckConnectorImplementationIsValid(SConnectorImplementationDescriptor connectorImplementationDescriptor, java.lang.String connectorId, java.lang.String connectorVersion)voiddisconnect(ConnectorResult result)java.util.Map<java.lang.String,java.lang.Object>evaluateInputParameters(java.lang.String connectorId, java.util.Map<java.lang.String,SExpression> parameters, SExpressionContext sExpressionContext, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.io.Serializable>> inputValues)java.util.concurrent.CompletableFuture<ConnectorResult>executeConnector(long processDefinitionId, SConnectorInstance sConnectorInstance, SConnectorImplementationDescriptor connectorImplementationDescriptor, java.lang.ClassLoader classLoader, java.util.Map<java.lang.String,java.lang.Object> inputParameters)ConnectorResultexecuteMultipleEvaluation(long processDefinitionId, java.lang.String connectorDefinitionId, java.lang.String connectorDefinitionVersion, java.util.Map<java.lang.String,SExpression> connectorInputParameters, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.io.Serializable>> inputValues, java.lang.ClassLoader classLoader, SExpressionContext expressionContext)Execute a connector instance by given connectorDefinitionId and connectorDefinitionVersionvoidexecuteOutputOperation(java.util.List<SOperation> outputs, SExpressionContext expressionContext, ConnectorResult result)SConnectorImplementationDescriptorgetConnectorImplementation(long processDefinitionId, java.lang.String connectorId, java.lang.String connectorVersion)Get connector implementation descriptor for specified connector in a process definition.SConnectorImplementationDescriptorgetConnectorImplementationDescriptor(long processDefinitionId, java.lang.String connectorId, java.lang.String version)java.util.List<SBARResource>getConnectorImplementations(long processDefinitionId, int from, int numberOfElements)java.util.List<SConnectorImplementationDescriptor>getConnectorImplementations(long processDefinitionId, int fromIndex, int numberPerPage, java.lang.String field, OrderByType order)Get a list of connector implementation descriptors for id specified process definition, the returned list is paginatedjava.lang.LonggetNumberOfConnectorImplementations(long processDefinitionId)protected booleanloadConnectors(long processDefinitionId)booleanloadConnectors(SProcessDefinition sDefinition)Load connectors for given process definition and tenant, connectors will be stored in cache after loadingvoidremoveConnectorImplementations(long processDefinitionId)voidsetConnectorImplementation(SProcessDefinition sProcessDefinition, java.lang.String connectorId, java.lang.String connectorVersion, byte[] connectorImplementationArchive)Set connector implementation for id and version specified connector.
-
-
-
Field Detail
-
CONNECTOR_CACHE_NAME
protected static final java.lang.String CONNECTOR_CACHE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConnectorServiceImpl
public ConnectorServiceImpl(CacheService cacheService, ConnectorExecutor connectorExecutor, ExpressionResolverService expressionResolverService, OperationService operationService, DependencyService dependencyService, ClassLoaderService classLoaderService, TimeTracker timeTracker, ProcessResourcesService processResourcesService, ConnectorExecutionTimeLogger connectorExecutionTimeLogger)
-
-
Method Detail
-
executeConnector
public java.util.concurrent.CompletableFuture<ConnectorResult> executeConnector(long processDefinitionId, SConnectorInstance sConnectorInstance, SConnectorImplementationDescriptor connectorImplementationDescriptor, java.lang.ClassLoader classLoader, java.util.Map<java.lang.String,java.lang.Object> inputParameters) throws SConnectorException
- Specified by:
executeConnectorin interfaceConnectorService- Returns:
- the result of the connector execution
- Throws:
SConnectorException
-
getConnectorImplementationDescriptor
public SConnectorImplementationDescriptor getConnectorImplementationDescriptor(long processDefinitionId, java.lang.String connectorId, java.lang.String version) throws SConnectorException
- Specified by:
getConnectorImplementationDescriptorin interfaceConnectorService- Throws:
SConnectorException
-
executeOutputOperation
public void executeOutputOperation(java.util.List<SOperation> outputs, SExpressionContext expressionContext, ConnectorResult result) throws SConnectorException
- Specified by:
executeOutputOperationin interfaceConnectorService- Throws:
SConnectorException
-
disconnect
public void disconnect(ConnectorResult result) throws SConnectorException
- Specified by:
disconnectin interfaceConnectorService- Throws:
SConnectorException
-
buildConnectorImplementationKey
protected java.lang.String buildConnectorImplementationKey(long rootDefinitionId, java.lang.String connectorId, java.lang.String version)
-
executeMultipleEvaluation
public ConnectorResult executeMultipleEvaluation(long processDefinitionId, java.lang.String connectorDefinitionId, java.lang.String connectorDefinitionVersion, java.util.Map<java.lang.String,SExpression> connectorInputParameters, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.io.Serializable>> inputValues, java.lang.ClassLoader classLoader, SExpressionContext expressionContext) throws SConnectorException
Description copied from interface:ConnectorServiceExecute a connector instance by given connectorDefinitionId and connectorDefinitionVersion- Specified by:
executeMultipleEvaluationin interfaceConnectorService- Parameters:
processDefinitionId- The identifier of process definitionconnectorDefinitionId- The identifier of connector definitionconnectorDefinitionVersion- The version of connector definitionconnectorInputParameters- The input of connectorinputValues- The input values of connectorclassLoader- The class loader used to load and run connectorexpressionContext- The expression context- Returns:
- The output after connector executing
- Throws:
SConnectorException- Error thrown if has exceptions during the connector executing
-
evaluateInputParameters
public java.util.Map<java.lang.String,java.lang.Object> evaluateInputParameters(java.lang.String connectorId, java.util.Map<java.lang.String,SExpression> parameters, SExpressionContext sExpressionContext, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.io.Serializable>> inputValues) throws SExpressionTypeUnknownException, SExpressionEvaluationException, SExpressionDependencyMissingException, SInvalidExpressionException- Specified by:
evaluateInputParametersin interfaceConnectorService- Returns:
- Throws:
SExpressionTypeUnknownExceptionSExpressionEvaluationExceptionSExpressionDependencyMissingExceptionSInvalidExpressionException
-
loadConnectors
public boolean loadConnectors(SProcessDefinition sDefinition) throws SConnectorException
Description copied from interface:ConnectorServiceLoad connectors for given process definition and tenant, connectors will be stored in cache after loading- Specified by:
loadConnectorsin interfaceConnectorService- Parameters:
sDefinition- The process definition- Returns:
- true if all connectors found have all them dependencies resolved and are correctly loaded
- Throws:
SConnectorException- Error thrown if has exceptions during the connector loading
-
loadConnectors
protected boolean loadConnectors(long processDefinitionId) throws SConnectorException- Throws:
SConnectorException
-
setConnectorImplementation
public void setConnectorImplementation(SProcessDefinition sProcessDefinition, java.lang.String connectorId, java.lang.String connectorVersion, byte[] connectorImplementationArchive) throws SConnectorException, SInvalidConnectorImplementationException
Description copied from interface:ConnectorServiceSet connector implementation for id and version specified connector. Store all connector related files if they are not existed and replace the old implementation with the new one in file system. Delete former and load current connectors in cache.- Specified by:
setConnectorImplementationin interfaceConnectorService- Parameters:
sProcessDefinition- The process definition which the connector belongs toconnectorId- Id of connector definition.connectorVersion- Version of connector definitionconnectorImplementationArchive- zip byte array containing the connector implementation information- Throws:
SConnectorException- Error thrown if has exceptions during the connector implementation settingSInvalidConnectorImplementationException
-
checkConnectorImplementationIsValid
protected void checkConnectorImplementationIsValid(SConnectorImplementationDescriptor connectorImplementationDescriptor, java.lang.String connectorId, java.lang.String connectorVersion) throws SConnectorException, SInvalidConnectorImplementationException
-
getNumberOfConnectorImplementations
public java.lang.Long getNumberOfConnectorImplementations(long processDefinitionId) throws SConnectorException- Specified by:
getNumberOfConnectorImplementationsin interfaceConnectorService- Parameters:
processDefinitionId- the id of the process definition- Returns:
- the number of connector implementation for this process definition
- Throws:
SConnectorException
-
getConnectorImplementations
public java.util.List<SConnectorImplementationDescriptor> getConnectorImplementations(long processDefinitionId, int fromIndex, int numberPerPage, java.lang.String field, OrderByType order) throws SConnectorException
Description copied from interface:ConnectorServiceGet a list of connector implementation descriptors for id specified process definition, the returned list is paginated- Specified by:
getConnectorImplementationsin interfaceConnectorService- Parameters:
processDefinitionId- Identifier of process definitionfromIndex- Start index of connector recordnumberPerPage- Number of connectors we want to get. Maximum number of connectors returned.field- The field that the result ordered byorder- The order, ACS or DESC- Returns:
- A list of all satisfied connector implementation descriptor objects
- Throws:
SConnectorException- Error thrown if has exceptions during the connector implementations retrieve
-
getConnectorImplementation
public SConnectorImplementationDescriptor getConnectorImplementation(long processDefinitionId, java.lang.String connectorId, java.lang.String connectorVersion) throws SConnectorException
Description copied from interface:ConnectorServiceGet connector implementation descriptor for specified connector in a process definition.- Specified by:
getConnectorImplementationin interfaceConnectorService- Parameters:
processDefinitionId- Identifier of process definitionconnectorId- id of connector definitionconnectorVersion- version of connector definition- Returns:
- connector implementation descriptor object
- Throws:
SConnectorException- Error thrown if has exceptions during the connector implementation get
-
getConnectorImplementations
public java.util.List<SBARResource> getConnectorImplementations(long processDefinitionId, int from, int numberOfElements) throws SBonitaReadException
- Specified by:
getConnectorImplementationsin interfaceConnectorService- Throws:
SBonitaReadException
-
addConnectorImplementation
public void addConnectorImplementation(java.lang.Long processDefinitionId, java.lang.String name, byte[] content) throws SRecorderException- Specified by:
addConnectorImplementationin interfaceConnectorService- Throws:
SRecorderException
-
removeConnectorImplementations
public void removeConnectorImplementations(long processDefinitionId) throws SBonitaReadException, SRecorderException- Specified by:
removeConnectorImplementationsin interfaceConnectorService- Throws:
SBonitaReadExceptionSRecorderException
-
-