FileDocCategorySizeDatePackage
TemplateCache.javaAPI DocGlassfish v2 API3599Fri May 04 22:34:12 BST 2007com.sun.enterprise.appclient.jws

TemplateCache

public class TemplateCache extends Object
Manages the caching and retrieval of templates used for generating JNLP and HTML documents to be served to Java Web Start.
author
tjquinn

Fields Summary
private static final String
TEMPLATES_PATH_PREFIX
path relative to this class where the templates reside
private Map
templateCache
caches templates
Constructors Summary
public TemplateCache()
Creates a new instance of TemplateCache

    
    
           
      
        templateCache = new HashMap<String,String>();
    
Methods Summary
public java.lang.StringgetTemplate(java.lang.String templateName)
Returns a template retrieved using the path specified.

param
name of the template, relative to the current package
return
the retrieved template as a String
throws
IOException reporting any error retrieving the template as a resource

        
        /*
         *Look for the named template in the cache and, if it is not there, 
         *retrieve it and store it in the cache.
         */
        String template = templateCache.get(templateName);
        if (template == null) {
            template = Util.loadResource(this.getClass(), TEMPLATES_PATH_PREFIX + templateName);
            templateCache.put(templateName, template);
        }
        
        /*
         *Regardless of how the template was found, return it.
         */
        return template;