cziegeler    01/08/20 06:02:18

  Modified:    src/org/apache/cocoon/sitemap Tag: cocoon_20_branch
                        Manager.java
  Log:
  Improved handler generation
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.10  +21 -8     xml-cocoon2/src/org/apache/cocoon/sitemap/Manager.java
  
  Index: Manager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/Manager.java,v
  retrieving revision 1.2.2.9
  retrieving revision 1.2.2.10
  diff -u -r1.2.2.9 -r1.2.2.10
  --- Manager.java      2001/08/20 06:51:05     1.2.2.9
  +++ Manager.java      2001/08/20 13:02:18     1.2.2.10
  @@ -34,7 +34,7 @@
    * checking regeneration of the sub <code>Sitemap</code>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
  - * @version CVS $Revision: 1.2.2.9 $ $Date: 2001/08/20 06:51:05 $
  + * @version CVS $Revision: 1.2.2.10 $ $Date: 2001/08/20 13:02:18 $
    */
   public class Manager extends AbstractLoggable implements Component, Configurable, 
Composable, Contextualizable, ThreadSafe {
       private Context context;
  @@ -151,7 +151,7 @@
       }
       */
   
  -    private synchronized Handler getHandler(final ComponentManager newManager, 
final Environment environment, final String source, final boolean check_reload,
  +    private Handler getHandler(final ComponentManager newManager, final Environment 
environment, final String source, final boolean check_reload,
           final boolean reload_asynchron) throws Exception {
               Handler sitemapHandler = (Handler)sitemaps.get(source);
               if (sitemapHandler != null) {
  @@ -167,12 +167,25 @@
                       sitemapHandler.regenerate(environment);
                   }
               } else {
  -                sitemapHandler = new Handler(source, check_reload);
  -                sitemapHandler.setLogger(getLogger());
  -                sitemapHandler.compose(newManager);
  -                sitemapHandler.contextualize(this.context);
  -                sitemapHandler.regenerate(environment);
  -                sitemaps.put(source, sitemapHandler);
  +                // also this looks a little bit strange, it should work
  +                // if no handler is available, the generation of the new
  +                // handler is synchronized.
  +                // The first incoming request creates the handler and blocks
  +                // all incoming requests. When the generation is finished
  +                // all other requests enter (one after the other) this method
  +                // and get the new created handler with the first get
  +                // statement
  +                synchronized (this) {
  +                    sitemapHandler = (Handler)sitemaps.get(source);
  +                    if (sitemapHandler == null) {
  +                        sitemapHandler = new Handler(source, check_reload);
  +                        sitemapHandler.setLogger(getLogger());
  +                        sitemapHandler.compose(newManager);
  +                        sitemapHandler.contextualize(this.context);
  +                        sitemapHandler.regenerate(environment);
  +                        sitemaps.put(source, sitemapHandler);
  +                    }
  +                }
               }
               return sitemapHandler;
       }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to