Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.HierarchicalConfiguration


            Properties properties = getSession().getProperties();
            List<HierarchicalConfiguration> allProperties =
                configuration.configurationsAt("javaMailProperties.property");
            for (int i = 0; i < allProperties.size(); i++)
            {
                HierarchicalConfiguration propConf = allProperties.get(i);
                properties.setProperty(
                        propConf.getString("[@name]"),
                        propConf.getString("[@value]"));
                if (logger.isDebugEnabled())
                {
                    StringBuilder messageBuffer =
                        new StringBuilder("Set property name: ");
                    messageBuffer.append(propConf.getString("[@name]"));
                    messageBuffer.append(" to: ");
                    messageBuffer.append(
                        propConf.getString("[@value]"));
                    logger.debug(messageBuffer.toString());
                }
            }
        }
    }   
View Full Code Here


            List<HierarchicalConfiguration> fetchConfs = conf.configurationsAt("fetch");
            for (int i = 0; i < fetchConfs.size(); i++)
            {
                // read configuration
                HierarchicalConfiguration fetchConf = fetchConfs.get(i);
                Long interval = fetchConf.getLong("interval");

                FetchMail fetcher = new FetchMail();
                   
                fetcher.setLog(logger);
                fetcher.setDNSService(dns);
View Full Code Here

        List<HierarchicalConfiguration> allAccounts = configuration.configurationsAt("accounts");
        if (allAccounts.size() < 1)
            throw new ConfigurationException("Missing <accounts> section.");
        if (allAccounts.size() > 1)
            throw new ConfigurationException("Too many <accounts> sections, there must be exactly one");
        HierarchicalConfiguration accounts = allAccounts.get(0);

   
        if (accounts.getKeys().hasNext() == false)
            throw new ConfigurationException("Missing <account> section.");

        List<Node> accountsChildren = accounts.getRoot().getChildren();
        int i = 0;

        // Create an Account for every configured account
        for (Node accountsChild: accountsChildren) {
           
            String accountsChildName = accountsChild.getName();
       
            HierarchicalConfiguration accountsChildConfig = accounts.configurationAt(accountsChildName);
            if ("alllocal".equals(accountsChildName))
            {
                // <allLocal> is dynamic, save the parameters for accounts to
                // be created when the task is triggered
                getParsedDynamicAccountParameters().add(
                    new ParsedDynamicAccountParameters(i, accountsChildConfig));
                continue;
            }

            if ("account".equals(accountsChildName))
            {
                // Create an Account for the named user and
                // add it to the list of static accounts
                getStaticAccounts().add(
                    new Account(
                        i,
                        parsedConfiguration,
                        accountsChildConfig.getString("[@user]"),
                        accountsChildConfig.getString("[@password]"),
                        accountsChildConfig.getString("[@recipient]"),
                        accountsChildConfig.getBoolean(
                            "[@ignorercpt-header]"),
                        accountsChildConfig.getString("[@customrcpt-header]",""),
                        getSession()));
                continue;
            }

            throw new ConfigurationException(
View Full Code Here

            Processor mailProcessor = new MailCamelProcessor();
            Processor removePropsProcessor = new RemovePropertiesProcessor();
           
            List<HierarchicalConfiguration> processorConfs = config.configurationsAt("processor");
            for (int i = 0; i < processorConfs.size(); i++) {
                final HierarchicalConfiguration processorConf = processorConfs.get(i);
                String processorName = processorConf.getString("[@name]");

               
                mailets.put(processorName, new ArrayList<MailetManagement>());
                matchers.put(processorName, new ArrayList<MatcherManagement>());

                RouteDefinition processorDef = from(getEndpoint(processorName)).routeId(processorName).inOnly()
                // store the logger in properties
                .setProperty(MatcherSplitter.LOGGER_PROPERTY, constant(logger));  

                final List<HierarchicalConfiguration> mailetConfs = processorConf.configurationsAt("mailet");
                // Loop through the mailet configuration, load
                // all of the matcher and mailets, and add
                // them to the processor.
                for (int j = 0; j < mailetConfs.size(); j++) {
                    HierarchicalConfiguration c = mailetConfs.get(j);

                    // We need to set this because of correctly parsing comma
                    String mailetClassName = c.getString("[@class]");
                    String matcherName = c.getString("[@match]", null);
                    String invertedMatcherName = c.getString("[@notmatch]", null);
               
                    Mailet mailet = null;
                    Matcher matcher = null;
                    try {
View Full Code Here

        }
       
        logger.info("Defaultdomain: " + defaultDomain);
       
        if (conf.getKeys("helloName").hasNext()) {
            HierarchicalConfiguration helloNameConfig = conf.configurationAt("helloName");
            boolean autodetect = helloNameConfig.getBoolean("[@autodetect]", true);
            if (autodetect) {
                try {
                    helloName = dns.getHostName(dns.getLocalHost());
                } catch (UnknownHostException e) {
                    helloName = "localhost";
View Full Code Here

        {
            throw new ConfigurationException("Only one external virtualhosts configuration file allowed, multiple filenames found.");
        }

        // Virtualhost configuration object
        Configuration vhostConfiguration = new HierarchicalConfiguration();

        // Load from embedded configuration if possible
        if (!vhostConfig.subset("virtualhost").isEmpty())
        {
            vhostConfiguration = vhostConfig;
        }
        else
        {
        // Load from the external configuration if possible
        for (String fileName : vhostFiles)
          {
              // Open the vhosts XML file and copy values from it to our config
                _vhostsFile = new File(fileName);
                if (!_vhostsFile.exists())
                {
                    throw new ConfigurationException("Virtualhosts file does not exist");
                }
            vhostConfiguration = parseConfig(new File(fileName));

                // save the default virtualhost name
                String defaultVirtualHost = vhostConfiguration.getString("default");
                _configuration.setProperty("virtualhosts.default", defaultVirtualHost);
            }
        }

        // Now extract the virtual host names from the configuration object
        List hosts = vhostConfiguration.getList("virtualhost.name");
        for (int j = 0; j < hosts.size(); j++)
        {
            String name = (String) hosts.get(j);

            // Add the virtual hosts to the server configuration
            VirtualHostConfiguration virtualhost = new VirtualHostConfiguration(name, vhostConfiguration.subset("virtualhost." + name));
            _virtualHosts.put(virtualhost.getName(), virtualhost);
        }
    }
View Full Code Here

    public void load(Reader in) throws ConfigurationException
    {
        PropertyListParser parser = new PropertyListParser(in);
        try
        {
            HierarchicalConfiguration config = parser.parse();
            setRoot(config.getRoot());
        }
        catch (ParseException e)
        {
            throw new ConfigurationException(e);
        }
View Full Code Here

      }
      child = Property();
            if (child.getValue() instanceof HierarchicalConfiguration)
            {
                // prune & graft the nested configuration to the parent configuration
                HierarchicalConfiguration conf = (HierarchicalConfiguration) child.getValue();
                Node root = conf.getRoot();
                root.setName(child.getName());
                children.add(root);
            }
            else
            {
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    protected void doConfigure(HierarchicalConfiguration config) throws ConfigurationException {
        super.doConfigure(config);
        HierarchicalConfiguration handlerConfiguration = config.configurationAt("handler");
        List<HierarchicalConfiguration> accounts = handlerConfiguration.configurationsAt("administrator_accounts.account");
        for (int i = 0; i < accounts.size(); i++) {
            adminAccounts.put(accounts.get(i).getString("[@login]"), accounts.get(i).getString("[@password]"));
        }
    }
View Full Code Here

    }
   
   
    @PostConstruct
    public void init() throws Exception {
        HierarchicalConfiguration handlerchainConfig = config.configurationAt("handler.handlerchain");
        if (handlerchainConfig.getString("[@coreHandlersPackage]") == null)
            handlerchainConfig.addProperty("[@coreHandlersPackage]", coreHandlersPackage);
       
        loadHandlers(handlerchainConfig);    
       
        wireExtensibleHandlers();
    }
View Full Code Here

TOP

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

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.