Package org.apache.velocity.runtime.configuration

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


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


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

        /*
         * Use the turbine template service to translate
         * the template paths.
         */
        templatePaths = TurbineTemplate.translateTemplatePaths(
        config.getStringArray("templates"));
       
        /*
         * Set relative paths from config.
         * Needed for javax.servlet.RequestDispatcher
         */
        relativeTemplatePaths = config.getStringArray("templates");
       
        /*
         * Make sure that the relative paths begin with /
         */
        for (int i = 0; i < relativeTemplatePaths.length; i++)
        {
            if (!relativeTemplatePaths[i].startsWith("/"))
            {
                relativeTemplatePaths[i] = "/" + relativeTemplatePaths[i];
            }
        }
       
        bufferSize = config.getInt("buffer.size", 8192);
   
        /*
         * Register with the template service.
         */
        registerConfiguration("jsp");
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

    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

     * Load the persisted state of the repository from disk
     */
    private synchronized void load() {

        Map store = new HashMap();
        Configuration config = null;

        logger.info( "Restoring the URLs from disk: " + path );

        try {
            config = new Configuration( path );

            int count = 1;
            String url = null;

            while ( ( url = ( config
                              .getString("entry."+count+".url") ) ) != null ) {
                //Intern the url to ensure we can use "==" to compare
                //and synchronize on it
                url = url.intern();
                int status = config.getInteger("entry."+count+".status", URLManagerService.STATUS_OK );
                if( store.get( url ) == null )
                    store.put( url, new URLInfo( url, status ) );
                count++;
            }

View Full Code Here

     * Load the persisted state of the repository from disk
     */
    private synchronized void load() {

        Map store = new HashMap();
        Configuration config = null;

        logger.info( "Restoring the URLs from disk: " + path );

        try {
            config = new Configuration( path );

            int count = 1;
            String url = null;

            while ( ( url = ( config
                              .getString("entry."+count+".url") ) ) != null ) {
                //Intern the url to ensure we can use "==" to compare
                //and synchronize on it
                url = url.intern();
                int status = config.getInteger("entry."+count+".status", URLManagerService.STATUS_OK );
                if( store.get( url ) == null )
                    store.put( url, new URLInfo( url, status ) );
                count++;
            }

View Full Code Here

     * Load the persisted state of the repository from disk
     */
    private synchronized void load() {

        Map store = new HashMap();
        Configuration config = null;

        Log.info( "Restoring the URLs from disk: " + path );
           
        try {
            config = new Configuration( path );
           
            int count = 1;
            String url = null;
           
            while ( ( url = ( config
                              .getString("entry."+count+".url") ) ) != null ) {
                //Intern the url to ensure we can use "==" to compare
                //and synchronize on it
                url = url.intern();
                int status = config.getInteger("entry."+count+".status", URLManagerService.STATUS_OK );
                if( store.get( url ) == null )
                    store.put( url, new URLInfo( url, status ) );
                count++;
            }
               
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

     */
    public void init()
        throws InitializationException
    {
        String path = null;
        Configuration conf = getConfiguration();
        if (conf != null)
        {
            path = conf.getString(MIME_TYPES);
            if (path != null)
            {
                path = TurbineServlet.getRealPath(path);
            }
        }
        if (path != null)
        {
            try
            {
                mimeTypeMap = new MimeTypeMap(path);
            }
            catch (IOException x)
            {
                throw new InitializationException(path,x);
            }
        }
        else
        {
            mimeTypeMap = new MimeTypeMap();
        }

        if (conf != null)
        {
            path = conf.getString(CHARSETS);
            if (path != null)
            {
                path = TurbineServlet.getRealPath(path);
            }
        }
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.