JBPM4.3 动态创建Transition时,需要在OpenEnvironment取得Activity后closeEnvironment

JBPM4.3 动态创建Transition时,需要在OpenEnvironment取得Activity后closeEnvironment,否则会报session close错误,如下代码所示

public ActivityImpl getActiveActivityByExecution(String executionId) {
    	EnvironmentFactory environmentFactory = (EnvironmentFactory) processEngine;
  	  	EnvironmentImpl environment = environmentFactory.openEnvironment();
    	
    	try {
	        ExecutionImpl exeImpl = (ExecutionImpl)executionService.findExecutionById(executionId);
	        ActivityImpl activity = exeImpl.getActivity();
	        return activity;
	      } finally {
		      if(null != environment)
		     environment.close();
	        }
    }

 

 

你可能感兴趣的:(Environment)