File homeDir = new File(System.getProperty(dbXML.PROP_DBXML_HOME));
setCollectionRoot(new File(homeDir, "db"));
}
try {
Configuration queryCfg = config.getChild(QUERYENGINE);
if ( queryCfg != null )
engine.setConfig(queryCfg);
}
catch ( Exception e ) {
e.printStackTrace(System.err);
throw new dbXMLException("Couldn't initialize Query Engine", e);
}
try {
sysCol = new SystemCollection(this, magicUser, userStack);
try {
sysCol.init();
}
catch ( dbXMLException e ) {
e.printStackTrace(System.err);
}
collections.put(sysCol.getName(), sysCol);
}
catch ( Exception e ) {
e.printStackTrace(System.err);
throw new dbXMLException("Couldn't initialize System Collection", e);
}
Transaction tx = new Transaction();
try {
// Bootstrap from the database itself... This is accomplished
// by intercepting the setConfig call and using a Configuration
// retrieved from the database instead of the standard config
Collection col = sysCol.getCollection(SystemCollection.CONFIGS);
DOMAdapter domAdapter = new DOMAdapter(col);
Document colDoc = domAdapter.getDocument(tx, COLKEY);
if ( colDoc == null ) {
colDoc = DOMHelper.newDocument();
Element root = colDoc.createElement(DATABASE);
root.setAttribute(NAME, name);
colDoc.appendChild(root);
domAdapter.setDocument(tx, COLKEY, colDoc);
}
super.setConfig(new Configuration(colDoc));
}
catch ( Throwable e ) {
tx.cancel();
e.printStackTrace(System.err);
throw new dbXMLException("Couldn't bootstrap Database", e);
}
finally {
if ( tx.getStatus() == Transaction.ACTIVE )
tx.commit();
}
try {
Configuration securityCfg = config.getChild(SECURITY);
if ( securityCfg != null ) {
String className = securityCfg.getAttribute(CLASS);
security = (SecurityManager)ClassResolver.get(className).newInstance();
security.setDatabase(this);
security.setMagicUser(magicUser);
security.setUserStack(userStack);
security.setConfig(securityCfg);