public JDBCResolver() {
}
public void setConfig(Configuration config) throws ConfigurationException {
super.setConfig(config);
config.processChildren(CONNECTION, new ConfigurationCallback() {
public void process(Configuration cfg) throws ConfigurationException {
String driver = cfg.getAttribute(DRIVER);
if ( driver == null || driver.length() == 0 ) {
System.out.println("The '"+DRIVER+"' attribute is required for '"+CONNECTION+"'");
System.exit(1);
}
String url = cfg.getAttribute(URL);
if ( url == null || url.length() == 0 ) {
System.out.println("The '"+URL+"' attribute is required for '"+CONNECTION+"'");
System.exit(1);
}
String username = cfg.getAttribute(USERNAME);
String password = cfg.getAttribute(PASSWORD);
JDBCConnectionPool pool = null;
try {
Class.forName(driver).newInstance();
if ( username != null )
pool = new JDBCConnectionPool(url, username, password);
else
pool = new JDBCConnectionPool(url);
}
catch ( Exception e ) {
e.printStackTrace(System.err);
System.exit(1);
}
final JDBCConnectionPool connPool = pool;
cfg.processChildren(INSTANCE, new ConfigurationCallback() {
public void process(Configuration cfg) throws ConfigurationException {
String path = cfg.getAttribute(PATH);
JDBCDiscovery discovery = new JDBCDiscovery(connPool);
discovery.setConfig(cfg);