Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.SubnodeConfiguration


     * Tests whether manipulations of a subnode configuration trigger correct
     * events.
     */
    public void testSubnodeChangedEvent()
    {
        SubnodeConfiguration sub = ((HierarchicalConfiguration) config)
                .configurationAt(EXIST_PROPERTY);
        sub.addProperty("newProp", "newValue");
        checkSubnodeEvent(l
                .nextEvent(HierarchicalConfiguration.EVENT_SUBNODE_CHANGED),
                true);
        checkSubnodeEvent(l
                .nextEvent(HierarchicalConfiguration.EVENT_SUBNODE_CHANGED),
View Full Code Here


        Properties parameters = new Properties();

        List params = config.configurationsAt(PARAM_ELEMENT);
        for(Iterator it = params.iterator(); it.hasNext();) {
            // HierarchicalConfiguration sub = (HierarchicalConfiguration)it.next();
            SubnodeConfiguration sub = (SubnodeConfiguration)it.next();

            String name = null;
            String value = null;
            // String name = sub.getString("@" + NAME_ATTRIBUTE);
            // String value = sub.getString("@" + VALUE_ATTRIBUTE);
            List nameAtts = sub.getRootNode().getAttributes(NAME_ATTRIBUTE);
            List valueAtts = sub.getRootNode().getAttributes(VALUE_ATTRIBUTE);
            if (nameAtts != null && nameAtts.size() > 0) {
                ConfigurationNode nameAttNode = (ConfigurationNode)nameAtts.get(0);
                name = (String)nameAttNode.getValue();
            }
            if (valueAtts != null && valueAtts.size() > 0) {
View Full Code Here

     * @throws ConfigurationException if the attribute is not found
     */
    protected String getAttribute(HierarchicalConfiguration config, String name)
            throws ConfigurationException {
        // String attribute = config.getString("@" + name);
        SubnodeConfiguration xmlconfig = (SubnodeConfiguration)config;
        ConfigurationNode rootNode = xmlconfig.getRootNode();
        String rootNodeName = rootNode.getName();
        List atts = rootNode.getAttributes(name);
        String attribute = null;
        // Object obj = config.getProperty(name);
        if (atts != null && atts.size() > 0) {
View Full Code Here

        else
        {
            Iterator 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

        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

      Class en = PropertiesConfigurationHelper.CONFIGURATION_SECTIONS.get(section);
      if (en==null){
        Logger.warn(section  + " is not a valid configuration section, it will be skipped!");
        continue;
      }
      SubnodeConfiguration subConf=c.getSection(section);
      Iterator<String> it = subConf.getKeys();
      while (it.hasNext()){
        String key = (it.next());
        Object value =subConf.getString(key);
        key=key.replace(doubleDot, dot);//bug on the Apache library: if the key contain a dot, it will be doubled!
        try {
          Logger.info("Setting "+value+ " to "+key);
          PropertiesConfigurationHelper.setByKey(en, key, value);
        } catch (Exception e) {
View Full Code Here

          + Tokens.REXSTER_GRAPH_LOCATION);
    }

    // get the <properties> section of the xml configuration
    final HierarchicalConfiguration graphSectionConfig = (HierarchicalConfiguration) context.getProperties();
    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);
    }

    try {

      final String username = orientDbSpecificConfiguration.getString("username", "");
      final String password = orientDbSpecificConfiguration.getString("password", "");

      // Caching must be turned off. OrientDB has different layers of cache:
      // http://code.google.com/p/orient/wiki/Caching There's one Level1 cache per OGraphDatabase instance
      // and one level2 per JVM. If a OGraphDatabase caches a vertex and then you change it in
      // another thread/transaction you could see the older one. To fix it just disable the Level1 cache.
View Full Code Here

        {
            throw new IllegalArgumentException(
                    "Configuration must not be null!");
        }

        SubnodeConfiguration tmpconfiguration = null;
        ConfigurationNode tmpnode = null;
        try
        {
            tmpconfiguration = config.configurationAt(key);
            tmpnode = tmpconfiguration.getRootNode();
        }
        catch (IllegalArgumentException iex)
        {
            // If we reach this block, the key does not have exactly one value
            if (!optional || config.getMaxIndex(key) > 0)
View Full Code Here

        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

     * events.
     */
    @Test
    public void testSubnodeChangedEvent()
    {
        SubnodeConfiguration sub = ((HierarchicalConfiguration) config)
                .configurationAt(EXIST_PROPERTY);
        sub.addProperty("newProp", "newValue");
        checkSubnodeEvent(l
                .nextEvent(HierarchicalConfiguration.EVENT_SUBNODE_CHANGED),
                true);
        checkSubnodeEvent(l
                .nextEvent(HierarchicalConfiguration.EVENT_SUBNODE_CHANGED),
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.