Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.SubnodeConfiguration


        else
        {
            Iterator<HierarchicalConfiguration> iter = list.iterator();
            while (iter.hasNext())
            {
                SubnodeConfiguration config = (SubnodeConfiguration) iter.next();
                if (config.getRootNode().equals(node))
                {
                    return new XMLBeanDeclaration(config, node);
                }
            }
            throw new ConfigurationRuntimeException("Unable to match node for " + node.getName());
View Full Code Here


            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_LOCATION);
        }

        // get the <properties> section of the xml configuration
        final HierarchicalConfiguration graphSectionConfig = (HierarchicalConfiguration) context.getProperties();
        SubnodeConfiguration dexSpecificConfiguration;
        String sparkseeConfig;

        try {
            // allow the properties to be optional
            dexSpecificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
            sparkseeConfig = dexSpecificConfiguration.getString(SPARKSEE_CONFIGURATION_PROPERTY, null);
        } catch (IllegalArgumentException iae) {
            sparkseeConfig = null;
        }

        try {
View Full Code Here

    public Graph configureGraphInstance(final GraphConfigurationContext context) throws GraphConfigurationException {
        final String graphFile = context.getProperties().getString(Tokens.REXSTER_GRAPH_LOCATION, null);

        // get the <properties> section of the xml configuration
        final HierarchicalConfiguration graphSectionConfig = (HierarchicalConfiguration) context.getProperties();
        SubnodeConfiguration sailSpecificConfiguration = null;

        try {
            sailSpecificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
        } catch (IllegalArgumentException iae) {
            // it's ok if this is missing.  it is optional depending on the settings
        }

        // graph-file and data-directory must be present for native, sparql, and linked-data
        if ((sailType.equals(SAIL_TYPE_NATIVE) || sailType.equals(SAIL_TYPE_SPARQL) || sailType.equals(SAIL_TYPE_LINKED_DATA))
                && (graphFile == null || graphFile.trim().length() == 0)) {
            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_LOCATION);
        }

        try {
            SailGraph graph = null;

            if (this.sailType.equals(SAIL_TYPE_MEMORY)) {

                if (graphFile != null && !graphFile.isEmpty()) {
                    logger.warn("[" + MemoryStoreSailGraph.class.getSimpleName() + "] doesn't support the graph-file parameter.  It will be ignored.");
                }

                graph = new MemoryStoreSailGraph();
            } else if (this.sailType.equals(SAIL_TYPE_LINKED_DATA)) {
                RexsterApplicationGraph baseGraph = context.getGraphs().get(graphFile);
                if (null == baseGraph) {
                    throw new GraphConfigurationException("no such base graph for LinkedDataSail graph: " + graphFile);
                }
                if (!(baseGraph.getGraph() instanceof SailGraph)) {
                    throw new GraphConfigurationException("base graph for LinkedDataSail graph must be an instance of SailGraph");
                }
                if (baseGraph.getGraph() instanceof LinkedDataSailGraph) {
                    throw new GraphConfigurationException("LinkedDataSail graph based on another LinkedDataSail graph");
                }

                graph = new LinkedDataSailGraph((SailGraph) baseGraph.getGraph());
            } else if (this.sailType.equals(SAIL_TYPE_NATIVE)) {
                String configTripleIndices = "";
                if (sailSpecificConfiguration != null) {
                    configTripleIndices = sailSpecificConfiguration.getString("triple-indices", "");
                }

                if (configTripleIndices != null && configTripleIndices.trim().length() > 0) {
                    graph = new NativeStoreSailGraph(graphFile, configTripleIndices);
                } else {
View Full Code Here

            throw new GraphConfigurationException("base graph for IdGraph must be an instance of KeyIndexableGraph");
        }

        // get the <properties> section of the xml configuration
        final HierarchicalConfiguration graphSectionConfig = (HierarchicalConfiguration) context.getProperties();
        SubnodeConfiguration specificConfiguration;

        try {
            specificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
        } catch (IllegalArgumentException iae) {
            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_PROPERTIES);
        }

        boolean supportVertexIds = specificConfiguration.getBoolean("supportVertexIds", true);
        boolean supportEdgeIds = specificConfiguration.getBoolean("supportEdgeIds", true);

        return new IdGraph((KeyIndexableGraph) baseGraph.getGraph(), supportVertexIds, supportEdgeIds);
    }
View Full Code Here

        final boolean highAvailabilityMode = context.getProperties().getBoolean(Tokens.REXSTER_GRAPH_HA, false);

        // get the <properties> section of the xml configuration
        final HierarchicalConfiguration graphSectionConfig = (HierarchicalConfiguration) context.getProperties();
        SubnodeConfiguration neo4jSpecificConfiguration;

        try {
            neo4jSpecificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
        } catch (IllegalArgumentException iae) {
            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_PROPERTIES);
        }

        try {

            // properties to initialize the neo4j instance.
            final HashMap<String, String> neo4jProperties = new HashMap<String, String>();

            // read the properties from the xml file and convert them to properties
            // to be injected into neo4j.
            final Iterator<String> neo4jSpecificConfigurationKeys = neo4jSpecificConfiguration.getKeys();
            while (neo4jSpecificConfigurationKeys.hasNext()) {
                String key = neo4jSpecificConfigurationKeys.next();

                // replace the ".." put in play by apache commons configuration.  that's expected behavior
                // due to parsing key names to xml.
                neo4jProperties.put(key.replace("..", "."), neo4jSpecificConfiguration.getString(key));
            }

            if (highAvailabilityMode) {
                if (!neo4jProperties.containsKey("ha.machine_id")) {
                    throw new GraphConfigurationException("Check graph configuration. Neo4j HA requires [ha.machine_id] in the <properties> of the configuration");
View Full Code Here

public class MongoDBGraphConfiguration implements GraphConfiguration {

    @Override
    public Graph configureGraphInstance(Configuration configuration) throws GraphConfigurationException {
        final HierarchicalConfiguration graphSectionConfig = (HierarchicalConfiguration) configuration;
        SubnodeConfiguration orientDbSpecificConfiguration;

        try {
            orientDbSpecificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
        } catch (IllegalArgumentException iae) {
            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_PROPERTIES);
        }

        final String username = orientDbSpecificConfiguration.getString("username", null);
        final String password = orientDbSpecificConfiguration.getString("password", null);
        final String host = orientDbSpecificConfiguration.getString("host", "localhost");
        final int port = orientDbSpecificConfiguration.getInt("port", 27017);

        if(username != null && password != null) {
            // create mongo graph with username and password
            try {
                return new MongoDBGraph(host, port, username, password);
View Full Code Here

        logger.info("browsscap.ini loaded and processed " + browscap.size() + " entries in " + timer.elapsedMillis()
                + "ms");
    }

    private String digForProperty(String sectionName, String property, HierarchicalINIConfiguration browscapIni) {
        SubnodeConfiguration sectionValues = browscapIni.getSection(sectionName);

        String propertyValue = sectionValues.getString(property);

        if (null != propertyValue) {
            return propertyValue;
        } else {
            String parentSection = sectionValues.getString("Parent");

            if (null != parentSection) {
                return digForProperty(parentSection, property, browscapIni);
            } else {
                return null;
View Full Code Here

public class KVGraphConfiguration implements GraphConfiguration {

    @Override
    public Graph configureGraphInstance(Configuration configuration) throws GraphConfigurationException {
        final HierarchicalConfiguration graphSectionConfig = (HierarchicalConfiguration) configuration;
        SubnodeConfiguration kvSpecificConfiguration;

        try {
            kvSpecificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
        } catch (IllegalArgumentException iae) {
            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_PROPERTIES);
        }

        try {

            final String host = kvSpecificConfiguration.getString("host");
            final int port = kvSpecificConfiguration.getInt("port", 5000);
            final String storeName = kvSpecificConfiguration.getString("store-name");
            final String graphName = configuration.getString("graph-name");

            return new KVGraph(graphName, storeName, host, port);

        } catch (Exception ex) {
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.SubnodeConfiguration

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.