timer = new Timer(false);
closed = false;
// Initialize query engine
try {
Configuration queryCfg = config.getChild(QUERYENGINE);
if (queryCfg != null) {
engine.setConfig(queryCfg);
}
} catch (Exception e) {
if (log.isWarnEnabled()) {
log.warn("ignored exception", e);
}
}
// Initialize system collection
if (!sysInit) {
systemCollection = new SystemCollection(this);
systemCollection.init();
super.addCollection(systemCollection);
this.sysInit = true;
}
Collection sysConfigCollection = systemCollection.getCollection(SystemCollection.CONFIGS);
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
Document colDoc = sysConfigCollection.getDocument(COLKEY);
if (colDoc == null) {
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
colDoc = db.newDocument();
Element root = colDoc.createElement(DATABASE);
root.setAttribute(NAME, getName());
colDoc.appendChild(root);
sysConfigCollection.setDocument(COLKEY, colDoc);
}
super.setConfig(new Configuration(colDoc.getDocumentElement(), false));
} catch (Exception e) {
if (log.isWarnEnabled()) {
log.warn("ignored exception", e);
}
}
// Register the Database with the VM
// databases.put(getName(), this);
// initialize the meta collection
// but only if it's turned on in the config.
String metaCfg = config.getAttribute(METADATA);
if (metaCfg.equalsIgnoreCase("on")) {
metaEnabled = true;
}
if (metaEnabled && !metaInit) {
try {
metaSystemCollection = new MetaSystemCollection(this);
Document colDoc = sysConfigCollection.getDocument(METAKEY);
if (colDoc == null) {
metaSystemCollection.init();
Document metaConfig = metaSystemCollection.getConfig().getElement().getOwnerDocument();
sysConfigCollection.setDocument(METAKEY, metaConfig);
} else {
metaSystemCollection.setConfig(new Configuration(colDoc, false));
}
super.addCollection(metaSystemCollection);
metaInit = true;
if (log.isDebugEnabled()) {