How to Configure Activiti Engine In Config file Of Grails Project

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member II

How to Configure Activiti Engine In Config file Of Grails Project

1. In Spring i did like this for generating activiti related tables in database

         

@Bean(name = "processEngineConfiguration")
public SpringProcessEngineConfiguration processEngineConfiguration() {
SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
config.setDataSource(getDataSource());
config.setTransactionManager(getTransactionManager(getSessionFactory()));
config.setDatabaseSchemaUpdate("true");
config.setHistory("audit");
config.setAsyncExecutorActivate(false);
config.setJobExecutorActivate(false);
config.setMailServerHost("smtp.elasticemail.com");
config.setMailServerPort(2525);
config.setMailServerUsername("vamsikrishna.g@nipun.net");
config.setMailServerPassword("de0bc9a4-663c-40ee-8546-4a4c98f4919f");
return config;
}

@Bean(name = "processEngine")
public ProcessEngineFactoryBean processEngine() {
ProcessEngineFactoryBean factoryBean = new ProcessEngineFactoryBean();
factoryBean.setProcessEngineConfiguration(processEngineConfiguration());
return factoryBean;
}

@Bean
public HistoryService historyService(ProcessEngine processEngine) {
return processEngine.getHistoryService();
}

@Bean
public ManagementService managementService(ProcessEngine processEngine) {
return processEngine.getManagementService();
}

@Bean
public RepositoryService repositoryService(ProcessEngine processEngine) {
return processEngine.getRepositoryService();
}

@Bean
public RuntimeService runtimeService(ProcessEngine processEngine) {
return processEngine.getRuntimeService();
}

@Bean
public TaskService taskService(ProcessEngine processEngine) {
return processEngine.getTaskService();
}

@Bean
public IdentityService identityService(ProcessEngine processEngine) {
return processEngine.getIdentityService();
}

@Bean
public FormService formService(ProcessEngine processEngine) {
return processEngine.getFormService();
}

2. like this i have to Configure activiti engine in grails

I am added this Code in Config.groovy

activiti {
processEngineName = "activiti-engine-default"
jobExecutorActivate = false
asyncExecutorActivate = false
databaseType = "mysql"
history = "audit"
}

environments {
development {
grails.logging.jul.usebridge = true
activiti {
processEngineName = "activiti-engine-dev"
databaseSchemaUpdate = "true"
}
// grails.serverURL = "http://localhost:8080/MaterialManagement/dashboard/main"
}
production {
grails.logging.jul.usebridge = true
activiti {
processEngineName = "activiti-engine-prod"
databaseSchemaUpdate = false
}
// grails.serverURL = "localhost:8080/smartInventory"
// grails.serverURL = "localhost:8080/MaterialManagement/dashboard/loginpage"
}
}

DataSource.groovy

--------------------------------

dataSource {
pooled = true
jmxExport = true
driverClassName = "com.mysql.jdbc.Driver"
dialect="org.hibernate.dialect.MySQL5InnoDBDialect"
username = grailsApplication.metadata['database.username']
// password = "root"
password = grailsApplication.metadata['database.password']
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}

// environment specific settings
environments {
development {
dataSource {
dbCreate = "validate" // one of 'create', 'create-drop', 'update', 'validate', ''
url = grailsApplication.metadata['database.url']
username = grailsApplication.metadata['database.username']
password = grailsApplication.metadata['database.password']
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}

}
test {
dataSource {
dbCreate = "validate" // one of 'create', 'create-drop', 'update', 'validate', ''
url = grailsApplication.metadata['database.url']
username = grailsApplication.metadata['database.username']
// password = "root"
password = grailsApplication.metadata['database.password']
// password = "root"
}
}
production {
dataSource {
dbCreate = "validate" // one of 'create', 'create-drop', 'update', 'validate', ''
url = grailsApplication.metadata['database.url']
username = grailsApplication.metadata['database.username']
// password = "root"
password = grailsApplication.metadata['database.password']
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}

I want to Specify DataSource in activiti enginee of config file

i have to generate activiti related tables dynamically in database

what can i do in grails, could you please let me know how to implement this.

Thanks&Regards,

V.HimaBindu

1 Reply
Highlighted
Active Member II

Re: How to Configure Activiti Engine In Config file Of Grails Project

1)     Integrating Activiti in Grails:

 

BuildConfig.groovy

 

    repositories {

       //maven of activiti repository

mavenRepo name: "Activiti", root: "https://maven.alfresco.com/nexus/content/groups/public"

    }

 

    dependencies {

        runtime 'mysql:mysql-connector-java:5.1.29'

        test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"

      

       //add this line for downloading activiti related jars from repository

        compile ('org.activiti:activiti-engine:5.20.0') {

             excludes 'livetribe-jsr223', 'spring-beans'

        }

        runtime ('org.activiti:activiti-spring:5.20.0') {

excludes 'spring-context', 'spring-jdbc', 'spring-orm', 'slf4j-log4j12', 'commons-dbcp'

        }

    }

}

 

 

Configuring ProcessEngineConfiguration in Grails:

 

In resources.groovy add this Code

 

 

resources.groovy:

 

import org.activiti.spring.SpringProcessEngineConfiguration

import org.hibernate.SessionFactory;

import org.springframework.orm.hibernate3.HibernateTransactionManager

 

 

// Place your Spring DSL code here

 

beans = {

     

      processEngineConfiguration(org.activiti.spring.SpringProcessEngineConfiguration) {

databaseType = "mysql" // (u have to specify which database did u used in your application)

            databaseSchemaUpdate = true // create-drop, true, false

            dataSource = ref("dataSource")

            transactionManager = ref("transactionManager")

            history = "audit";

            asyncExecutorActivate = false;

            jobExecutorActivate = false;

      }

     

      processEngine(org.activiti.spring.ProcessEngineFactoryBean) {

            processEngineConfiguration = ref("processEngineConfiguration")

      }

           

      runtimeService(processEngine:"getRuntimeService")

    repositoryService(processEngine:"getRepositoryService")

      taskService(processEngine:"getTaskService")

      managementService(processEngine:"getManagementService")

      identityService(processEngine:"getIdentityService")

      historyService(processEngine:"getHistoryService")

    formService(processEngine:"getFormService")

     

      baseController(com.nipun.BaseController) {

            repositoryService = ref("repositoryService")

            runtimeService = ref("runtimeService")

            taskService = ref("taskService")

            identityService = ref("identityService")

            formService = ref("formService")

      }

}