Package org.apache.velocity.runtime.configuration

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


     *
     * @throws InitializationException if initialization fails.
     */
    public void init() throws InitializationException
    {
        Configuration conf = getConfiguration();
        if (conf != null)
        {
            Vector loaders = conf.getVector(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 TurbinbeFactoryService",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


    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.
         */
        configuration.setProperty(Velocity.RUNTIME_LOG,
            TurbineServlet.getRealPath(configuration.getString(
                Velocity.RUNTIME_LOG, null)));

        /*
         * 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

     * @exception InitializationException Thrown by Turbine.
     */
    private void initWebMacro()
        throws InitException, InitializationException
    {
        Configuration config = getConfiguration();

        /*
         * We retrieve the template paths here and translate
         * them so that we have a functional templateExists(name)
         * method in this service. This happens again in
         * the provider so that we don't have to store the
         * converted configuration, and we don't want to
         * store them because the initialization of this
         * service is done in one pass. This means that
         * the provider trying to retrieve the converted
         * properties via this service we get a recursion
         * problem. What would be idea is if the service
         * broker could store the properties for each of
         * the services, even if they are converted. Just
         * trying to explain what's going on.
         */
        templatePaths = config.getStringArray("templates");
        templatePaths = TurbineTemplate.translateTemplatePaths(templatePaths);
       
        WMTemplateProvider = config.getString("templates.provider", null);
        WMProperties = config.getString("properties");
       
        if (WMProperties != null)
        {
            /*
             * If possible, transform paths to be webapp
View Full Code Here

     * @throws InitializationException if initialization fails.
     */
    public void init()
        throws InitializationException
    {
        Configuration conf = getConfiguration();
        if (conf != null)
        {
            try
            {
                int capacity = conf.getInt(POOL_CAPACITY,DEFAULT_POOL_CAPACITY);
                if (capacity <= 0)
                {
                    throw new IllegalArgumentException("Capacity must be >0");
                }
                poolCapacity = capacity;
View Full Code Here

    private void initTemplate()
    {
        /*
         * Get the configuration for the template service.
         */
        Configuration config = getConfiguration();
       
        /*
         * Get the default extension to use if nothing else is applicable.
         */
        defaultExtension = config.getString("default.extension",NO_FILE_EXT);
        defaultTemplate = "Default." + defaultExtension;
       
        /*
         * Check to see if we are going to be caching modules.
         */
        useCache = TurbineResources.getBoolean("module.cache",true);
       
        if (useCache)
        {
            int screenSize = config.getInt("screen.cache.size",5);
            int screenTemplateSize = config.getInt("screen.cache.size",50);
            int layoutSize = config.getInt("layout.cache.size",5);
            int layoutTemplateSize = config.getInt("layout.cache.size",5);
            int navigationSize = config.getInt("navigation.cache.size",10);
           
            /*
             * Create hashtables for each object type,
             * the first one for pages is not used.
             */
View Full Code Here

        PoolBuffer pool = (PoolBuffer) poolRepository.get(className);
        if (pool == null)
        {
            /* Check class specific capacity. */
            int capacity = poolCapacity;
            Configuration conf = getConfiguration();
            if (conf != null)
            {
                try
                {
                    capacity = conf.getInt(
                        POOL_CAPACITY + '.' + className,poolCapacity);
                    if (capacity <= 0)
                    {
                        capacity = poolCapacity;
                    }
View Full Code Here

            /*
             * We are specifically not getting the configuration
             * from the service because it hasn't finished
             * init'ing we're getting it from the service broker.
             */
            Configuration config = TurbineServices.getInstance()
                .getConfiguration(WebMacroService.SERVICE_NAME);
           
            paths = config.getStringArray("templates");
            paths = TurbineTemplate.translateTemplatePaths(paths);

            StringBuffer pathMsg = new StringBuffer("TurbineTemplateProvider path(s):");
           
            for (int i = 0; i < paths.length; i++)
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.
         */
        configuration.put(DEFAULT_PAGE, config.getString(DEFAULT_PAGE));
        configuration.put(DEFAULT_SCREEN, config.getString(DEFAULT_SCREEN));
        configuration.put(DEFAULT_LAYOUT, config.getString(DEFAULT_LAYOUT));
        configuration.put(DEFAULT_NAVIGATION,
                          config.getString(DEFAULT_NAVIGATION));
        configuration.put(DEFAULT_ERROR_SCREEN,
                          config.getString(DEFAULT_ERROR_SCREEN));
        configuration.put(DEFAULT_LAYOUT_TEMPLATE,
                          config.getString(DEFAULT_LAYOUT_TEMPLATE));
    }
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

     * @param config A ServletConfig.
     * @exception Exception, a generic exception.
     */
    private void initFreeMarker() throws Exception
    {
        Configuration config = getConfiguration();

        path = config.getString("templates", "/templates");

        // If possible, transform paths to be webapp root relative.
        path = TurbineServlet.getRealPath(path);

        // Store the converted path in service properties for Turbine
        // based providers.
        config.setProperty("templates", path);

        templateCache = new FileTemplateCache(path);
        templateCache.addCacheListener(this);
        templateCache.startAutoUpdate();
    }
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.