Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.Configuration


            throws TorqueException
    {
        log.debug("initAdapters(" + conf + ")");
        adapterMap = new HashMap();

        Configuration c = conf.subset(Torque.DATABASE_KEY);
        if (c == null || c.isEmpty())
        {
            String error = "Invalid configuration : "
                    + "No keys starting with "
                    + Torque.TORQUE_KEY
                    + "."
                    + Torque.DATABASE_KEY
                    + " found in configuration";
            log.error(error);
            throw new TorqueException(error);
        }

        try
        {
            for (Iterator it = c.getKeys(); it.hasNext(); )
            {
                String key = (String) it.next();
                if (key.endsWith(DB.ADAPTER_KEY))
                {
                    String adapter = c.getString(key);
                    String handle = key.substring(0, key.indexOf('.'));
                    DB db = DBFactory.create(adapter);
                    // register the adapter for this name
                    adapterMap.put(handle, db);
                    log.debug("Adding " + adapter + " -> " + handle + " as Adapter");
View Full Code Here


            throws TorqueException
    {
        log.debug("initDataSourceFactories(" + conf + ")");
        dsFactoryMap = new HashMap();

        Configuration c = conf.subset(DataSourceFactory.DSFACTORY_KEY);
        if (c == null || c.isEmpty())
        {
            String error = "Invalid configuration: "
                    + "No keys starting with "
                    + Torque.TORQUE_KEY
                    + "."
                    + DataSourceFactory.DSFACTORY_KEY
                    + " found in configuration";
            log.error(error);
            throw new TorqueException(error);
        }

        try
        {
            for (Iterator it = c.getKeys(); it.hasNext();)
            {
                String key = (String) it.next();
                if (key.endsWith(DataSourceFactory.FACTORY_KEY))
                {
                    String classname = c.getString(key);
                    String handle = key.substring(0, key.indexOf('.'));
                    log.debug("handle: " + handle
                            + " DataSourceFactory: " + classname);
                    Class dsfClass = Class.forName(classname);
                    DataSourceFactory dsf =
                            (DataSourceFactory) dsfClass.newInstance();
                    dsf.initialize(c.subset(handle));
                    dsFactoryMap.put(handle, dsf);
                }
            }
        }
        catch (Exception e)
View Full Code Here

            throws TorqueException
    {
        log.debug("init(" + configFile + ")");
        try
        {
            Configuration conf = new PropertiesConfiguration(configFile);

            log.debug("Config Object is " + conf);
            init(conf);
        }
        catch (ConfigurationException e)
View Full Code Here

                property = property.substring(0, dot);

                MappedPropertyDescriptor mappedPD =
                    new MappedPropertyDescriptor(property, dsClass);
                Class propertyType = mappedPD.getMappedPropertyType();
                Configuration subProps = c.subset(property);
                // use reflection to set properties
                Iterator j = subProps.getKeys();
                while (j.hasNext())
                {
                    String subProp = (String) j.next();
                    String propVal = subProps.getString(subProp);
                    Object value = ConvertUtils.convert(propVal, propertyType);
                    PropertyUtils
                        .setMappedProperty(ds, property, subProp, value);

                    if (log.isDebugEnabled())
View Full Code Here

    protected ConnectionPoolDataSource initCPDS(Configuration configuration)
        throws TorqueException
    {
        log.debug("Starting initCPDS");
        ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
        Configuration c = Torque.getConfiguration();

        if (c == null || c.isEmpty())
        {
            log.warn("Global Configuration not set,"
                    + " no Default connection pool data source configured!");
        }
        else
        {
            Configuration conf = c.subset(DEFAULT_CONNECTION_KEY);
            applyConfiguration(conf, cpds);
        }

        Configuration conf = configuration.subset(CONNECTION_KEY);
        applyConfiguration(conf, cpds);

        return cpds;
    }
View Full Code Here

        schema = configuration.getString(SCHEMA_KEY, null);

        if (StringUtils.isEmpty(schema))
        {
            Configuration conf = Torque.getConfiguration();
            schema = conf.getString(DEFAULT_SCHEMA_KEY, null);
        }
    }
View Full Code Here

     */
    private void initJNDI(Configuration configuration) throws TorqueException
    {
        log.debug("Starting initJNDI");

        Configuration c = configuration.subset("jndi");
        if (c == null || c.isEmpty())
        {
            throw new TorqueException(
                "JndiDataSourceFactory requires a jndi "
                    + "path property to lookup the DataSource in JNDI.");
        }

        try
        {
            Hashtable env = new Hashtable();
            for (Iterator i = c.getKeys(); i.hasNext(); )
            {
                String key = (String) i.next();
                if (key.equals("path"))
                {
                    path = c.getString(key);
                    if (log.isDebugEnabled())
                    {
                        log.debug("JNDI path: " + path);
                    }
                }
                else if (key.equals("ttl"))
                {
                    ttl = c.getLong(key, ttl);
                    if (log.isDebugEnabled())
                    {
                        log.debug("Time between context lookups: " + ttl);
                    }
                }
                else
                {
                    String value = c.getString(key);
                    env.put(key, value);
                    if (log.isDebugEnabled())
                    {
                        log.debug("Set jndi property: " + key + "=" + value);
                    }
View Full Code Here

        log.debug("Starting initDataSource");
        try
        {
            Object ds = null;

            Configuration c = configuration.subset("datasource");
            if (c != null)
            {
                for (Iterator i = c.getKeys(); i.hasNext(); )
                {
                    String key = (String) i.next();
                    if (key.equals("classname"))
                    {
                        String classname = c.getString(key);
                        if (log.isDebugEnabled())
                        {
                            log.debug("Datasource class: " + classname);
                        }
View Full Code Here

    private SharedPoolDataSource initJdbc2Pool(Configuration configuration)
        throws TorqueException
    {
        log.debug("Starting initJdbc2Pool");
        SharedPoolDataSource ds = new SharedPoolDataSource();
        Configuration c = Torque.getConfiguration();

        if (c == null || c.isEmpty())
        {
            log.warn("Global Configuration not set,"
                    + " no Default pool data source configured!");
        }
        else
        {
            Configuration conf = c.subset(DEFAULT_POOL_KEY);
            applyConfiguration(conf, ds);
        }

        Configuration conf = configuration.subset(POOL_KEY);
        applyConfiguration(conf, ds);
        return ds;
    }
View Full Code Here

    private PerUserPoolDataSource initJdbc2Pool(Configuration configuration)
        throws TorqueException
    {
        log.debug("Starting initJdbc2Pool");
        PerUserPoolDataSource ds = new PerUserPoolDataSource();
        Configuration c = Torque.getConfiguration();

        if (c == null || c.isEmpty())
        {
            log.warn("Global Configuration not set,"
                    + " no Default pool data source configured!");
        }
        else
        {
            Configuration conf = c.subset(DEFAULT_POOL_KEY);
            applyConfiguration(conf, ds);
        }

        Configuration conf = configuration.subset(POOL_KEY);
        applyConfiguration(conf, ds);
        return ds;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.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.