Package org.apache.velocity.runtime.configuration

Examples of org.apache.velocity.runtime.configuration.Configuration


    {
        try
        {
            assureResultsDirectoryExists(RESULTS_DIR);
           
            Configuration c = new Configuration(TEST_CONFIG);
           
            FileWriter result = new FileWriter(
                getFileName(RESULTS_DIR, "output", "res"));
           
            message(result, "Testing order of keys ...");
            showIterator(result, c.getKeys());
           
            message(result, "Testing retrieval of CSV values ...");
            showVector(result, c.getVector("resource.loader"));           

            message(result, "Testing Configuration.subset(prefix).getKeys() ...");
            Configuration subset = c.subset("file.resource.loader");
            showIterator(result, subset.getKeys());

            message(result, "Testing getVector(prefix) ...");
            showVector(result, subset.getVector("path"));           

            message(result, "Testing getString(key) ...");
            result.write(c.getString("config.string.value"));
            result.write("\n\n");
View Full Code Here


       
        assembleResourceLoaderInitializers();
       
        for (int i = 0; i < sourceInitializerList.size(); i++)
        {
            Configuration configuration = (Configuration) sourceInitializerList.get(i);
            String loaderClass = configuration.getString("class");

            resourceLoader = ResourceLoaderFactory.getLoader(loaderClass);
            resourceLoader.commonInit(configuration);
            resourceLoader.init(configuration);
            resourceLoaders.add(resourceLoader);
View Full Code Here

             * pertaining to a particular loader.
             */
            String loaderID =
                resourceLoaderNames.get(i) + "." + Runtime.RESOURCE_LOADER;

            Configuration loaderConfiguration =
                Runtime.getConfiguration().subset(loaderID);

            /*
             * Add resources to the list of resource loader
             * initializers.
 
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 logFile = TurbineServlet.getRealPath
            (configuration.getString(Velocity.RUNTIME_LOG, null));
        if (StringUtils.isValid(logFile))
        {
            configuration.setProperty(Velocity.RUNTIME_LOG, logFile);
        }
        else
        {
            String msg = VelocityService.SERVICE_NAME + " runtime log file " +
                "is misconfigured: '" + logFile + "' 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.
         */
        Vector templatePaths = configuration.getVector(
            Velocity.FILE_RESOURCE_LOADER_PATH);

        /*
         * Clear the configuration for the template paths, we
         * want to translate them all to the webapp space.
         */
        Velocity.clearProperty(Velocity.FILE_RESOURCE_LOADER_PATH);
        configuration.clearProperty(Velocity.FILE_RESOURCE_LOADER_PATH);
       
        int pathsToProcess = templatePaths.size();
       
        // If I use this line I get an endless loop?
        // What the hell is that? Is that a bug with
        // Vector used in conjunction with a for loop.
        //for (int i = 0; i < templatePaths.size(); i++)
       
        for (int i = 0; i < pathsToProcess; i++)
        {
            configuration.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH,
                TurbineServlet.getRealPath((String) templatePaths.get(i)));
        }
       
        try
        {
View Full Code Here

     * @param name The name of the service.
     * @return Properties of requested Service.
     */
     public Configuration getConfiguration( String name )
     {
        return new Configuration();
     }
View Full Code Here

     */
    public static void setProperty(String key, Object value)
    {
        if (overridingProperties == null)
        {
            overridingProperties = new Configuration();
        }           
           
        overridingProperties.setProperty( key, value );
    }       
View Full Code Here

     * @param Properties
     */
    public static void init(String configurationFile)
        throws Exception
    {
        overridingProperties = new Configuration(configurationFile);
        init();
    }
View Full Code Here

       
        assembleResourceLoaderInitializers();
       
        for (int i = 0; i < sourceInitializerList.size(); i++)
        {
            Configuration configuration = (Configuration) sourceInitializerList.get(i);
            String loaderClass = configuration.getString("class");

            resourceLoader = ResourceLoaderFactory.getLoader(loaderClass);
            resourceLoader.commonInit(configuration);
            resourceLoader.init(configuration);
            resourceLoaders.add(resourceLoader);
View Full Code Here

             * pertaining to a particular loader.
             */
            String loaderID =
                resourceLoaderNames.get(i) + "." + Runtime.RESOURCE_LOADER;

            Configuration loaderConfiguration =
                Runtime.getConfiguration().subset(loaderID);

            /*
             * Add resources to the list of resource loader
             * initializers.
 
View Full Code Here

    {
        try
        {
            assureResultsDirectoryExists(RESULTS_DIR);
           
            Configuration c = new Configuration(TEST_CONFIG);
           
            FileWriter result = new FileWriter(
                getFileName(RESULTS_DIR, "output", "res"));
           
            message(result, "Testing order of keys ...");
            showIterator(result, c.getKeys());
           
            message(result, "Testing retrieval of CSV values ...");
            showVector(result, c.getVector("resource.loader"));           

            message(result, "Testing subset(prefix).getKeys() ...");
            Configuration subset = c.subset("file.resource.loader");
            showIterator(result, subset.getKeys());

            message(result, "Testing getVector(prefix) ...");
            showVector(result, subset.getVector("path"));           

            message(result, "Testing getString(key) ...");
            result.write(c.getString("config.string.value"));
            result.write("\n\n");
View Full Code Here

TOP

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