Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.Configuration


     * @throws InitializationException if initialization fails.
     */
    public void init()
            throws InitializationException
    {
        Configuration conf = getConfiguration();

        int capacity = conf.getInt(POOL_CAPACITY_KEY,
                DEFAULT_POOL_CAPACITY);

        if (capacity <= 0)
        {
            throw new IllegalArgumentException("Capacity must be >0");
        }
        poolCapacity = capacity;

        debugPool = conf.getBoolean(POOL_DEBUG_KEY,
                POOL_DEBUG_DEFAULT);

        if (debugPool)
        {
            log.info("Activated Pool Debugging!");
View Full Code Here


     *
     * @throws InitializationException if initialization fails.
     */
    public void init() throws InitializationException
    {
        Configuration conf = getConfiguration();
        if (conf != null)
        {
            List loaders = conf.getList(CLASS_LOADERS);
            if (loaders != null)
            {
                for (int i = 0; i < loaders.size(); i++)
                {
                    try
                    {
                        classLoaders.add(
                                loadClass((String) loaders.get(i)).newInstance());
                    }
                    catch (Exception x)
                    {
                        throw new InitializationException(
                                "No such class loader '" +
                                (String) loaders.get(i) +
                                "' for TurbineFactoryService", x);
                    }
                }
            }

            String key,factory;
            for (Iterator i = conf.getKeys(OBJECT_FACTORY); i.hasNext();)
            {
                key = (String) i.next();
                factory = conf.getString(key);

                /*
                 * Store the factory to the table as a string and
                 * instantiate it by using the service when needed.
                 */
 
View Full Code Here

     */
    public void init()
            throws InitializationException
    {
        int cacheInitialSize = DEFAULT_INITIAL_CACHE_SIZE;
        Configuration conf = getConfiguration();
        if (conf != null)
        {
            try
            {
                cacheInitialSize = conf.getInt(INITIAL_CACHE_SIZE, DEFAULT_INITIAL_CACHE_SIZE);
                if (cacheInitialSize <= 0)
                {
                    throw new IllegalArgumentException(INITIAL_CACHE_SIZE + " must be >0");
                }
                cacheCheckFrequency = conf.getLong(CACHE_CHECK_FREQUENCY, DEFAULT_CACHE_CHECK_FREQUENCY);
                if (cacheCheckFrequency <= 0)
                {
                    throw new IllegalArgumentException(CACHE_CHECK_FREQUENCY + " must be >0");
                }
            }
View Full Code Here

        if (pool == null)
        {
            /* Check class specific capacity. */
            int capacity;

            Configuration conf = getConfiguration();
            capacity = conf.getInt(
                    POOL_CAPACITY_KEY + '.' + className,
                    poolCapacity);
            capacity = (capacity <= 0) ? poolCapacity : capacity;
            return capacity;
        }
View Full Code Here

     *         from the security service
     */
    public void doPerform(RunData data)
            throws TurbineException
    {
        Configuration conf = Turbine.getConfiguration();

        // Pull user from session.
        data.populate();

        // The user may have not logged in, so create a "guest/anonymous" user.
        if (data.getUser() == null)
        {
            log.debug("Fixing up empty User Object!");
            data.setUser(TurbineSecurity.getAnonymousUser());
            data.save();
        }

        // make sure we have some way to return a response
        if (!data.hasScreen() && StringUtils.isEmpty(
                data.getTemplateInfo().getScreenTemplate()))
        {
            String template = conf.getString(
                    TurbineConstants.TEMPLATE_HOMEPAGE);

            if (StringUtils.isNotEmpty(template))
            {
                data.getTemplateInfo().setScreenTemplate(template);
            }
            else
            {
                data.setScreen(conf.getString(
                        TurbineConstants.SCREEN_HOMEPAGE));
            }
        }
        // the session_access_counter can be placed as a hidden field in
        // forms.  This can be used to prevent a user from using the
        // browsers back button and submitting stale data.
        else if (data.getParameters().containsKey("_session_access_counter")
                && !TurbineSecurity.isAnonymousUser(data.getUser()))
        {
            // See comments in screens.error.InvalidState.
            if (data.getParameters().getInt("_session_access_counter")
                    < (((Integer) data.getUser().getTemp(
                    "_session_access_counter")).intValue() - 1))
            {
                if (data.getTemplateInfo().getScreenTemplate() != null)
                {
                    data.getUser().setTemp("prev_template",
                            data.getTemplateInfo().getScreenTemplate()
                            .replace('/', ','));
                    data.getTemplateInfo().setScreenTemplate(conf.getString(
                            TurbineConstants.TEMPLATE_INVALID_STATE));
                }
                else
                {
                    data.getUser().setTemp("prev_screen",
                                           data.getScreen().replace('/', ','));
                    data.setScreen(conf.getString(
                            TurbineConstants.SCREEN_INVALID_STATE));
                }
                data.getUser().setTemp("prev_parameters", data.getParameters());
                data.setAction("");
            }
View Full Code Here

     *         from the security service
     */
    public void doPerform(RunData data)
            throws TurbineException
    {
        Configuration conf = Turbine.getConfiguration();

        // Pull user from session.
        data.populate();

        // The user may have not logged in, so create a "guest/anonymous" user.
        if (data.getUser() == null)
        {
            log.debug("Fixing up empty User Object!");
            data.setUser(TurbineSecurity.getAnonymousUser());
            data.save();
        }

        // This is the secure sessionvalidator, so user must be logged in.
        if (!data.getUser().hasLoggedIn())
        {
            log.debug("User is not logged in!");

            // only set the message if nothing else has already set it
            // (e.g. the LogoutUser action).
            if (StringUtils.isEmpty(data.getMessage()))
            {
                data.setMessage(conf.getString(TurbineConstants.LOGIN_MESSAGE));
            }

            // Set the screen template to the login page.
            String loginTemplate =
                conf.getString(TurbineConstants.TEMPLATE_LOGIN);

            log.debug("Sending User to the Login Screen ("
                    + loginTemplate + ")");
            data.getTemplateInfo().setScreenTemplate(loginTemplate);

            // We're not doing any actions buddy! (except action.login which
            // will have been performed already)
            data.setAction(null);
        }

        log.debug("Login Check finished!");

        // Make sure we have some way to return a response.
        if (!data.hasScreen() && StringUtils.isEmpty(
                data.getTemplateInfo().getScreenTemplate()))
        {
            String template = conf.getString(
                    TurbineConstants.TEMPLATE_HOMEPAGE);

            if (StringUtils.isNotEmpty(template))
            {
                data.getTemplateInfo().setScreenTemplate(template);
            }
            else
            {
                data.setScreen(conf.getString(
                        TurbineConstants.SCREEN_HOMEPAGE));
            }
        }

        // The session_access_counter can be placed as a hidden field in
        // forms.  This can be used to prevent a user from using the
        // browsers back button and submitting stale data.
        // FIXME!! a template needs to be written to use this with templates.

        if (data.getParameters().containsKey("_session_access_counter")
                && !TurbineSecurity.isAnonymousUser(data.getUser()))
        {
            // See comments in screens.error.InvalidState.
            if (data.getParameters().getInt("_session_access_counter")
                    < (((Integer) data.getUser().getTemp(
                    "_session_access_counter")).intValue() - 1))
            {
                if (data.getTemplateInfo().getScreenTemplate() != null)
                {
                    data.getUser().setTemp("prev_template",
                            data.getTemplateInfo().getScreenTemplate()
                            .replace('/', ','));
                    data.getTemplateInfo().setScreenTemplate(conf.getString(
                            TurbineConstants.TEMPLATE_INVALID_STATE));
                }
                else
                {
                    data.getUser().setTemp("prev_screen",
                                           data.getScreen().replace('/', ','));
                    data.setScreen(conf.getString(
                            TurbineConstants.SCREEN_INVALID_STATE));
                }
                data.getUser().setTemp("prev_parameters", data.getParameters());
                data.setAction("");
            }
View Full Code Here

     * web application root, if neccessary
     */
    public void init()
            throws InitializationException
    {
        Configuration conf = getConfiguration();

        String repoPath = conf.getString(
                UploadService.REPOSITORY_KEY,
                UploadService.REPOSITORY_DEFAULT);

        if (!repoPath.startsWith("/"))
        {
            // If our temporary directory is in the application
            // space, try to create it. If this fails, throw
            // an exception.
            String testPath = Turbine.getRealPath(repoPath);
            File testDir = new File(testPath);
            if (!testDir.exists())
            {
                if (!testDir.mkdirs())
                {
                    throw new InitializationException(
                            "Could not create target directory!");
                }
            }
            repoPath = testPath;
            conf.setProperty(UploadService.REPOSITORY_KEY, repoPath);
        }

        log.debug("Upload Path is now " + repoPath);

        long sizeMax = conf.getLong(
                UploadService.SIZE_MAX_KEY,
                UploadService.SIZE_MAX_DEFAULT);

        log.debug("Max Size " + sizeMax);

        int sizeThreshold = conf.getInt(
                UploadService.SIZE_THRESHOLD_KEY,
                UploadService.SIZE_THRESHOLD_DEFAULT);

        log.debug("Threshold Size " + sizeThreshold);

        automatic = conf.getBoolean(
                UploadService.AUTOMATIC_KEY,
                UploadService.AUTOMATIC_DEFAULT);

        log.debug("Auto Upload " + automatic);

View Full Code Here

    public void init(Object data)
    {
        /**
         * Store the resources directory for use in image().
         */
        Configuration cfg = Turbine.getConfiguration();

        resourcesDirectory = stripSlashes(TurbinePull.getResourcesDirectory());

        if (data == null)
        {
            log.debug("UI Manager scope is global");
            setSkin();
        }
        else if (data instanceof RunData)
        {
            log.debug("UI Manager scope is request");
            setSkin((RunData) data);
        }
        else if (data instanceof User)
        {
            log.debug("UI Manager scope is session");
            setSkin((User) data);
        }

        skinsDirectory = stripSlashes(cfg.getString(SKINDIR_PROPERTY, SKINS_DIRECTORY));

        imagesDirectory = stripSlashes(cfg.getString(IMAGEDIR_PROPERTY, IMAGES_DIRECTORY));

        cssFile = cfg.getString(CSS_PROPERTY, DEFAULT_SKIN_CSS_FILE);

        wantRelative = cfg.getBoolean(RELATIVE_PROPERTY, false);

        loadSkin();
    }
View Full Code Here

     *
     * @return A Session.
     */
    private Session getMailSession()
    {
        Configuration conf = Turbine.getConfiguration();
        Properties properties = System.getProperties();

        properties.put(MAIL_TRANSPORT_PROTOCOL, SMTP);
        properties.put(MAIL_HOST, conf.getString(TurbineConstants.MAIL_SERVER_KEY,
                                                 TurbineConstants.MAIL_SERVER_DEFAULT));


        String mailSMTPFrom = conf.getString(TurbineConstants.MAIL_SMTP_FROM);

        if (StringUtils.isNotEmpty(mailSMTPFrom))
        {
            properties.put(TurbineConstants.MAIL_SMTP_FROM, mailSMTPFrom);
        }
View Full Code Here

     */
    public void init()
        throws InitializationException
    {
        // Get the configuration for the template service.
        Configuration config = getConfiguration();

        // Get the default extension to use if nothing else is applicable.
        defaultExtension = config.getString(TemplateService.DEFAULT_EXTENSION_KEY,
            TemplateService.DEFAULT_EXTENSION_VALUE);

        defaultTemplate =  config.getString(TemplateService.DEFAULT_TEMPLATE_KEY,
            TemplateService.DEFAULT_TEMPLATE_VALUE);

        // Check to see if we are going to be caching modules.
        // Aaargh, who moved this _out_ of the TemplateService package?
        useCache = Turbine.getConfiguration().getBoolean(TurbineConstants.MODULE_CACHE_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.