morciuch    2003/07/17 15:05:13

  Modified:    src/java/org/apache/jetspeed/services/template
                        JetspeedTemplateLocatorService.java
               webapp/WEB-INF/conf JetspeedResources.properties
  Log:
  1. Corrected the property name for portlet template global search (see Bugzilla bug# 
21699).
  
  2. Fixed template hot deployment feature (optional, default = false). This allows 
the template locator service to recognize newly added templates (see Bugzilla bug# 
14830).
  
  Revision  Changes    Path
  1.19      +36 -126   
jakarta-jetspeed/src/java/org/apache/jetspeed/services/template/JetspeedTemplateLocatorService.java
  
  Index: JetspeedTemplateLocatorService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/template/JetspeedTemplateLocatorService.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- JetspeedTemplateLocatorService.java       17 Jul 2003 14:57:54 -0000      1.18
  +++ JetspeedTemplateLocatorService.java       17 Jul 2003 22:05:13 -0000      1.19
  @@ -120,6 +120,7 @@
   {
       private final static String CONFIG_TEMPLATE_ROOT = ".templateRoot";
       private final static String CONFIG_PORTLET_GLOBAL_SEARCH = 
".portlet.global.search";
  +    private final static String CONFIG_HOT_DEPLOY = ".hot.deploy";
       private final static String DIR_SCREENS = "/screens";
       private final static String DIR_LAYOUTS = "/layouts";
       private final static String DIR_PORTLETS = "/portlets";
  @@ -146,8 +147,8 @@
       // the template root directories, webapp relative
       private String[] templateRoots;
   
  -    // use the name cache when looking up a template
  -    private boolean useNameCache = true;
  +    // check the file system if template not found in name cache
  +    private boolean hotDeploy = false;
   
       // template name cache
       private Map templateMap = null;
  @@ -223,21 +224,6 @@
               String path = (String) i.next();
               located = locateTemplate(data, DIR_SCREENS, path, template);
   
  -            if (null == located)
  -            {
  -                // Try to locate it directly on file system, perhaps it was 
recently added
  -                useNameCache = false;
  -                located = locateTemplate(data, DIR_SCREENS, path, template);
  -
  -                if (null != located)
  -                {
  -                    // add it to the map
  -                    templateMap.put(located, null);
  -                }
  -
  -                useNameCache = true;
  -            }
  -
               if (null != located)
               {
                   return located;
  @@ -287,21 +273,6 @@
               String path = (String) i.next();
               located = locateTemplate(data, DIR_LAYOUTS, path, template);
   
  -            if (null == located)
  -            {
  -                // Try to locate it directly on file system, perhaps it was 
recently added
  -                useNameCache = false;
  -                located = locateTemplate(data, DIR_LAYOUTS, path, template);
  -
  -                if (null != located)
  -                {
  -                    // add it to the map
  -                    templateMap.put(located, null);
  -                }
  -
  -                useNameCache = true;
  -            }
  -
               if (null != located)
               {
                   return located;
  @@ -352,21 +323,6 @@
               String path = (String) i.next();
               String located = locateTemplate(data, DIR_NAVIGATIONS, path, template);
   
  -            if (null == located)
  -            {
  -                // Try to locate it directly on file system, perhaps it was 
recently added
  -                useNameCache = false;
  -                located = locateTemplate(data, DIR_NAVIGATIONS, path, template);
  -
  -                if (null != located)
  -                {
  -                    // add it to the map
  -                    templateMap.put(located, null);
  -                }
  -
  -                useNameCache = true;
  -            }
  -
               if (null != located)
               {
                   return located;
  @@ -396,21 +352,6 @@
               String path = (String) i.next();
               String located = locateTemplate(data, DIR_PORTLETS, path, template);
   
  -            if (null == located)
  -            {
  -                // Try to locate it directly on file system, perhaps it was 
recently added
  -                useNameCache = false;
  -                located = locateTemplate(data, DIR_PORTLETS, path, template);
  -
  -                if (null != located)
  -                {
  -                    // add it to the map
  -                    templateMap.put(located, null);
  -                }
  -
  -                useNameCache = true;
  -            }
  -
               if (null != located)
               {
                   return DIR_PORTLETS + located;
  @@ -423,7 +364,7 @@
               String located = locateScreenTemplate(data, template);
               if (located != null)
               {
  -                return "/screens" + located;
  +                return DIR_SCREENS + located;
               }
           }
   
  @@ -450,21 +391,6 @@
               String path = (String) i.next();
               String located = locateTemplate(data, DIR_CONTROLS, path, template);
   
  -            if (null == located)
  -            {
  -                // Try to locate it directly on file system, perhaps it was 
recently added
  -                useNameCache = false;
  -                located = locateTemplate(data, DIR_CONTROLS, path, template);
  -
  -                if (null != located)
  -                {
  -                    // add it to the map
  -                    templateMap.put(located, null);
  -                }
  -
  -                useNameCache = true;
  -            }
  -
               if (null != located)
               {
                   return DIR_CONTROLS + located;
  @@ -494,21 +420,6 @@
               String path = (String) i.next();
               String located = locateTemplate(data, DIR_CONTROLLERS, path, template);
   
  -            if (null == located)
  -            {
  -                // Try to locate it directly on file system, perhaps it was 
recently added
  -                useNameCache = false;
  -                located = locateTemplate(data, DIR_CONTROLLERS, path, template);
  -
  -                if (null != located)
  -                {
  -                    // add it to the map
  -                    templateMap.put(located, null);
  -                }
  -
  -                useNameCache = true;
  -            }
  -
               if (null != located)
               {
                   return DIR_CONTROLLERS + located;
  @@ -556,21 +467,6 @@
               String path = (String) i.next();
               String located = locateTemplate(data, DIR_EMAILS, path, template);
   
  -            if (null == located)
  -            {
  -                // Try to locate it directly on file system, perhaps it was 
recently added
  -                useNameCache = false;
  -                located = locateTemplate(data, DIR_EMAILS, path, template);
  -
  -                if (null != located)
  -                {
  -                    // add it to the map
  -                    templateMap.put(located, null);
  -                }
  -
  -                useNameCache = true;
  -            }
  -
               if (null != located)
               {
                   return DIR_EMAILS + located;
  @@ -600,19 +496,6 @@
               String path = (String) i.next();
               String located = locateTemplate(data, DIR_PARAMETERS, path, template);
   
  -            if (null == located)
  -            {
  -                // Try to locate it directly on file system, perhaps it was 
recently added
  -                useNameCache = false;
  -                located = locateTemplate(data, DIR_PARAMETERS, path, template);
  -                if (null != located)
  -                {
  -                    // add it to the map
  -                    templateMap.put(located, null);
  -                }
  -                useNameCache = true;
  -            }
  -
               if (null != located)
               {
                   return DIR_PARAMETERS + located;
  @@ -714,13 +597,13 @@
               workingPath = path + template;
               realPath = TurbineServlet.getRealPath(basePath + workingPath);
   
  -            // the current template exists, return the corresponding path
  -            if (templateExists(realPath))
  +            // the current template exists in cache, return the corresponding path
  +            if (templateExists(realPath, true))
               {
                   if (Log.getLogger().isDebugEnabled())
                   {
                       Log.debug(
  -                        "TemplateLocator: template exists: "
  +                        "TemplateLocator: template exists in cache: "
                               + realPath
                               + " returning "
                               + workingPath);
  @@ -728,6 +611,27 @@
   
                   return workingPath;
               }
  +            else if (this.hotDeploy == true)
  +            {
  +                // Try to locate it directly on file system, perhaps it was 
recently added
  +                if (templateExists(realPath, false))
  +                {
  +                    if (Log.getLogger().isDebugEnabled())
  +                    {
  +                        Log.debug(
  +                            "TemplateLocator: template exists on the file system: "
  +                                + realPath
  +                                + " returning "
  +                                + workingPath);
  +                    }
  +
  +                    // add it to the map
  +                    //templateMap.put(workingPath, null);
  +                    templateMap.put(realPath, null);
  +
  +                    return workingPath;
  +                }
  +            }
               // else strip path of one of its components and loop
               int pt = path.lastIndexOf(PATH_SEPARATOR);
               if (pt > -1)
  @@ -880,12 +784,13 @@
        *
        * @return True when the template is found, otherwise false.
        */
  -    public boolean templateExists(String templateKey)
  +    public boolean templateExists(String templateKey, boolean useNameCache)
       {
           if (null == templateKey)
           {
               return false;
           }
  +
           if (useNameCache == true)
           {
               return templateMap.containsKey(templateKey);
  @@ -950,6 +855,11 @@
                   TurbineServices.SERVICE_PREFIX
                       + TemplateLocatorService.SERVICE_NAME
                       + CONFIG_PORTLET_GLOBAL_SEARCH, false);
  +
  +        hotDeploy = JetspeedResources.getBoolean(
  +                TurbineServices.SERVICE_PREFIX
  +                    + TemplateLocatorService.SERVICE_NAME
  +                    + CONFIG_HOT_DEPLOY, true);
   
       }
   
  
  
  
  1.105     +7 -2      
jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties
  
  Index: JetspeedResources.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties,v
  retrieving revision 1.104
  retrieving revision 1.105
  diff -u -r1.104 -r1.105
  --- JetspeedResources.properties      30 Jun 2003 20:22:59 -0000      1.104
  +++ JetspeedResources.properties      17 Jul 2003 22:05:13 -0000      1.105
  @@ -464,7 +464,12 @@
   
   # This parameter includes screen templates in portlet template search.
   # If set to 'true', when template is not found in /portlets folder, it will be 
searched for in the /screens folder
  -service.TemplateLocator.portlet.global.search = false
  +services.TemplateLocator.portlet.global.search = false
  +
  +# This parameter enables hot deployment of templates (adding new templates without 
having to restart the portal).
  +# If set to 'true', when template name is not found in template name cache, it will 
be searched for in the file system.
  +# default = false (for performance reasons)
  +services.TemplateLocator.hot.deploy = false
   
   #########################################
   # StockQuote Web Service                #
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to