cziegeler    02/02/05 05:43:52

  Modified:    src/java/org/apache/cocoon/sitemap Manager.java
                        SitemapManager.java
  Log:
  Removed debug output to standard error
  
  Revision  Changes    Path
  1.7       +131 -103  xml-cocoon2/src/java/org/apache/cocoon/sitemap/Manager.java
  
  Index: Manager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/sitemap/Manager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Manager.java      4 Feb 2002 14:05:18 -0000       1.6
  +++ Manager.java      5 Feb 2002 13:43:51 -0000       1.7
  @@ -86,11 +86,17 @@
    * checking regeneration of the sub <code>Sitemap</code>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
  - * @version CVS $Id: Manager.java,v 1.6 2002/02/04 14:05:18 cziegeler Exp $
  + * @version CVS $Id: Manager.java,v 1.7 2002/02/05 13:43:51 cziegeler Exp $
    */
  -public class Manager extends AbstractLoggable
  -    implements Component, Configurable, Composable, Contextualizable,
  -               ThreadSafe, LogKitManageable, Disposable
  +public class Manager
  +  extends AbstractLoggable
  +  implements Component,
  +             Configurable,
  +             Composable,
  +             Contextualizable,
  +             ThreadSafe,
  +             LogKitManageable,
  +             Disposable
   {
       protected Context context;
   
  @@ -128,18 +134,18 @@
       /** get a configuration
        * @param conf the configuration
        */
  -    public void configure(Configuration conf) throws ConfigurationException {
  +    public void configure(Configuration conf)
  +    throws ConfigurationException {
           this.conf = conf;
   
           String value = conf.getAttribute("handler-class", null);
           if (value != null) {
  -          try {
  -            handlerClass = Class.forName(value);
  -          }
  -          catch (ClassNotFoundException ex) {
  -            throw new ConfigurationException("Cannot find Handler class "
  +            try {
  +                handlerClass = Class.forName(value);
  +            } catch (ClassNotFoundException ex) {
  +                throw new ConfigurationException("Cannot find Handler class "
                                                + value);
  -          }
  +            }
           }
       }
   
  @@ -166,20 +172,25 @@
        * @throws Exception there may be several excpetions thrown
        * @return states if the requested resource was produced
        */
  -    public boolean invoke(ComponentManager newManager, Environment environment, 
String uri_prefix, String source, boolean check_reload,
  -        boolean reload_asynchron) throws Exception {
  -            // get a sitemap handler
  -            Handler sitemapHandler = getHandler(newManager, environment, source, 
check_reload, reload_asynchron);
  -            // setup to invoke the processing
  -            setupProcessing(environment, sitemapHandler, uri_prefix, source);
  -            String prefix = environment.getURIPrefix();
  -            String uri    = environment.getURI();
  -            try {
  -                environment.changeContext(uri_prefix, source);
  -                return sitemapHandler.process(environment);
  -            } finally{
  -                environment.setContext(prefix, uri);
  -            }
  +    public boolean invoke(ComponentManager newManager,
  +                          Environment environment,
  +                          String uri_prefix,
  +                          String source,
  +                          boolean check_reload,
  +                          boolean reload_asynchron)
  +    throws Exception {
  +        // get a sitemap handler
  +        Handler sitemapHandler = getHandler(newManager, environment, source, 
check_reload, reload_asynchron);
  +        // setup to invoke the processing
  +        setupProcessing(environment, sitemapHandler, uri_prefix, source);
  +        String prefix = environment.getURIPrefix();
  +        String uri    = environment.getURI();
  +        try {
  +            environment.changeContext(uri_prefix, source);
  +            return sitemapHandler.process(environment);
  +        } finally{
  +            environment.setContext(prefix, uri);
  +        }
       }
   
       /** invokes the sitemap handler to process a request
  @@ -191,20 +202,27 @@
        * @throws Exception there may be several excpetions thrown
        * @return states if the requested resource was produced
        */
  -    public boolean invoke(ComponentManager newManager, Environment environment, 
String uri_prefix, String source, boolean check_reload,
  -        boolean reload_asynchron, StreamPipeline pipeline, EventPipeline 
eventPipeline) throws Exception {
  -            // get a sitemap handler
  -            Handler sitemapHandler = getHandler(newManager, environment, source, 
check_reload, reload_asynchron);
  -            // setup to invoke the processing
  -            setupProcessing(environment, sitemapHandler, uri_prefix, source);
  -            String prefix = environment.getURIPrefix();
  -            String uri    = environment.getURI();
  -            try {
  -                environment.changeContext(uri_prefix, source);
  -                return sitemapHandler.process(environment, pipeline, eventPipeline);
  -            } finally{
  -                environment.setContext(prefix, uri);
  -            }
  +    public boolean invoke(ComponentManager newManager,
  +                          Environment environment,
  +                          String uri_prefix,
  +                          String source,
  +                          boolean check_reload,
  +                          boolean reload_asynchron,
  +                          StreamPipeline pipeline,
  +                          EventPipeline eventPipeline)
  +    throws Exception {
  +        // get a sitemap handler
  +        Handler sitemapHandler = getHandler(newManager, environment, source, 
check_reload, reload_asynchron);
  +        // setup to invoke the processing
  +        setupProcessing(environment, sitemapHandler, uri_prefix, source);
  +        String prefix = environment.getURIPrefix();
  +        String uri    = environment.getURI();
  +        try {
  +            environment.changeContext(uri_prefix, source);
  +            return sitemapHandler.process(environment, pipeline, eventPipeline);
  +        } finally{
  +            environment.setContext(prefix, uri);
  +        }
       }
   
       /** has the sitemap changed
  @@ -222,85 +240,95 @@
           return false;
       }
   
  -    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) {
  -                // The following is a little bit complicated:
  -                // If the sitemap handler is not available, it is regenerated
  -                // If it is available:
  -                //    The handler is only queried if it has changed if
  -                //    the check_reload flag is true
  -                if (sitemapHandler.available()) {
  -                    if (check_reload && sitemapHandler.hasChanged()) {
  -                        // The sitemap has been changed.
  -                        if (reload_asynchron) {
  -                            // In asynchron mode the first request entering this
  -                            // starts the regeneration. All other request comming
  -                            // in, use the old sitemap until the new is generated.
  -                            if (!sitemapHandler.isRegenerating()) {
  -                                
sitemapHandler.regenerateAsynchronously(environment);
  +    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) {
  +            // The following is a little bit complicated:
  +            // If the sitemap handler is not available, it is regenerated
  +            // If it is available:
  +            //    The handler is only queried if it has changed if
  +            //    the check_reload flag is true
  +            if (sitemapHandler.available()) {
  +                if (check_reload && sitemapHandler.hasChanged()) {
  +                    // The sitemap has been changed.
  +                    if (reload_asynchron) {
  +                        // In asynchron mode the first request entering this
  +                        // starts the regeneration. All other request comming
  +                        // in, use the old sitemap until the new is generated.
  +                        if (!sitemapHandler.isRegenerating()) {
  +                            sitemapHandler.regenerateAsynchronously(environment);
  +                        }
  +                    } else {
  +                        // In synchron mode the first request starts the
  +                        // regeneration, all other requests are blocked
  +                        // until the regeneration is finished. This is done
  +                        // by the synchronized statement
  +                        if (!sitemapHandler.isRegenerating()) {
  +                            synchronized (this) {
  +                                sitemapHandler.regenerate(environment);
                               }
                           } else {
  -                            // In synchron mode the first request starts the
  -                            // regeneration, all other requests are blocked
  -                            // until the regeneration is finished. This is done
  -                            // by the synchronized statement
  -                            if (!sitemapHandler.isRegenerating()) {
  -                                synchronized (this) {
  -                                    sitemapHandler.regenerate(environment);
  -                                }
  -                            } else {
  -                                synchronized (this) {
  -                                    // Dummy statement
  -                                    this.hashCode();
  -                                }
  +                            synchronized (this) {
  +                                // Dummy statement
  +                                this.hashCode();
                               }
                           }
                       }
  -                } else {
  -                    sitemapHandler.regenerate(environment);
                   }
               } else {
  -                // 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 = (Handler)handlerClass.newInstance();
  -                        sitemapHandler.setSourceFileName(source);
  -                        sitemapHandler.setCheckReload(check_reload);
  -                        sitemapHandler.setLogger(getLogger());
  -                        sitemapHandler.compose(newManager);
  -                        sitemapHandler.contextualize(this.context);
  -                        if (sitemapHandler instanceof Configurable)
  -                          ((Configurable)sitemapHandler).configure(conf);
  -                        sitemapHandler.regenerate(environment);
  -                        sitemaps.put(source, sitemapHandler);
  -                    }
  +                sitemapHandler.regenerate(environment);
  +            }
  +        } else {
  +            // 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 = (Handler)handlerClass.newInstance();
  +                    sitemapHandler.setSourceFileName(source);
  +                    sitemapHandler.setCheckReload(check_reload);
  +                    sitemapHandler.setLogger(getLogger());
  +                    sitemapHandler.compose(newManager);
  +                    sitemapHandler.contextualize(this.context);
  +                    if (sitemapHandler instanceof Configurable)
  +                        ((Configurable)sitemapHandler).configure(conf);
  +                    sitemapHandler.regenerate(environment);
  +                    sitemaps.put(source, sitemapHandler);
                   }
               }
  -            return sitemapHandler;
  +        }
  +        return sitemapHandler;
       }
   
  -    private void setupProcessing(Environment environment, Handler sitemapHandler, 
String uri_prefix,
  -        String source) throws Exception {
  -            if (!sitemapHandler.available()) {
  -                if (sitemapHandler.getException() != null) {
  -                    throw sitemapHandler.getException();
  -                } else {
  -                    throw new ProcessingException("The sitemap handler's sitemap is 
not available. " +
  +    private void setupProcessing(Environment environment,
  +                                 Handler sitemapHandler,
  +                                 String uri_prefix,
  +                                 String source)
  +    throws Exception {
  +        if (!sitemapHandler.available()) {
  +            if (sitemapHandler.getException() != null) {
  +                throw sitemapHandler.getException();
  +            } else {
  +                throw new ProcessingException("The sitemap handler's sitemap is not 
available. " +
                           "Please check logs for the exact error.");
  -                }
               }
  +        }
       }
   
  +    /**
  +     * Disposable
  +     */
       public void dispose() {
           context = null;
           for (Iterator i = sitemaps.values().iterator(); i.hasNext();) {
  
  
  
  1.7       +15 -13    
xml-cocoon2/src/java/org/apache/cocoon/sitemap/SitemapManager.java
  
  Index: SitemapManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/sitemap/SitemapManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SitemapManager.java       4 Feb 2002 14:05:18 -0000       1.6
  +++ SitemapManager.java       5 Feb 2002 13:43:51 -0000       1.7
  @@ -85,7 +85,7 @@
    * to Java code.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Id: SitemapManager.java,v 1.6 2002/02/04 14:05:18 cziegeler Exp $
  + * @version CVS $Id: SitemapManager.java,v 1.7 2002/02/05 13:43:51 cziegeler Exp $
    */
   public class SitemapManager extends Manager implements Processor, Configurable {
   
  @@ -113,15 +113,12 @@
           long checkDelay = sconf.getAttributeAsLong("check-delay", 1L);
           Handler.setSitemapCheckDelay(checkDelay * 1000L);
   
  -        getLogger().debug("Sitemap location = " + this.sitemapFileName);
  -        getLogger().debug("Checking sitemap reload = " + this.checkSitemapReload);
  -        getLogger().debug("Reloading sitemap asynchron = " + 
this.reloadSitemapAsynchron);
  -        getLogger().debug("Sitemap check delay = " + checkDelay + " sec");
  -
  -        System.err.println("Sitemap location = " + this.sitemapFileName);
  -        System.err.println("Checking sitemap reload = " + this.checkSitemapReload);
  -        System.err.println("Reloading sitemap asynchron = " + 
this.reloadSitemapAsynchron);
  -        System.err.println("Sitemap check delay = " + checkDelay + " sec");
  +        if (this.getLogger().isDebugEnabled()) {
  +            getLogger().debug("Sitemap location = " + this.sitemapFileName);
  +            getLogger().debug("Checking sitemap reload = " + 
this.checkSitemapReload);
  +            getLogger().debug("Reloading sitemap asynchron = " + 
this.reloadSitemapAsynchron);
  +            getLogger().debug("Sitemap check delay = " + checkDelay + " sec");
  +        }
   
           // Read sitemap roles
           Parser p = null;
  @@ -188,14 +185,19 @@
        * Process the given <code>Environment</code> producing the output.
        */
       public boolean process(Environment environment) throws Exception {
  -        return this.invoke(this.manager, environment, "", this.sitemapFileName, 
this.checkSitemapReload, this.reloadSitemapAsynchron);
  +        return this.invoke(this.manager, environment, "", this.sitemapFileName,
  +                           this.checkSitemapReload, this.reloadSitemapAsynchron);
       }
   
       /**
        * Process the given <code>Environment</code> to assemble
        * a <code>StreamPipeline</code> and an <code>EventPipeline</code>.
        */
  -    public boolean process(Environment environment, StreamPipeline pipeline, 
EventPipeline eventPipeline) throws Exception {
  -        return this.invoke(this.manager, environment, "", this.sitemapFileName, 
this.checkSitemapReload, this.reloadSitemapAsynchron, pipeline, eventPipeline);
  +    public boolean process(Environment environment,
  +                           StreamPipeline pipeline,
  +                           EventPipeline eventPipeline)
  +    throws Exception {
  +        return this.invoke(this.manager, environment, "", this.sitemapFileName,
  +                           this.checkSitemapReload, this.reloadSitemapAsynchron, 
pipeline, eventPipeline);
       }
   }
  
  
  

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