String type = configuration.getAttribute("type", "ram");
if (type.equals("ram")) {
return new RAMJobStore();
}
JobStoreSupport store = null;
if (type.equals("tx")) {
store = new QuartzJobStoreTX(getLogger(), this.manager, this.context);
} else if (type.equals("cmt")) {
store = new QuartzJobStoreCMT(getLogger(), this.manager, this.context);
} else {
throw new ConfigurationException("Unknown store type: " + type);
}
Configuration dsConfig = configuration.getChild("datasource", false);
if (dsConfig == null) {
throw new ConfigurationException("Store " + type + " requires datasource configuration.");
}
String dsName = dsConfig.getValue();
String dsType = dsConfig.getAttribute("provider", "jndi");
ConnectionProvider provider;
if (dsType.equals("jndi")) {
provider = new JNDIConnectionProvider(dsName, false);
} else if (dsType.equals("excalibur")) {
provider = new DataSourceComponentConnectionProvider(dsName, this.manager);
} else {
// assume class name
try {
provider = (ConnectionProvider)Class.forName(dsType).newInstance();
} catch (Exception e) {
throw new ConfigurationException("Could not instantiate ConnectionProvider class " + dsType);
}
}
store.setInstanceName(instanceName);
store.setInstanceId(instanceID);
store.setDataSource(dsType + ":" + dsName);
DBConnectionManager.getInstance().addConnectionProvider(dsType + ":" + dsName, provider);
String delegate = configuration.getAttribute("delegate", null);
try {
if (delegate != null) {
store.setDriverDelegateClass(delegate);
}
} catch (InvalidConfigurationException e) {
throw new ConfigurationException("Could not instantiate DriverDelegate class " + delegate, e);
}