package lt.itdbaltics.camel.component.existdb;

import org.exist.xmldb.DatabaseImpl;
import org.xmldb.api.DatabaseManager;

public class DatabaseFactory {
    private static DatabaseImpl database;

    public DatabaseFactory() throws Exception {
        if (database == null) {
            database = new DatabaseImpl();
            database.setProperty("create-database", "true");
            database.setProperty("configuration", "conf.xml");

            DatabaseManager.registerDatabase(database);
        }
    }

    public void destroy() {
        if (database != null) {
            try {
                DatabaseManager.deregisterDatabase(database);
                database = null;
            } catch (Exception ex) {

            }
        }
    }
}

@@ -115,16 +115,54 @@
 Manager;
+%0Aimport org.xmldb.api.base.Collection;
 %0A%0Apublic
@@ -524,32 +524,143 @@
 abase(database);
+%0A%0A            //FIXME: Externalize database URL%0A            DatabaseManager.getCollection(%22xmldb:exist:///db%22);
 %0A        %7D%0A    %7D

Add dummy collection resolving on database initialization