Package org.apache.stratum.configuration

Examples of org.apache.stratum.configuration.Configuration


     */
    public void init()
    {
        pools = (Map) new HashMap();

        Configuration configuration = getConfiguration();

        // Get the value for the default pool, but if there
        // isn't a value than fall back to the standard
        // "default" value.
        defaultPool = configuration.getString(DEFAULT_POOL, DEFAULT);

        // Create monitor thread
        Monitor monitor = new Monitor();
        // Indicate that this is a system thread. JVM will quit only when there
        // are no more active user threads. Settings threads spawned internally
View Full Code Here


    private void initVelocity() throws InitializationException
    {
        /*
         * Get the configuration for this service.
         */
        Configuration configuration = getConfiguration();

        /*
         * Now we have to perform a couple of path translations
         * for our log file and template paths.
         */
        String path = Turbine.getRealPath
            (configuration.getString(Velocity.RUNTIME_LOG, null));

        if (StringUtils.isValid(path))
        {
            configuration.setProperty(Velocity.RUNTIME_LOG, path);
        }
        else
        {
            String msg = VelocityService.SERVICE_NAME + " runtime log file " +
                "is misconfigured: '" + path + "' is not a valid log file";

            if (TurbineServlet.getServletConfig() instanceof TurbineConfig)
            {
                msg += ": TurbineConfig users must use a path relative to " +
                    "web application root";
            }
            throw new Error(msg);
        }

        /*
         * Get all the template paths where the velocity runtime should search
         * for templates and collect them into a separate vector to avoid
         * concurrent modification exceptions.
         */
        String key;
        Vector keys = new Vector();
        for (Iterator i = configuration.getKeys(); i.hasNext();)
        {
            key = (String) i.next();
            if (key.endsWith(RESOURCE_LOADER_PATH))
            {
                keys.add(key);
            }
        }

        /*
         * Loop through all template paths, clear the corresponding
         * velocity properties and translate them all to the webapp space.
         */

        int ind;
        Vector paths;
        String entry;
        for (Iterator i = keys.iterator(); i.hasNext();)
        {
            key = (String) i.next();
            paths = configuration.getVector(key,null);
            if (paths != null)
            {
                Velocity.clearProperty(key);
                configuration.clearProperty(key);

                for (Iterator j = paths.iterator(); j.hasNext();)
                {
                    path = (String) j.next();
                    if (path.startsWith(JAR_PREFIX + "file"))
                    {
                        /*
                         * A local jar resource URL path is a bit more
                         * complicated, but we can translate it as well.
                         */
                        ind = path.indexOf("!/");
                        if (ind >= 0)
                        {
                            entry = path.substring(ind);
                            path = path.substring(9,ind);
                        }
                        else
                        {
                            entry = "!/";
                            path = path.substring(9);
                        }
                        path = JAR_PREFIX + "file:" +
                            Turbine.getRealPath(path) + entry;
                    }
                    else if (path.startsWith(ABSOLUTE_PREFIX))
                    {
                        path = path.substring (ABSOLUTE_PREFIX.length(),
                                               path.length());
                    }
                    else if (!path.startsWith(JAR_PREFIX))
                    {
                        // But we don't translate remote jar URLs.
                        path = Turbine.getRealPath(path);
                    }
                    // Put the translated paths back to the configuration.
                    configuration.addProperty(key,path);
                }
            }
        }
        try
        {
View Full Code Here

TOP

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