Search in sources :

Example 11 with DeploymentManager

use of org.activiti.engine.impl.persistence.deploy.DeploymentManager in project Activiti by Activiti.

the class RulesDeployer method deploy.

public void deploy(DeploymentEntity deployment, Map<String, Object> deploymentSettings) {
    log.debug("Processing deployment {}", deployment.getName());
    KnowledgeBuilder knowledgeBuilder = null;
    DeploymentManager deploymentManager = Context.getProcessEngineConfiguration().getDeploymentManager();
    Map<String, ResourceEntity> resources = deployment.getResources();
    for (String resourceName : resources.keySet()) {
        log.info("Processing resource {}", resourceName);
        if (resourceName.endsWith(".drl")) {
            // is only parsing .drls sufficient? what about other rule dsl's? (@see ResourceType)
            if (knowledgeBuilder == null) {
                knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
            }
            ResourceEntity resourceEntity = resources.get(resourceName);
            byte[] resourceBytes = resourceEntity.getBytes();
            Resource droolsResource = ResourceFactory.newByteArrayResource(resourceBytes);
            knowledgeBuilder.add(droolsResource, ResourceType.DRL);
        }
    }
    if (knowledgeBuilder != null) {
        KnowledgeBase knowledgeBase = knowledgeBuilder.newKnowledgeBase();
        deploymentManager.getKnowledgeBaseCache().add(deployment.getId(), knowledgeBase);
    }
}
Also used : KnowledgeBuilder(org.drools.builder.KnowledgeBuilder) KnowledgeBase(org.drools.KnowledgeBase) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ResourceEntity(org.activiti.engine.impl.persistence.entity.ResourceEntity) Resource(org.drools.io.Resource)

Aggregations

DeploymentManager (org.activiti.engine.impl.persistence.deploy.DeploymentManager)11 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)8 ActivitiException (org.activiti.engine.ActivitiException)6 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)4 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)4 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 BpmnModel (org.activiti.bpmn.model.BpmnModel)2 ProcessDefinitionInfoCacheObject (org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject)2 ResourceEntity (org.activiti.engine.impl.persistence.entity.ResourceEntity)2 TimerEntity (org.activiti.engine.impl.persistence.entity.TimerEntity)2 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AbstractDataAssociation (org.activiti.engine.impl.bpmn.data.AbstractDataAssociation)1 BpmnDeployer (org.activiti.engine.impl.bpmn.deployer.BpmnDeployer)1 BpmnParse (org.activiti.engine.impl.bpmn.parser.BpmnParse)1