Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.Configuration


        // that may be contained in the configuration we will make the
        // configuration consist only of the remain torque specific
        // properties that are contained in the configuration. First
        // look for properties that are in the "torque" namespace.

        Configuration subConf = conf.subset("torque");

        if (!subConf.isEmpty())
        {
            setConfiguration(subConf);
        }

        dbMaps = new HashMap();
View Full Code Here


    private final void initAdapters(Configuration conf)
            throws TorqueException
    {
        log.debug("initAdapters(" + conf + ")");
        adapterMap = new HashMap();
        Configuration c = conf.subset("database");

        if (c != null)
        {
            boolean foundAdapters = false;

            try
            {
                for (Iterator it = c.getKeys(); it.hasNext(); )
                {
                    String key = (String) it.next();
                    if (key.endsWith("adapter"))
                    {
                        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

    private void initDataSourceFactories(Configuration conf)
            throws TorqueException
    {
        log.debug("initDataSourceFactories(" + conf + ")");
        dsFactoryMap = new HashMap();
        Configuration c = conf.subset("dsfactory");
        if (c != null)
        {
            boolean foundFactories = false;

            try
            {
                for (Iterator it = c.getKeys(); it.hasNext();)
                {
                    String key = (String) it.next();
                    if (key.endsWith("factory"))
                    {
                        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);
                        foundFactories = true;
                    }
                }
                if (!foundFactories)
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)
        {
            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

     */
    private void initJNDI(Configuration configuration) throws TorqueException
    {
        log.debug("Starting initJNDI");
        Hashtable env = null;
        Configuration c = configuration.subset("jndi");
        if (c == null)
        {
            throw new TorqueException(
                "JndiDataSourceFactory requires a jndi "
                    + "path property to lookup the DataSource in JNDI.");
        }
        try
        {
            Iterator i = c.getKeys();
            while (i.hasNext())
            {
                String key = (String) i.next();
                if (key.equals("path"))
                {
                    path = c.getString(key);
                    log.debug("JNDI path: " + path);
                }
                else if (key.equals("ttl"))
    {
        ttl = c.getLong(key, ttl);
                    log.debug("Time between context lookups: " + ttl);
    }
                else
                {
                    if (env == null)
                    {
                        env = new Hashtable();
                    }
                    String value = c.getString(key);
                    env.put(key, value);
                    log.debug("Set jndi property: " + key + "=" + value);
                }
            }
            if (env == null)
View Full Code Here

     */
    private void initDataSource(Configuration configuration)
        throws TorqueException
    {
        log.debug("Starting initDataSources");
        Configuration c = configuration.subset("datasource");
        try
        {
            if (c != null)
            {
                Object ds = null;
                Iterator i = c.getKeys();
                while (i.hasNext())
                {
                    String key = (String) i.next();
                    if (key.equals("classname"))
                    {
                        String classname = c.getString(key);
                        log.debug("Datasource class: " + classname);

                        Class dsClass = Class.forName(classname);
                        ds = dsClass.newInstance();
                    }
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)
        {
            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

        throws TorqueException
    {
        log.debug("Starting initTorqueClassic");
        TorqueClassicDataSource ds = new TorqueClassicDataSource();

        Configuration c = null;

        c = Torque.getConfiguration().subset(DEFAULT_POOL_KEY);
        applyConfiguration(c, ds);

        c = configuration.subset(POOL_KEY);
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.