protected ClassLoader resolveProcessArchiveClassLoader() { final DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache(); final ExecutionContext executionContext = getExecutionContext(); if (executionContext != null) { String processDefinitionId = executionContext.getProcessInstance().getProcessDefinitionId(); // check whether the process definition is deployed to the cache. // if the process definition is not deployed to the cache, we do not attempt // to resolve the deploymentClassloader since the process archive is undeployed. if (deploymentCache.getProcessDefinitionCache().containsKey(processDefinitionId)) { String processDefinitionKey = executionContext.getProcessDefinition().getKey(); // look up the classloader for that processDefinition: return deploymentClassloaderMap.get(processDefinitionKey); } } return null; }
public ProcessArchive getProcessArchiveByProcessDefinitionId(final String processDefinitionId) { // first try to hit the cache ProcessDefinitionEntity processDefinitionEntity = processEngineConfiguration .getDeploymentCache() .getProcessDefinitionCache() .get(processDefinitionId); if(processDefinitionEntity == null) { // now look for it in the database (will add it to the cache). processDefinitionEntity = processEngineConfiguration .getCommandExecutorTxRequired() .execute(new Command<ProcessDefinitionEntity>() { public ProcessDefinitionEntity execute(CommandContext commandContext) { return commandContext.getProcessDefinitionManager() .findLatestProcessDefinitionById(processDefinitionId); } }); } if(processDefinitionEntity == null) { throw new FoxPlatformException("Could not find process definition with id '"+processDefinitionId+"' for process engine '"+processEngineName+"'."); } String processDefinitionKey = processDefinitionEntity.getKey(); if(processDefinitionKey == null) { throw new FoxPlatformException("Could not find process definition with id '"+processDefinitionId+"' for process engine '"+processEngineName+"'."); } return getProcessArchiveByProcessDefinitionKey(processDefinitionKey); }