Package org.apache.xindice.util

Examples of org.apache.xindice.util.Configuration


        return config;
    }

    private Configuration loadConfiguration() throws XMLDBException {
        Configuration config;

        if (configFile == null) {
            try {
                // Try configuration first
                configFile = getProperty(PROP_XINDICE_CONFIGURATION);
            } catch (XMLDBException e) {
                /* ignored */
            }
            if (configFile == null) {
                // Fallback to system property
                configFile = System.getProperty(SYSPROP_XINDICE_CONFIGURATION);
            }
            if ("".equals(configFile)) {
                configFile = null;
            }
        }

        if (configFile != null) {
            if (log.isInfoEnabled()) {
                log.info("Specified configuration file: '" + configFile + "'");
            }
            try {
                FileInputStream configXMLFile = new FileInputStream(configFile);
                config = new Configuration(DOMParser.toDocument(configXMLFile), false);
            } catch (XindiceException e) {
                throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR,
                                         "Unable to parse database configuration file: " + configFile, e);
            } catch (FileNotFoundException e) {
                throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR,
                                         "Database configuration file not found: " + configFile);
            }
        } else {
            if (log.isInfoEnabled()) {
                log.info("No configuration file specified, going with the default configuration");
            }

            try {
                config = new Configuration(DOMParser.toDocument(Xindice.DEFAULT_CONFIGURATION), false);
            } catch (XindiceException e) {
                throw new XindiceRuntimeException("Unable to parse default database configuration", e);
            }
        }

View Full Code Here


            // Observer
            DBObserver.getInstance().flushDatabaseConfig(this, getConfig());
        }

        if (isMetaEnabled()) {
            Configuration config = metaSystemCollection.getConfig();
            if (config.isDirty()) {
                try {
                    Document d = config.getElement().getOwnerDocument();
                    systemCollection.getCollection(SystemCollection.CONFIGS).setDocument(METAKEY, d);
                    config.resetDirty();
                } catch (Exception e) {
                    log.error("Error writing configuration '" + METAKEY + "', for database " + getName(), e);
                }
            }
        }
View Full Code Here

        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()) {
View Full Code Here

    // See superclass for documentation. Note that first argument is the path, not the name.
    public org.xmldb.api.base.Collection createCollection(String path, Document configuration) throws XMLDBException {
        checkOpen();
        try {
            Configuration config = new Configuration(configuration.getDocumentElement(), false);
            col.createCollection(path, config);

            // Traverse path to get newly created collection
            org.xmldb.api.base.Collection col = this;
            if (path.indexOf("/") != -1) {
View Full Code Here

    /* see superclass for documentation */
    public void createIndexer(Document configuration) throws XMLDBException {
        checkOpen();
        try {
            col.createIndexer(new Configuration(configuration, false));
        } catch (Exception e) {
            throw FaultCodes.createXMLDBException(e);
        }
    }
View Full Code Here

    void init() throws DBException {
        // Bootstrap the System Collection
        try {
            Document sysDoc = DOMParser.toDocument(SYSCOL_DEFINITION);
            Configuration sysCfg = new Configuration(sysDoc, false);
            setConfig(sysCfg);
        } catch (Exception e) {
            log.fatal("Failed to generate system collection '" + SYSCOL + "'", e);

            // TODO: System.exit() CANNOT be good here.
View Full Code Here

            doc.appendChild(index);
        }

        Collection col = getCollection((String) message.get(COLLECTION));
        Configuration config = new Configuration(doc.getDocumentElement(), false);
        col.createIndexer(config);

        Hashtable result = new Hashtable();
        result.put(RESULT, message.get(NAME));
        return result;
View Full Code Here

    public void init() throws DBException {
        // Bootstrap the Meta Collection
        try {
            Document metaDoc = DOMParser.toDocument(METACOL_DEFINITION);
            Configuration metaCfg = new Configuration(metaDoc, false);
            setConfig(metaCfg);
        } catch (Exception e) {
            if (log.isFatalEnabled()) {
                log.fatal("FATAL ERROR: Generating System Collection '" + METACOL + "'", e);
            }
View Full Code Here

                        + "  <filer class='org.apache.xindice.core.filer.BTreeFiler'/>"
                        + "</collection>";

                try {
                    Document cfgDoc = DOMParser.toDocument(cfgText);
                    Configuration cfg = new Configuration(cfgDoc, false);
                    childcol = current.createCollection(segment, cfg);
                } catch (DBException de) {
                    throw de;
                } catch (Exception e) {
                    throw new DBException(FaultCodes.getFaultCode(e));
View Full Code Here

                    if (type != null) {
                        e.setAttribute("type", type);
                    }

                    idxMgr.create(new Configuration(e));
                }
            } catch (Exception e) {
                if (log.isWarnEnabled()) {
                    log.warn("ignored exception", e);
                }
View Full Code Here

TOP

Related Classes of org.apache.xindice.util.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.