Examples of DeploymentCache


Examples of com.founder.fix.fixflow.core.impl.persistence.deployer.DeploymentCache

    ProcessDefinitionBehavior processDefinitionBehavior = getProcessDefinition(dataMap);
    return processDefinitionBehavior;
  }

  public ProcessDefinitionBehavior selectProcessDefinitionById(String processDefinitionId) {
    DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();
    ProcessDefinitionBehavior processDefinition = deploymentCache.getProcessDefinitionCache().get(processDefinitionId);
    if (processDefinition == null) {
      String sqlText = "select * " + "from FIXFLOW_DEF_PROCESSDEFINITION " + "where PROCESS_ID = ?";
      // 构建查询参数
      List<Object> objectParamWhere = new ArrayList<Object>();
      objectParamWhere.add(processDefinitionId);
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.deployer.DeploymentCache

  private ProcessDefinitionBehavior getProcessDefinition(Map<String, Object> processDataMap) {
    String processId = StringUtil.getString(processDataMap.get("PROCESS_ID"));
    String deploymentId = StringUtil.getString(processDataMap.get("DEPLOYMENT_ID"));
    String resourceName = StringUtil.getString(processDataMap.get("RESOURCE_NAME"));
    String processKey = StringUtil.getString(processDataMap.get("PROCESS_KEY"));
    DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();
    ProcessDefinitionBehavior processDefinition = deploymentCache.getProcessDefinitionCache().get(processId);
    if (processDefinition == null) {
      String sqlText = "SELECT BYTES FROM FIXFLOW_DEF_BYTEARRAY WHERE NAME=? and DEPLOYMENT_ID=?";
      // 构建查询参数
      List<Object> objectParamWhere = new ArrayList<Object>();
      objectParamWhere.add(resourceName);
      objectParamWhere.add(deploymentId);
      List<Map<String, Object>> dataObj = sqlCommand.queryForList(sqlText, objectParamWhere);
      Map<String, Object> dataMap = dataObj.get(0);
      Object bytesObject = dataMap.get("BYTES");
      if (bytesObject != null) {
        byte[] bytes = (byte[]) bytesObject;
        ResourceSet resourceSet = getResourceSet();
        String fixflowFilePath =  ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getNoneTemplateFilePath();
        URL url = ReflectUtil.getResource(fixflowFilePath);
        if(url == null){
          throw new FixFlowClassLoadingException(ExceptionCode.CLASSLOAD_EXCEPTION_FILENOTFOUND,fixflowFilePath);
        }
        String filePath = url.toString();
        Resource ddddResource = null;
        try {
          if (!filePath.startsWith("jar")) {
            filePath = java.net.URLDecoder.decode(url.getFile(),"utf-8");
            ddddResource = resourceSet.createResource(URI.createFileURI(filePath));
          } else {
            ddddResource = resourceSet.createResource(URI.createURI(filePath));
          }
          ddddResource.load(new ByteArrayInputStream(bytes), null);
        } catch (Exception e) {
          throw new FixFlowClassLoadingException(ExceptionCode.CLASSLOAD_EXCEPTION, e);
        }
        DefinitionsBehavior definitions = (DefinitionsBehavior) ddddResource.getContents().get(0).eContents().get(0);
        definitions.setProcessId(processId);

        for (RootElement rootElement : definitions.getRootElements()) {
          if (rootElement instanceof ProcessDefinitionBehavior) {
            ProcessDefinitionBehavior processObj = (ProcessDefinitionBehavior) rootElement;
            if (processObj.getProcessDefinitionKey().equals(processKey)) {
              processDefinition = (ProcessDefinitionBehavior) rootElement;
              break;
            }
          }
        }
        processDefinition.setDefinitions(definitions);
        // 加载事件定义.
        loadEvent(processDefinition);
        // 加载数据变量
        loadVariable(processDefinition);
        // 设置FlowNode元素的子流程
        loadSubProcess(processDefinition);
        processDefinition.persistentInit(processDataMap);
        deploymentCache.addProcessDefinition(processDefinition);
        return processDefinition;

      }
      return null;
    } else {
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.deployer.DeploymentCache

    if (deploymentCache == null) {
      List<Deployer> deployers = new ArrayList<Deployer>();

      deployers.add(new BpmnDeployer());
      deploymentCache = new DeploymentCache();
      deploymentCache.setDeployers(deployers);
    }
  }
View Full Code Here

Examples of org.activiti.engine.impl.persistence.deploy.DeploymentCache

    String processDefinitionId = messageEventSubscription.getConfiguration();
    if(processDefinitionId == null) {
      throw new ActivitiException("Cannot start process instance by message: subscription to message with name '"+messageName+"' is not a message start event.");
    }
       
    DeploymentCache deploymentCache = Context
            .getProcessEngineConfiguration()
            .getDeploymentCache();
         
    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiException("No process definition found for id '" + processDefinitionId + "'");
    }
 
    ActivityImpl startActivity = processDefinition.findActivity(messageEventSubscription.getActivityId());
View Full Code Here

Examples of org.activiti.engine.impl.persistence.deploy.DeploymentCache

    this.businessKey = businessKey;
    this.variables = variables;
  }
 
  public ProcessInstance execute(CommandContext commandContext) {
    DeploymentCache deploymentCache = Context
      .getProcessEngineConfiguration()
      .getDeploymentCache();
   
    // Find the process definition
    ProcessDefinitionEntity processDefinition = null;
    if (processDefinitionId!=null) {
      processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
      if (processDefinition == null) {
        throw new ActivitiException("No process definition found for id = '" + processDefinitionId + "'");
      }
    } else if(processDefinitionKey != null){
      processDefinition = deploymentCache.findDeployedLatestProcessDefinitionByKey(processDefinitionKey);
      if (processDefinition == null) {
        throw new ActivitiException("No process definition found for key '" + processDefinitionKey +"'");
      }
    } else {
      throw new ActivitiException("processDefinitionKey and processDefinitionId are null");
View Full Code Here

Examples of org.activiti.engine.impl.persistence.deploy.DeploymentCache

  public String getType() {
    return TYPE;
  }
 
  public void execute(JobEntity job, String configuration, ExecutionEntity execution, CommandContext commandContext) {
    DeploymentCache deploymentCache = Context
            .getProcessEngineConfiguration()
            .getDeploymentCache();
   
    ProcessDefinition processDefinition = deploymentCache.findDeployedLatestProcessDefinitionByKey(configuration);
    try {
      if(!processDefinition.isSuspended()) {
        new StartProcessInstanceCmd(configuration, null, null, null).execute(commandContext);
      } else {
        log.log(Level.FINE, "ignoring timer of suspended process definition " + processDefinition.getName());
View Full Code Here

Examples of org.activiti.engine.impl.persistence.deploy.DeploymentCache

        "'"+processInstance.getProcessInstanceId()+"'. " +
        "Please invoke the "+getClass().getSimpleName()+" with a root execution id.");
    }
    ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.getProcessDefinition();

    DeploymentCache deploymentCache = Context
      .getProcessEngineConfiguration()
      .getDeploymentCache();
    ProcessDefinitionEntity currentProcessDefinition;
    if (currentProcessDefinitionImpl instanceof ProcessDefinitionEntity) {
      currentProcessDefinition = (ProcessDefinitionEntity) currentProcessDefinitionImpl;
    } else {
      currentProcessDefinition = deploymentCache.findDeployedProcessDefinitionById(currentProcessDefinitionImpl.getId());
    }

    ProcessDefinitionEntity newProcessDefinition = deploymentCache
      .findDeployedProcessDefinitionByKeyAndVersion(currentProcessDefinition.getKey(), processDefinitionVersion);
   
    validateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);
   
    // switch the historic process instance to the new process definition version
View Full Code Here

Examples of org.activiti.engine.impl.persistence.deploy.DeploymentCache

  private static Logger log = Logger.getLogger(RulesDeployer.class.getName());

  public void deploy(DeploymentEntity deployment) {
    KnowledgeBuilder knowledgeBuilder = null;

    DeploymentCache deploymentCache = Context
      .getProcessEngineConfiguration()
      .getDeploymentCache();
   
    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();
      deploymentCache.addKnowledgeBase(deployment.getId(), knowledgeBase);
    }
  }
View Full Code Here

Examples of org.activiti.engine.impl.persistence.deploy.DeploymentCache

      keyList.add(processDefinition.getKey());
    }
   
    CommandContext commandContext = Context.getCommandContext();
    ProcessDefinitionManager processDefinitionManager = commandContext.getProcessDefinitionManager();
    DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();
    DbSqlSession dbSqlSession = commandContext.getSession(DbSqlSession.class);
    for (ProcessDefinitionEntity processDefinition : processDefinitions) {
     
      if (deployment.isNew()) {
        int processDefinitionVersion;

        ProcessDefinitionEntity latestProcessDefinition = processDefinitionManager.findLatestProcessDefinitionByKey(processDefinition.getKey());
        if (latestProcessDefinition != null) {
          processDefinitionVersion = latestProcessDefinition.getVersion() + 1;
        } else {
          processDefinitionVersion = 1;
        }

        processDefinition.setVersion(processDefinitionVersion);
        processDefinition.setDeploymentId(deployment.getId());

        String nextId = idGenerator.getNextId();
        String processDefinitionId = processDefinition.getKey()
          + ":" + processDefinition.getVersion()
          + ":" + nextId; // ACT-505
                  
        // ACT-115: maximum id length is 64 charcaters
        if (processDefinitionId.length() > 64) {         
          processDefinitionId = nextId;
        }
        processDefinition.setId(processDefinitionId);

        removeObsoleteTimers(processDefinition);
        addTimerDeclarations(processDefinition);
       
        removeObsoleteMessageEventSubscriptions(processDefinition, latestProcessDefinition);
        addMessageEventSubscriptions(processDefinition);

        dbSqlSession.insert(processDefinition);
        deploymentCache.addProcessDefinition(processDefinition);
        addAuthorizations(processDefinition);

       
      } else {
        String deploymentId = deployment.getId();
        processDefinition.setDeploymentId(deploymentId);
        ProcessDefinitionEntity persistedProcessDefinition = processDefinitionManager.findProcessDefinitionByDeploymentAndKey(deploymentId, processDefinition.getKey());
        processDefinition.setId(persistedProcessDefinition.getId());
        processDefinition.setVersion(persistedProcessDefinition.getVersion());
        processDefinition.setSuspensionState(persistedProcessDefinition.getSuspensionState());
       
        deploymentCache.addProcessDefinition(processDefinition);
        addAuthorizations(processDefinition);

      }

      // Add to cache
View Full Code Here

Examples of org.activiti.engine.impl.persistence.deploy.DeploymentCache

      deployers.addAll(getDefaultDeployers());
      if (customPostDeployers!=null) {
        deployers.addAll(customPostDeployers);
      }

      deploymentCache = new DeploymentCache();
      deploymentCache.setDeployers(deployers);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.