use of org.apache.ode.il.dbutil.Database in project carbon-business-process by wso2.
the class BPELServerImpl method initDataSource.
/**
* Initialize the data source.
*
* @throws BPELEngineException If error occured while initializing datasource
*/
private void initDataSource() throws BPELEngineException {
db = new Database(odeConfigurationProperties);
db.setTransactionManager(transactionManager);
if (System.getProperty("setup") != null) {
BPELDatabaseCreator bpelDBCreator;
try {
bpelDBCreator = new BPELDatabaseCreator(db.<DataSource>lookupInJndi(odeConfigurationProperties.getDbDataSource()));
} catch (Exception e) {
String errMsg = "Error creating BPELDatabaseCreator";
log.error(errMsg, e);
throw new BPELEngineException(errMsg, e);
}
if (!bpelDBCreator.isDatabaseStructureCreated("SELECT * FROM ODE_SCHEMA_VERSION")) {
try {
// TODO rename following method
bpelDBCreator.createRegistryDatabase();
} catch (Exception e) {
String errMsg = "Error creating BPEL database";
log.error(errMsg, e);
throw new BPELEngineException(errMsg, e);
}
} else {
if (log.isDebugEnabled()) {
log.debug("BPEL database already exists. Using the old database.");
}
}
}
// In carbon, embedded H2 database for ODE is located at CARBON_HOME/repository/database
String dbRoot = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "database";
File dbRootDir = new File(dbRoot);
if (dbRootDir.exists() && dbRootDir.isDirectory()) {
db.setWorkRoot(dbRootDir);
} else {
db.setWorkRoot(null);
}
try {
db.start();
} catch (Exception e) {
String errMsg = "Error starting database connections, check the database configuration!";
log.error(errMsg, e);
throw new BPELEngineException(errMsg, e);
}
}
Aggregations