configDigester.push(servletContext.getScriptConfig());
configDigester.parse(is);
}
//--------------------create database
UserDatabase userDatabase = null;
CaseDatabase caseDatabase = null;
String schemaConextBase = context.findInitParameter(org.huihoo.workflow.xpdl.parser.Constants.WORKFLOW_SCHEMA_CONTEXT);
if (schemaConextBase == null)
{
schemaConextBase = WorkflowProperties.getSchemaContextFile();
}
Hashtable env = new Hashtable();
String storeFactoryClass = context.findFactoryClass(org.huihoo.workflow.xpdl.parser.Constants.WORKFLOW_FACTORY_STORE);
if (storeFactoryClass != null)
{
env.put(org.huihoo.workflow.xpdl.parser.Constants.WORKFLOW_FACTORY_STORE, storeFactoryClass);
}
DatabaseFactory dbFactory = DatabaseFactory.newInstance(env);
env.clear();
Store userStore = context.findStore(org.huihoo.workflow.xpdl.parser.Constants.WORKFLOW_STORE_USER);
if (userStore == null)
{
userStore = WorkflowProperties.getUserStore();
}
env.put(org.huihoo.workflow.xpdl.parser.Constants.WORKFLOW_STORE_USER, userStore);
userDatabase = dbFactory.newUserDatabase(env);
env.clear();
userDatabase.setWorkflowService(context);
Store caseStore = context.findStore(org.huihoo.workflow.xpdl.parser.Constants.WORKFLOW_STORE_CASE);
if (caseStore == null)
{
caseStore = WorkflowProperties.getCaseStore();
}
env.put(org.huihoo.workflow.xpdl.parser.Constants.WORKFLOW_STORE_CASE, caseStore);
caseDatabase = dbFactory.newCaseDatabase(env);
caseDatabase.setWorkflowService(context);
SchemaContext schemaContext = new SchemaContext(schemaConextBase);
if (userDatabase.getSchemaContext() == null)
{
userDatabase.setSchemaContext(schemaContext);
}
if (caseDatabase.getSchemaContext() == null)
{
caseDatabase.setSchemaContext(schemaContext);
}
ScriptInterpretor scriptInterpretor = new JavaInterpretor();
scriptInterpretor.initialize(context.getScriptContext());
context.setCaseDatabase(caseDatabase);
context.setUserDatabase(userDatabase);