else
jbpmObjectFactory = objectFactory;
jbpmConfiguration = new JbpmConfiguration(jbpmObjectFactory);
JbpmContext context = null;
try {
// 2. inject the HB session factory if it is the case
context = jbpmConfiguration.createJbpmContext(contextName);
if (sessionFactory != null) {
logger.info("using given Hibernate session factory");
context.setSessionFactory(sessionFactory);
}
// 3. execute persistence operations
hasPersistenceService = JbpmUtils.hasPersistenceService(jbpmConfiguration, contextName);
if (hasPersistenceService) {
logger.info("persistence service available...");
if (createSchema) {
logger.info("creating schema");
jbpmConfiguration.createSchema(contextName);
}
if (processDefinitions != null || processDefinitionsResources != null) {
if (processDefinitions != null) {
String toString = Arrays.asList(processDefinitions).toString();
logger.info("deploying process definitions:" + toString);
// deploy the ProcessDefinitions
for (int i = 0; i < processDefinitions.length; i++) {
context.deployProcessDefinition(processDefinitions[i]);
}
}
if (processDefinitionsResources != null) {
ProcessDefinitionFactoryBean factory = new ProcessDefinitionFactoryBean();
String toString = Arrays.asList(processDefinitionsResources).toString();
logger.info("deploying process definitions (from resources):" + toString);
for (int i = 0; i < processDefinitionsResources.length; i++) {
factory.setDefinitionLocation(processDefinitionsResources[i]);
factory.afterPropertiesSet();
context.deployProcessDefinition((ProcessDefinition) factory.getObject());
}
}
}
}
else {
logger
.info("persistence unavailable not available - schema create/drop and process definition deployment disabled");
}
}
finally {
if (context != null)
context.close();
}
}