Search in sources :

Example 1 with BPSUserManagerFactory

use of org.wso2.carbon.bpmn.core.integration.BPSUserManagerFactory in project carbon-business-process by wso2.

the class ActivitiEngineBuilder method buildEngine.

/* Instantiates the engine. Builds the state of the engine
	 *
	 * @return  ProcessEngineImpl object
	 * @throws BPSFault  Throws in the event of failure of ProcessEngine
	 */
public ProcessEngine buildEngine() throws BPSFault {
    try {
        String carbonConfigDirPath = CarbonUtils.getCarbonConfigDirPath();
        String activitiConfigPath = carbonConfigDirPath + File.separator + BPMNConstants.ACTIVITI_CONFIGURATION_FILE_NAME;
        File activitiConfigFile = new File(activitiConfigPath);
        ProcessEngineConfigurationImpl processEngineConfigurationImpl = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(new FileInputStream(activitiConfigFile));
        // Add script engine resolvers
        setResolverFactories(processEngineConfigurationImpl);
        // Add supported variable types
        setSupportedVariableTypes(processEngineConfigurationImpl);
        // we have to build the process engine first to initialize session factories.
        processEngine = processEngineConfigurationImpl.buildProcessEngine();
        processEngineConfigurationImpl.getSessionFactories().put(UserIdentityManager.class, new BPSUserManagerFactory());
        processEngineConfigurationImpl.getSessionFactories().put(GroupIdentityManager.class, new BPSGroupManagerFactory());
        dataSourceJndiName = processEngineConfigurationImpl.getProcessEngineConfiguration().getDataSourceJndiName();
    } catch (FileNotFoundException e) {
        String msg = "Failed to create an Activiti engine. Activiti configuration file not found";
        throw new BPSFault(msg, e);
    }
    return processEngine;
}
Also used : BPSGroupManagerFactory(org.wso2.carbon.bpmn.core.integration.BPSGroupManagerFactory) BPSUserManagerFactory(org.wso2.carbon.bpmn.core.integration.BPSUserManagerFactory) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) FileInputStream(java.io.FileInputStream)

Aggregations

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)1 BPSGroupManagerFactory (org.wso2.carbon.bpmn.core.integration.BPSGroupManagerFactory)1 BPSUserManagerFactory (org.wso2.carbon.bpmn.core.integration.BPSUserManagerFactory)1