Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.Configuration


        // we just blithely cast to RunData as if another object
        // or null is passed in we'll throw an appropriate runtime
        // exception.
        dataURI = new DataURI((RunData) data);

        Configuration conf =
                Turbine.getConfiguration().subset(CONTENT_TOOL_PREFIX);

        if (conf != null)
        {
            wantRelative = conf.getBoolean(CONTENT_TOOL_RELATIVE_KEY,
                    CONTENT_TOOL_RELATIVE_DEFAULT);

            wantEncoding = conf.getBoolean(CONTENT_TOOL_ENCODING_KEY,
                    CONTENT_TOOL_ENCODING_DEFAULT);
        }

        if (!wantEncoding)
        {
View Full Code Here


     * @param defaultExt The default used when the default defined in the
     *                   properties file is missing or misconfigured.
     */
    protected void initConfiguration(String defaultExt)
    {
        Configuration config = getConfiguration();

        //
        // Should modify the configuration class to take defaults
        // here, should have to do this.
        //
        String[] fileExtensionAssociations =
                config.getStringArray(TEMPLATE_EXTENSIONS);

        if (fileExtensionAssociations == null ||
            fileExtensionAssociations.length == 0)
        {
            fileExtensionAssociations = new String[1];
            fileExtensionAssociations[0] = config.getString(
                    DEFAULT_TEMPLATE_EXTENSION, defaultExt);
        }

        configuration.put(TEMPLATE_EXTENSIONS, fileExtensionAssociations);

        /*
         * We need some better error checking here and should probably
         * throw an exception here if these things aren't set
         * up correctly.
         */

        String[] copyParams = {
            DEFAULT_PAGE,
            DEFAULT_SCREEN,
            DEFAULT_LAYOUT,
            DEFAULT_NAVIGATION,
            DEFAULT_ERROR_SCREEN,
            DEFAULT_LAYOUT_TEMPLATE,
            DEFAULT_SCREEN_TEMPLATE
        };

        for (int i = 0; i < copyParams.length; i++)
        {
            configuration.put(copyParams[i], config.getString(copyParams[i], ""));
        }
    }
View Full Code Here

     * This method sets up the template cache.
     */
    private void initJsp()
        throws Exception
    {
        Configuration config = getConfiguration();

        // Set relative paths from config.
        // Needed for javax.servlet.RequestDispatcher
        relativeTemplatePaths = config.getStringArray(TEMPLATE_PATH_KEY);

        // Use Turbine Servlet to translate the template paths.
        templatePaths = new String [relativeTemplatePaths.length];
        for (int i=0; i < relativeTemplatePaths.length; i++)
        {
            relativeTemplatePaths[i] = warnAbsolute(relativeTemplatePaths[i]);

            templatePaths[i] = Turbine.getRealPath(relativeTemplatePaths[i]);
        }

        bufferSize = config.getInt(JspService.BUFFER_SIZE_KEY,
            JspService.BUFFER_SIZE_DEFAULT);
    }
View Full Code Here

        // or null is passed in we'll throw an appropriate runtime
        // exception.

        templateURI = new TemplateURI((RunData) data);

        Configuration conf =
                Turbine.getConfiguration().subset(TEMPLATE_LINK_PREFIX);

        if (conf != null)
        {
            wantRelative = conf.getBoolean(TEMPLATE_LINK_RELATIVE_KEY,
                    TEMPLATE_LINK_RELATIVE_DEFAULT);
        }

    }
View Full Code Here

     * thread.
     */
    public void init()
            throws InitializationException
    {
        Configuration conf = getConfiguration();

        try
        {
            scheduleQueue = new JobQueue();
            mainLoop = new MainLoop();

            List jobProps = conf.getList("scheduler.jobs");
            List jobs = new Vector();
            // If there are scheduler.jobs defined then set up a job vector
            // for the scheduleQueue
            if (!jobProps.isEmpty())
            {
                for (int i = 0; i < jobProps.size(); i++)
                {
                    String jobName = (String) jobProps.get(i);
                    String jobPrefix = "scheduler.job." + jobName;

                    String jobId = conf.getString(jobPrefix + ".ID", null);
                    if (StringUtils.isEmpty(jobId))
                    {
                        throw new Exception(
                                "There is an error in the TurbineResources.properties file. \n"
                                + jobPrefix + ".ID is not found.\n");
                    }

                    int sec = conf.getInt(jobPrefix + ".SECOND", -1);
                    int min = conf.getInt(jobPrefix + ".MINUTE", -1);
                    int hr = conf.getInt(jobPrefix + ".HOUR", -1);
                    int wkday = conf.getInt(jobPrefix + ".WEEKDAY", -1);
                    int dayOfMonth = conf.getInt(jobPrefix + ".DAY_OF_MONTH", -1);

                    JobEntry je = new JobEntry(
                            sec,
                            min,
                            hr,
View Full Code Here

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

        catchErrors = conf.getBoolean(CATCH_ERRORS_KEY, CATCH_ERRORS_DEFAULT);

        conf.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
                SimpleLog4JLogSystem.class.getName());
        conf.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM
                + ".log4j.category", "velocity");

        Velocity.setExtendedProperties(createVelocityProperties(conf));
        Velocity.init();
    }
View Full Code Here

     */
    private void initPullService()
        throws Exception
    {
        // This is the per-service configuration, prefixed with services.PullService
        Configuration conf = getConfiguration();

        // Get the resources directory that is specificed
        // in the TR.props or default to "resources", relative to the webapp.
        resourcesDirectory = conf.getString(
            TOOL_RESOURCES_DIR_KEY,
            TOOL_RESOURCES_DIR_DEFAULT);

        // Should we refresh the tool box on a per
        // request basis.
        refreshToolsPerRequest =
            conf.getBoolean(
                TOOLS_PER_REQUEST_REFRESH_KEY,
                TOOLS_PER_REQUEST_REFRESH_DEFAULT);

        // Log the fact that the application tool box will
        // be refreshed on a per request basis.
View Full Code Here

    {
        // And for reasons I never really fully understood,
        // the tools directive is toplevel without the service
        // prefix. This is brain-damaged but for legacy reasons we
        // keep this. So this is the global turbine configuration:
        Configuration conf = Turbine.getConfiguration();

        // Grab each list of tools that are to be used (for global scope,
        // request scope, authorized scope, session scope and persistent
        // scope tools). They are specified respectively in the TR.props
        // like this:
        //
        // tool.global.ui = org.apache.turbine.util.pull.UIManager
        // tool.global.mm = org.apache.turbine.util.pull.MessageManager
        //
        // tool.request.link = org.apache.turbine.services.pull.tools.TemplateLink
        //
        // tool.session.basket = org.sample.util.ShoppingBasket;
        //
        // tool.persistent.ui = org.apache.turbine.services.pull.util.PersistentUIManager

        log.debug("Global Tools:");
        globalTools     = getTools(conf.subset(GLOBAL_TOOL));
        log.debug("Request Tools:");
        requestTools    = getTools(conf.subset(REQUEST_TOOL));
        log.debug("Session Tools:");
        sessionTools    = getTools(conf.subset(SESSION_TOOL));
        log.debug("Authorized Tools:");
        authorizedTools = getTools(conf.subset(AUTHORIZED_TOOL));
        log.debug("Persistent Tools:");
        persistentTools = getTools(conf.subset(PERSISTENT_TOOL));

        // Create and populate the global context right now

        // This is unholy, because it entwines the VelocityService and
        // the Pull Service even further. However, there isn't much we can
View Full Code Here

             */

        }
        catch (Exception e)
        {
            Configuration conf = Turbine.getConfiguration();

            if (e instanceof DataBackendException)
            {
                log.error(e);
            }

            // Set Error Message and clean out the user.
            data.setMessage(conf.getString(TurbineConstants.LOGIN_ERROR, ""));
            data.setUser (TurbineSecurity.getAnonymousUser());

            String loginTemplate = conf.getString(
                    TurbineConstants.TEMPLATE_LOGIN);

            if (StringUtils.isNotEmpty(loginTemplate))
            {
                // We're running in a templating solution
                data.setScreenTemplate(loginTemplate);
            }
            else
            {
                data.setScreen(conf.getString(TurbineConstants.SCREEN_LOGIN));
            }
        }
    }
View Full Code Here

            user.setHasLoggedIn(Boolean.FALSE);
            TurbineSecurity.saveUser(user);
        }

        Configuration conf = Turbine.getConfiguration();

        data.setMessage(conf.getString(TurbineConstants.LOGOUT_MESSAGE, ""));

        // This will cause the acl to be removed from the session in
        // the Turbine servlet code.
        data.setACL(null);

        // Retrieve an anonymous user.
        data.setUser(TurbineSecurity.getAnonymousUser());
        data.save();

        // In the event that the current screen or related navigations
        // require acl info, we cannot wait for Turbine to handle
        // regenerating acl.
        data.getSession().removeAttribute(AccessControlList.SESSION_KEY);

        // If this action name is the value of action.logout then we are
        // being run before the session validator, so we don't need to
        // set the screen (we assume that the session validator will handle
        // that). This is basically still here simply to preserve old behaviour
        // - it is recommended that action.logout is set to "LogoutUser" and
        // that the session validator does handle setting the screen/template
        // for a logged out (read not-logged-in) user.
        if (!conf.getString(TurbineConstants.ACTION_LOGOUT_KEY,
                            TurbineConstants.ACTION_LOGOUT_DEFAULT)
            .equals(TurbineConstants.ACTION_LOGOUT_DEFAULT))
        {
            data.setScreen(conf.getString(TurbineConstants.SCREEN_HOMEPAGE));
        }
    }
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.