org.activiti.engine.ProcessEngineConfiguration Java Examples
The following examples show how to use
org.activiti.engine.ProcessEngineConfiguration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExecuteSchemaOperationCommand.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public Void execute(CommandContext commandContext) { if (ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(schemaOperation)) { try { commandContext.getDbSqlSession().dbSchemaDrop(); } catch (RuntimeException e) { // ignore } } if (org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP.equals(schemaOperation) || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(schemaOperation) || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_CREATE.equals(schemaOperation)) { commandContext.getDbSqlSession().dbSchemaCreate(); } else if (org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE.equals(schemaOperation)) { commandContext.getDbSqlSession().dbSchemaCheckVersion(); } else if (ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE.equals(schemaOperation)) { commandContext.getDbSqlSession().dbSchemaUpdate(); } return null; }
Example #2
Source File: DbSqlSession.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void performSchemaOperationsProcessEngineBuild() { String databaseSchemaUpdate = Context.getProcessEngineConfiguration().getDatabaseSchemaUpdate(); log.debug("Executing performSchemaOperationsProcessEngineBuild with setting " + databaseSchemaUpdate); if (ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate)) { try { dbSchemaDrop(); } catch (RuntimeException e) { // ignore } } if (org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP.equals(databaseSchemaUpdate) || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate) || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_CREATE.equals(databaseSchemaUpdate)) { dbSchemaCreate(); } else if (org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE.equals(databaseSchemaUpdate)) { dbSchemaCheckVersion(); } else if (ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE.equals(databaseSchemaUpdate)) { dbSchemaUpdate(); } }
Example #3
Source File: DeploymentEntityManagerImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected ProcessDefinition findNewLatestProcessDefinitionAfterRemovalOf(ProcessDefinition processDefinitionToBeRemoved) { // The latest process definition is not necessarily the one with 'version -1' (some versions could have been deleted) // Hence, the following logic ProcessDefinitionQueryImpl query = new ProcessDefinitionQueryImpl(); query.processDefinitionKey(processDefinitionToBeRemoved.getKey()); if (processDefinitionToBeRemoved.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinitionToBeRemoved.getTenantId())) { query.processDefinitionTenantId(processDefinitionToBeRemoved.getTenantId()); } else { query.processDefinitionWithoutTenantId(); } query.processDefinitionVersionLowerThan(processDefinitionToBeRemoved.getVersion()); query.orderByProcessDefinitionVersion().desc(); List<ProcessDefinition> processDefinitions = getProcessDefinitionEntityManager().findProcessDefinitionsByQueryCriteria(query, new Page(0, 1)); if (processDefinitions != null && processDefinitions.size() > 0) { return processDefinitions.get(0); } return null; }
Example #4
Source File: JobTestHelper.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public static void executeJobExecutorForTime(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait, long intervalMillis) { AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); try { Timer timer = new Timer(); InteruptTask task = new InteruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); try { while (!task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); } } catch (InterruptedException e) { // ignore } finally { timer.cancel(); } } finally { asyncExecutor.shutdown(); } }
Example #5
Source File: EventSubscriptionsByNameMatcher.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public boolean isRetained(EventSubscriptionEntity eventSubscriptionEntity, Object parameter) { Map<String, String> params = (Map<String, String>) parameter; String type = params.get("eventType"); String eventName = params.get("eventName"); String tenantId = params.get("tenantId"); if (eventSubscriptionEntity.getEventType() != null && eventSubscriptionEntity.getEventType().equals(type) && eventSubscriptionEntity.getEventName() != null && eventSubscriptionEntity.getEventName().equals(eventName)) { if (tenantId != null && !tenantId.equals(ProcessEngineConfiguration.NO_TENANT_ID)) { return eventSubscriptionEntity.getTenantId() != null && eventSubscriptionEntity.getTenantId().equals(tenantId); } else { return ProcessEngineConfiguration.NO_TENANT_ID.equals(eventSubscriptionEntity.getTenantId()) || eventSubscriptionEntity.getTenantId() == null; } } return false; }
Example #6
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) { List<Job> jobsToDelete = null; if (processDefinition.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager().findTimerJobsByTypeAndProcessDefinitionKeyAndTenantId( TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId()); } else { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager() .findTimerJobsByTypeAndProcessDefinitionKeyNoTenantId(TimerStartEventJobHandler.TYPE, processDefinition.getKey()); } if (jobsToDelete != null) { for (Job job : jobsToDelete) { new CancelJobsCmd(job.getId()).execute(Context.getCommandContext()); } } }
Example #7
Source File: BeansConfigurationHelper.java From flowable-engine with Apache License 2.0 | 6 votes |
public static ProcessEngineConfiguration parseProcessEngineConfiguration(Resource springResource, String beanName) { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); xmlBeanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); xmlBeanDefinitionReader.loadBeanDefinitions(springResource); // Check non singleton beans for types // Do not eagerly initialize FactorBeans when getting BeanFactoryPostProcessor beans Collection<BeanFactoryPostProcessor> factoryPostProcessors = beanFactory.getBeansOfType(BeanFactoryPostProcessor.class, true, false).values(); if (factoryPostProcessors.isEmpty()) { factoryPostProcessors = Collections.singleton(new PropertyPlaceholderConfigurer()); } for (BeanFactoryPostProcessor factoryPostProcessor : factoryPostProcessors) { factoryPostProcessor.postProcessBeanFactory(beanFactory); } ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) beanFactory.getBean(beanName); processEngineConfiguration.setBeans(new SpringBeanFactoryProxyMap(beanFactory)); return processEngineConfiguration; }
Example #8
Source File: JobTestHelper.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public static void executeJobExecutorForTime(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait, long intervalMillis) { AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); try { Timer timer = new Timer(); InteruptTask task = new InteruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); try { while (!task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); } } catch (InterruptedException e) { // ignore } finally { timer.cancel(); } } finally { asyncExecutor.shutdown(); } }
Example #9
Source File: JPAEnhancedVariableTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override protected void initializeProcessEngine() { if (cachedProcessEngine == null) { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration .createProcessEngineConfigurationFromResource("org/activiti/standalone/jpa/activiti.cfg.xml"); cachedProcessEngine = processEngineConfiguration.buildProcessEngine(); EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration.getSessionFactories().get(EntityManagerSession.class); entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory(); setupJPAVariables(); } processEngine = cachedProcessEngine; }
Example #10
Source File: EventSubscriptionEntityManager.java From flowable-engine with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public List<SignalEventSubscriptionEntity> findSignalEventSubscriptionsByEventName(String eventName, String tenantId) { final String query = "selectSignalEventSubscriptionsByEventName"; Set<SignalEventSubscriptionEntity> selectList = null; Map<String, String> params = new HashMap<>(); params.put("eventName", eventName); if (tenantId != null && !tenantId.equals(ProcessEngineConfiguration.NO_TENANT_ID)) { params.put("tenantId", tenantId); selectList = new HashSet<SignalEventSubscriptionEntity>(getDbSqlSession().selectList(query, params)); } else { selectList = new HashSet<SignalEventSubscriptionEntity>(getDbSqlSession().selectList(query, params)); } // add events created in this command (not visible yet in query) for (SignalEventSubscriptionEntity entity : createdSignalSubscriptions) { if (eventName.equals(entity.getEventName())) { selectList.add(entity); } } return new ArrayList<>(selectList); }
Example #11
Source File: ActivitiPlugin.java From my_curd with Apache License 2.0 | 6 votes |
/** * 创建工作流引擎 * @return */ private Boolean createProcessEngine(){ if (processEngine != null) { return true; } StandaloneProcessEngineConfiguration conf = (StandaloneProcessEngineConfiguration) ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration(); conf.setDataSource(DbKit.getConfig().getDataSource()) .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE) // 自动更新数据库表 .setDbHistoryUsed(true); // 历史表生效功能 // conf.setTransactionsExternallyManaged(true); // 使用托管事务工厂(不配置,事务也可生效) conf.setTransactionFactory(new ActivitiTransactionFactory()); ActivitiPlugin.processEngine = conf.buildProcessEngine(); return true; }
Example #12
Source File: BpmnDeploymentHelper.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * Gets the most recent persisted process definition that matches this one for tenant and key. * If none is found, returns null. This method assumes that the tenant and key are properly * set on the process definition entity. */ public ProcessDefinitionEntity getMostRecentVersionOfProcessDefinition(ProcessDefinitionEntity processDefinition) { String key = processDefinition.getKey(); String tenantId = processDefinition.getTenantId(); ProcessDefinitionEntityManager processDefinitionManager = Context.getCommandContext().getProcessEngineConfiguration().getProcessDefinitionEntityManager(); ProcessDefinitionEntity existingDefinition = null; if (tenantId != null && !tenantId.equals(ProcessEngineConfiguration.NO_TENANT_ID)) { existingDefinition = processDefinitionManager.findLatestProcessDefinitionByKeyAndTenantId(key, tenantId); } else { existingDefinition = processDefinitionManager.findLatestProcessDefinitionByKey(key); } return existingDefinition; }
Example #13
Source File: TimerManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) { List<TimerJobEntity> jobsToDelete = null; if (processDefinition.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager().findJobsByTypeAndProcessDefinitionKeyAndTenantId( TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId()); } else { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager() .findJobsByTypeAndProcessDefinitionKeyNoTenantId(TimerStartEventJobHandler.TYPE, processDefinition.getKey()); } if (jobsToDelete != null) { for (TimerJobEntity job :jobsToDelete) { new CancelJobsCmd(job.getId()).execute(Context.getCommandContext()); } } }
Example #14
Source File: ActivitiUtils.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 单例模式获取引擎对象 */ public static ProcessEngine getProcessEngine() { if (processEngine == null) { /* * 使用默认的配置文件名称(activiti.cfg.xml)创建引擎对象 */ processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault().buildProcessEngine(); } return processEngine; }
Example #15
Source File: SchemaBootstrap.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Initialises the Activiti DB schema, if not present it's created. * * @param connection Connection to use the initialise DB schema */ private void initialiseActivitiDBSchema(Connection connection) { // create instance of activiti engine to initialise schema ProcessEngine engine = null; ProcessEngineConfiguration engineConfig = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration(); try { // build the engine engine = engineConfig.setDataSource(dataSource). setDatabaseSchemaUpdate("none"). setProcessEngineName("activitiBootstrapEngine"). setHistory("full"). setJobExecutorActivate(false). buildProcessEngine(); String schemaName = dbSchemaName != null ? dbSchemaName : databaseMetaDataHelper.getSchema(connection); if (logger.isInfoEnabled()) { logger.info("Creating Activiti DB schema tables"); } engine.getManagementService().databaseSchemaUpgrade(connection, null, schemaName); } finally { if (engine != null) { // close the process engine engine.close(); } } }
Example #16
Source File: ProcessEngineConfigurationTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 此测试会失败,因为本例没有配置oracle驱动 */ @Test public void specialName() { ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault().setProcessEngineName("oracleEngine").setJdbcDriver("oracle.jdbc.Driver") .setJdbcUrl("jdbc:oracle:thin:@localhost:1521:XE").setJdbcUsername("dbusername").setJdbcPassword("password").setDatabaseType("oracle") .buildProcessEngine(); ProcessEngine oracleEngine = ProcessEngines.getProcessEngine("oracleEngine"); assertNotNull(oracleEngine); }
Example #17
Source File: DefaultFlowable5CompatibilityHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void resetClock() { ProcessEngineConfiguration processEngineConfig = getProcessEngine().getProcessEngineConfiguration(); if (processEngineConfig.getClock() != null) { processEngineConfig.getClock().reset(); } }
Example #18
Source File: ActivitiUtils.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 单例模式获取引擎对象 */ public static ProcessEngine getProcessEngine() { if (processEngine == null) { /* * 使用默认的配置文件名称(activiti.cfg.xml)创建引擎对象 */ processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault().buildProcessEngine(); } return processEngine; }
Example #19
Source File: SpringProcessEngineConfiguration.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public ProcessEngineConfiguration setDataSource(DataSource dataSource) { if (dataSource instanceof TransactionAwareDataSourceProxy) { return super.setDataSource(dataSource); } else { // Wrap datasource in Transaction-aware proxy DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource); return super.setDataSource(proxiedDataSource); } }
Example #20
Source File: ProcessEngineConfigurationTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 此测试会失败,因为本例没有配置oracle驱动 */ @Test public void specialName() { ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault().setProcessEngineName("oracleEngine").setJdbcDriver("oracle.jdbc.Driver") .setJdbcUrl("jdbc:oracle:thin:@localhost:1521:XE").setJdbcUsername("dbusername").setJdbcPassword("password").setDatabaseType("oracle") .buildProcessEngine(); ProcessEngine oracleEngine = ProcessEngines.getProcessEngine("oracleEngine"); assertNotNull(oracleEngine); }
Example #21
Source File: AbstractPlaybackTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected void initializeProcessEngine() { Clock clock = new DefaultClockImpl(); ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault(); processEngineConfiguration.setClock(clock); this.processEngine = (new RecordableProcessEngineFactory( (ProcessEngineConfigurationImpl) processEngineConfiguration , listener)). getObject(); }
Example #22
Source File: ProcessDefinitionDiagramCmd.java From lemon with Apache License 2.0 | 5 votes |
public InputStream execute(CommandContext commandContext) { ProcessDefinitionEntity processDefinition = new GetDeploymentProcessDefinitionCmd( processDefinitionId).execute(commandContext); String diagramResourceName = processDefinition.getDiagramResourceName(); String deploymentId = processDefinition.getDeploymentId(); if (deploymentId != null) { byte[] bytes = commandContext .getResourceEntityManager() .findResourceByDeploymentIdAndResourceName(deploymentId, diagramResourceName).getBytes(); InputStream inputStream = new ByteArrayInputStream(bytes); return inputStream; } GetBpmnModelCmd getBpmnModelCmd = new GetBpmnModelCmd( processDefinitionId); BpmnModel bpmnModel = getBpmnModelCmd.execute(commandContext); ProcessEngineConfiguration processEngineConfiguration = Context .getProcessEngineConfiguration(); InputStream is = new DefaultProcessDiagramGenerator().generateDiagram( bpmnModel, "png", processEngineConfiguration.getActivityFontName(), processEngineConfiguration.getLabelFontName(), null); return is; }
Example #23
Source File: EventSubscriptionEntity.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void scheduleEventAsync(Object payload) { final CommandContext commandContext = Context.getCommandContext(); JobEntity message = new JobEntity(); message.setJobType(Job.JOB_TYPE_MESSAGE); message.setRevision(1); message.setJobHandlerType(ProcessEventJobHandler.TYPE); message.setJobHandlerConfiguration(id); message.setTenantId(getTenantId()); message.setProcessDefinitionId(getProcessDefinitionId()); message.setExecutionId(getExecutionId()); message.setProcessInstanceId(getProcessInstanceId()); if (Context.getProcessEngineConfiguration().getAsyncExecutor().isActive()) { GregorianCalendar expireCal = new GregorianCalendar(); ProcessEngineConfiguration processEngineConfig = Context.getCommandContext().getProcessEngineConfiguration(); expireCal.setTime(processEngineConfig.getClock().getCurrentTime()); expireCal.add(Calendar.SECOND, processEngineConfig.getLockTimeAsyncJobWaitTime()); message.setLockExpirationTime(expireCal.getTime()); } // TODO: support payload // if(payload != null) { // message.setEventPayload(payload); // } commandContext.getJobEntityManager().send(message); }
Example #24
Source File: NoDbConnectionTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testNoDbConnection() { try { ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti/standalone/initialization/nodbconnection.activiti.cfg.xml").buildProcessEngine(); fail("expected exception"); } catch (RuntimeException e) { assertTrue(containsSqlException(e)); } }
Example #25
Source File: ProcessEngineInitializationTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testNoTables() { try { ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti/standalone/initialization/notables.activiti.cfg.xml").buildProcessEngine(); fail("expected exception"); } catch (Exception e) { // OK assertTextPresent("no activiti tables in db", e.getMessage()); } }
Example #26
Source File: JPAVariableTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void initializeProcessEngine() { if (cachedProcessEngine == null) { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration .createProcessEngineConfigurationFromResource("org/activiti/standalone/jpa/activiti.cfg.xml"); cachedProcessEngine = processEngineConfiguration.buildProcessEngine(); EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration.getSessionFactories().get(EntityManagerSession.class); entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory(); } processEngine = cachedProcessEngine; }
Example #27
Source File: DisabledDefinitionInfoCacheTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void initializeProcessEngine() { if (cachedProcessEngine==null) { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration .createProcessEngineConfigurationFromResource("org/activiti/engine/test/bpmn/usertask/activiti.cfg.xml"); cachedProcessEngine = processEngineConfiguration.buildProcessEngine(); } processEngine = cachedProcessEngine; }
Example #28
Source File: ProxyProcessEngine.java From lemon with Apache License 2.0 | 5 votes |
public ProcessEngineConfiguration getProcessEngineConfiguration() { if (processEngine == null) { return null; } return processEngine.getProcessEngineConfiguration(); }
Example #29
Source File: ActivitiDataSourceConfig.java From opscenter with Apache License 2.0 | 5 votes |
@Bean public SpringProcessEngineConfiguration springProcessEngineConfiguration() { SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration(); configuration.setDataSource(dataSource); configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE); configuration.setJobExecutorActivate(true); configuration.setTransactionManager(transactionManager()); return configuration; }
Example #30
Source File: ActivitiUtils.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 单例模式获取引擎对象 */ public static ProcessEngine getProcessEngine() { if (processEngine == null) { /* * 使用默认的配置文件名称(activiti.cfg.xml)创建引擎对象 */ processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault().buildProcessEngine(); } return processEngine; }