Search in sources :

Example 1 with SpringBeanFactoryProxyMap

use of org.flowable.engine.common.impl.cfg.SpringBeanFactoryProxyMap in project syncope by apache.

the class DomainProcessEngineFactoryBean method getObject.

@Override
public DomainProcessEngine getObject() throws Exception {
    if (engine == null) {
        Map<String, ProcessEngine> engines = new HashMap<>();
        ctx.getBeansOfType(DataSource.class).entrySet().stream().filter(entry -> (!entry.getKey().startsWith("local"))).forEachOrdered(entry -> {
            String domain = StringUtils.substringBefore(entry.getKey(), DataSource.class.getSimpleName());
            DataSource dataSource = entry.getValue();
            PlatformTransactionManager transactionManager = ctx.getBean(domain + "TransactionManager", PlatformTransactionManager.class);
            Object entityManagerFactory = ctx.getBean(domain + "EntityManagerFactory");
            SpringProcessEngineConfiguration conf = ctx.getBean(SpringProcessEngineConfiguration.class);
            conf.setDataSource(dataSource);
            conf.setTransactionManager(transactionManager);
            conf.setTransactionsExternallyManaged(true);
            conf.setJpaEntityManagerFactory(entityManagerFactory);
            if (conf.getBeans() == null) {
                conf.setBeans(new SpringBeanFactoryProxyMap(ctx));
            }
            if (conf.getExpressionManager() == null) {
                conf.setExpressionManager(new SpringExpressionManager(ctx, conf.getBeans()));
            }
            if (EngineServiceUtil.getIdmEngineConfiguration(conf) == null) {
                conf.addEngineConfiguration(EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG, ctx.getBean(SpringIdmEngineConfiguration.class));
            }
            engines.put(domain, conf.buildProcessEngine());
        });
        engine = new DomainProcessEngine(engines);
    }
    return engine;
}
Also used : EngineServiceUtil(org.flowable.engine.impl.util.EngineServiceUtil) EngineConfigurationConstants(org.flowable.engine.common.impl.interceptor.EngineConfigurationConstants) HashMap(java.util.HashMap) BeansException(org.springframework.beans.BeansException) StringUtils(org.apache.commons.lang3.StringUtils) ProcessEngine(org.flowable.engine.ProcessEngine) ApplicationContext(org.springframework.context.ApplicationContext) SpringIdmEngineConfiguration(org.flowable.idm.spring.SpringIdmEngineConfiguration) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) SpringBeanFactoryProxyMap(org.flowable.engine.common.impl.cfg.SpringBeanFactoryProxyMap) FactoryBean(org.springframework.beans.factory.FactoryBean) SpringExpressionManager(org.flowable.spring.SpringExpressionManager) Map(java.util.Map) DisposableBean(org.springframework.beans.factory.DisposableBean) DataSource(javax.sql.DataSource) SpringProcessEngineConfiguration(org.flowable.spring.SpringProcessEngineConfiguration) ApplicationContextAware(org.springframework.context.ApplicationContextAware) HashMap(java.util.HashMap) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) DataSource(javax.sql.DataSource) SpringIdmEngineConfiguration(org.flowable.idm.spring.SpringIdmEngineConfiguration) SpringBeanFactoryProxyMap(org.flowable.engine.common.impl.cfg.SpringBeanFactoryProxyMap) SpringProcessEngineConfiguration(org.flowable.spring.SpringProcessEngineConfiguration) SpringExpressionManager(org.flowable.spring.SpringExpressionManager) ProcessEngine(org.flowable.engine.ProcessEngine)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 DataSource (javax.sql.DataSource)1 StringUtils (org.apache.commons.lang3.StringUtils)1 ProcessEngine (org.flowable.engine.ProcessEngine)1 SpringBeanFactoryProxyMap (org.flowable.engine.common.impl.cfg.SpringBeanFactoryProxyMap)1 EngineConfigurationConstants (org.flowable.engine.common.impl.interceptor.EngineConfigurationConstants)1 EngineServiceUtil (org.flowable.engine.impl.util.EngineServiceUtil)1 SpringIdmEngineConfiguration (org.flowable.idm.spring.SpringIdmEngineConfiguration)1 SpringExpressionManager (org.flowable.spring.SpringExpressionManager)1 SpringProcessEngineConfiguration (org.flowable.spring.SpringProcessEngineConfiguration)1 BeansException (org.springframework.beans.BeansException)1 DisposableBean (org.springframework.beans.factory.DisposableBean)1 FactoryBean (org.springframework.beans.factory.FactoryBean)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ApplicationContextAware (org.springframework.context.ApplicationContextAware)1 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)1