cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/webapp cocoon.xconf
Date Wed, 04 Jul 2001 07:57:45 GMT
cziegeler    01/07/04 00:57:44

  Modified:    src/org/apache/cocoon Cocoon.java Main.java Roles.java
                        cocoon.roles
               src/org/apache/cocoon/components/language/markup/xsp
                        XSPFormValidatorHelper.java
               src/org/apache/cocoon/environment AbstractEnvironment.java
                        Environment.java
               src/org/apache/cocoon/environment/commandline
                        AbstractCommandLineEnvironment.java
                        FileSavingEnvironment.java
                        LinkSamplingEnvironment.java
               src/org/apache/cocoon/sitemap Handler.java Manager.java
               webapp   cocoon.xconf
  Added:       src/org/apache/cocoon/components/source
                        CocoonSourceFactory.java SitemapSource.java
                        SourceFactory.java SourceHandler.java
                        SourceHandlerImpl.java URLSource.java
  Removed:     src/org/apache/cocoon/environment FactoryURLResolver.java
                        URLResolver.java URLSource.java
               src/org/apache/cocoon/sitemap SitemapSource.java
                        SitemapURLResolver.java
  Log:
  - Redesigned the Source handling
  - Added SourceHandler and SourceFactory. The SourceHandler controlls the
  - SourceFactories and a SourceFactory has the same function as the
  - URLFactory except that it returns Source objects instead of urls.
  - Moved most classes into a separate package
  - Changed logging behaviour of the commandline environment and
    the AbstractEnvironment
  
  Revision  Changes    Path
  1.14      +15 -16    xml-cocoon2/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Cocoon.java	2001/06/28 09:56:30	1.13
  +++ Cocoon.java	2001/07/04 07:56:35	1.14
  @@ -37,11 +37,10 @@
   import org.apache.cocoon.components.pipeline.EventPipeline;
   import org.apache.cocoon.components.pipeline.StreamPipeline;
   import org.apache.cocoon.components.store.FilesystemStore;
  -import org.apache.cocoon.components.url.URLFactory;
  +import org.apache.cocoon.components.source.SourceHandler;
  +import org.apache.cocoon.components.source.URLSource;
   import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.FactoryURLResolver;
   import org.apache.cocoon.environment.Source;
  -import org.apache.cocoon.environment.URLSource;
   import org.apache.cocoon.serialization.Serializer;
   import org.apache.cocoon.sitemap.Manager;
   import org.apache.cocoon.sitemap.AbstractSitemap;
  @@ -57,7 +56,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a> (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.13 $ $Date: 2001/06/28 09:56:30 $
  + * @version CVS $Revision: 1.14 $ $Date: 2001/07/04 07:56:35 $
    */
   public class Cocoon extends AbstractLoggable implements ThreadSafe, Component, Initializable, Disposable, Modifiable, Processor, Contextualizable {
       /** The application context */
  @@ -88,7 +87,7 @@
       private boolean reloadSitemapAsynchron = true;
   
       /** The component manager. */
  -    private ExcaliburComponentManager componentManager;
  +    public ExcaliburComponentManager componentManager;
   
       /** flag for disposed or not */
       private boolean disposed = false;
  @@ -191,7 +190,7 @@
               getLogger().debug(key + "=" + System.getProperty(key));
            }
            getLogger().debug("===== System Properties End =====");
  -       } catch ( SecurityException se ) { 
  +       } catch ( SecurityException se ) {
            // Ignore Exceptions.
          }
       }
  @@ -369,11 +368,11 @@
       public void generateSitemap(Environment environment)
       throws Exception {
           ProgramGenerator programGenerator = null;
  -        URLFactory urlFactory = null;
  +        SourceHandler sourceHandler = null;
           try {
               programGenerator = (ProgramGenerator) this.componentManager.lookup(Roles.PROGRAM_GENERATOR);
  -            urlFactory = (URLFactory) this.componentManager.lookup(Roles.URL_FACTORY);
  -            environment.setURLResolver(new FactoryURLResolver(this.componentManager, urlFactory));
  +            sourceHandler = (SourceHandler) this.componentManager.lookup(Roles.SOURCE_HANDLER);
  +            environment.setSourceHandler(sourceHandler);
               String markupLanguage = "sitemap";
               String programmingLanguage = "java";
   
  @@ -390,9 +389,9 @@
               getLogger().error("Main: Error compiling sitemap", e);
               throw e;
           } finally {
  -            environment.setURLResolver(null);
  +            environment.setSourceHandler(null);
               if (programGenerator != null) this.componentManager.release(programGenerator);
  -            if (urlFactory != null) this.componentManager.release((Component) urlFactory);
  +            if (sourceHandler != null) this.componentManager.release((Component) sourceHandler);
           }
       }
   
  @@ -402,13 +401,13 @@
       public void generateXSP(String fileName, Environment environment)
       throws Exception {
           ProgramGenerator programGenerator = null;
  -        URLFactory urlFactory = null;
  +        SourceHandler sourceHandler = null;
           try {
               getLogger().debug("XSP generation begin:" + fileName);
   
               programGenerator = (ProgramGenerator) this.componentManager.lookup(Roles.PROGRAM_GENERATOR);
  -            urlFactory = (URLFactory) this.componentManager.lookup(Roles.URL_FACTORY);
  -            environment.setURLResolver(new FactoryURLResolver(this.componentManager, urlFactory));
  +            sourceHandler = (SourceHandler) this.componentManager.lookup(Roles.SOURCE_HANDLER);
  +            environment.setSourceHandler(sourceHandler);
               String markupLanguage = "xsp";
               String programmingLanguage = "java";
   
  @@ -420,9 +419,9 @@
               getLogger().error("Main: Error compiling XSP", e);
               throw e;
           } finally {
  -            environment.setURLResolver(null);
  +            environment.setSourceHandler(null);
               if (programGenerator != null) this.componentManager.release(programGenerator);
  -            if (urlFactory != null) this.componentManager.release((Component) urlFactory);
  +            if (sourceHandler != null) this.componentManager.release((Component) sourceHandler);
           }
       }
   }
  
  
  
  1.8       +34 -18    xml-cocoon2/src/org/apache/cocoon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Main.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Main.java	2001/07/03 08:11:34	1.7
  +++ Main.java	2001/07/04 07:56:38	1.8
  @@ -48,7 +48,7 @@
    * Command line entry point.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/07/03 08:11:34 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/07/04 07:56:38 $
    */
   
   public class Main {
  @@ -353,7 +353,7 @@
           log.info("Warming up...");
           log.info(" [Cocoon might need to compile the sitemaps, this might take a while]");
           //cocoon.process(new LinkSamplingEnvironment("/", context, attributes, null));
  -        cocoon.generateSitemap(new LinkSamplingEnvironment("/", context, attributes, null));
  +        cocoon.generateSitemap(new LinkSamplingEnvironment("/", context, attributes, null, this.log));
       }
   
       /**
  @@ -366,15 +366,15 @@
           HashSet links = new HashSet();
           links.addAll(uris);
           while (links.size() > 0) {
  -        	Iterator i = links.iterator();
  -           	String url = (String)i.next();
  -           	if(allProcessedLinks.get(url) == null){
  +            Iterator i = links.iterator();
  +            String url = (String)i.next();
  +            if(allProcessedLinks.get(url) == null){
                   if(xspOnly){
                       this.processXSP(url);
                   }else{
                       links.addAll(this.processURI(url));
                   }
  -	        }
  +            }
               links.remove(url);
               nCount++;
   
  @@ -403,7 +403,7 @@
       }
   
       public void processXSP(String uri) throws Exception {
  -        Environment env = new LinkSamplingEnvironment("/", context, attributes, null);
  +        Environment env = new LinkSamplingEnvironment("/", context, attributes, null, this.log);
           cocoon.generateXSP(uri, env);
       }
   
  @@ -427,7 +427,7 @@
       public Collection processURI(String uri) throws Exception {
           log.info("Processing URI: " + uri);
   
  -	    // Get parameters, deperameterized URI and path from URI
  +        // Get parameters, deperameterized URI and path from URI
           final HashMap parameters = new HashMap();
           parameters.put("user-agent", userAgent);
           parameters.put("accept", accept);
  @@ -437,9 +437,9 @@
           // Get file name from URI (without path)
           String pageURI = deparameterizedURI;
           if(pageURI.indexOf("/") != -1){
  -	        pageURI = pageURI.substring(pageURI.lastIndexOf("/") + 1);
  -	        if(pageURI.length() == 0) pageURI = "./";
  -	    }
  +            pageURI = pageURI.substring(pageURI.lastIndexOf("/") + 1);
  +            if(pageURI.length() == 0) pageURI = "./";
  +        }
   
           String filename = (String)allTranslatedLinks.get(uri);
           if(filename == null){
  @@ -464,7 +464,7 @@
               String relativeLink = (String) i.next();
               // Fix relative links starting with "?"
               if(relativeLink.startsWith("?")){
  -            	relativeLink = pageURI + relativeLink;
  +                relativeLink = pageURI + relativeLink;
               }
   
               final String absoluteLink = NetUtils.normalize(NetUtils.absolutize(path, relativeLink));
  @@ -549,26 +549,42 @@
       }
   
       Collection getLinks(String deparameterizedURI, Map parameters) throws Exception {
  -        LinkSamplingEnvironment env = new LinkSamplingEnvironment(deparameterizedURI, context, attributes, parameters);
  +        LinkSamplingEnvironment env = new LinkSamplingEnvironment(deparameterizedURI,
  +                  context,
  +                  attributes,
  +                  parameters,
  +                  this.log);
           cocoon.process(env);
           return env.getLinks();
       }
   
       String getPage(String deparameterizedURI, Map parameters, Map links, OutputStream stream) throws Exception {
  -        FileSavingEnvironment env = new FileSavingEnvironment(deparameterizedURI, context, attributes, parameters, links, stream);
  +        FileSavingEnvironment env = new FileSavingEnvironment(deparameterizedURI,
  +                        context,
  +                        attributes,
  +                        parameters,
  +                        links,
  +                        stream,
  +                        this.log);
           cocoon.process(env);
           return env.getContentType();
       }
   
       static class NullOutputStream extends OutputStream
       {
  -	    public void write(int b) throws IOException { }
  -	    public void write(byte b[]) throws IOException { }
  -	    public void write(byte b[], int off, int len) throws IOException { }
  +        public void write(int b) throws IOException { }
  +        public void write(byte b[]) throws IOException { }
  +        public void write(byte b[], int off, int len) throws IOException { }
       }
   
       String getType(String deparameterizedURI, Map parameters) throws Exception {
  -        FileSavingEnvironment env = new FileSavingEnvironment(deparameterizedURI, context, attributes, parameters, empty, new NullOutputStream());
  +        FileSavingEnvironment env = new FileSavingEnvironment(deparameterizedURI,
  +                     context,
  +                     attributes,
  +                     parameters,
  +                     empty,
  +                     new NullOutputStream(),
  +                     this.log);
           cocoon.process(env);
           return env.getContentType();
       }
  
  
  
  1.2       +2 -1      xml-cocoon2/src/org/apache/cocoon/Roles.java
  
  Index: Roles.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Roles.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Roles.java	2001/05/09 20:49:27	1.1
  +++ Roles.java	2001/07/04 07:56:39	1.2
  @@ -12,7 +12,7 @@
    * Created this interface to specify the Avalon role names.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/05/09 20:49:27 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/07/04 07:56:39 $
    */
   
   public interface Roles {
  @@ -33,6 +33,7 @@
       String IMAGE_ENCODER        = "org.apache.cocoon.components.image.ImageEncoderSelector";
       String DB_CONNECTION        = "org.apache.avalon.excalibur.datasource.DataSourceComponentSelector";
       String URL_FACTORY          = "org.apache.cocoon.components.url.URLFactory";
  +    String SOURCE_HANDLER       = "org.apache.cocoon.components.source.SourceHandler";
   
       String ACTIONS              = "org.apache.cocoon.acting.ActionSelector";
       String SELECTORS            = "org.apache.cocoon.selection.SelectorSelector";
  
  
  
  1.12      +4 -0      xml-cocoon2/src/org/apache/cocoon/cocoon.roles
  
  Index: cocoon.roles
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/cocoon.roles,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- cocoon.roles	2001/06/22 15:27:36	1.11
  +++ cocoon.roles	2001/07/04 07:56:40	1.12
  @@ -54,6 +54,10 @@
          shorthand="url-factory"
          default-class="org.apache.cocoon.components.url.URLFactoryImpl"/>
   
  + <role name="org.apache.cocoon.components.source.SourceHandler"
  +       shorthand="source-handler"
  +       default-class="org.apache.cocoon.components.source.SourceHandlerImpl"/>
  +
    <role name="org.apache.cocoon.components.sax.XMLSerializer"
          shorthand="xml-serializer"
          default-class="org.apache.cocoon.components.sax.XMLByteStreamCompiler"/>
  
  
  
  1.4       +252 -252  xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPFormValidatorHelper.java
  
  Index: XSPFormValidatorHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPFormValidatorHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSPFormValidatorHelper.java	2001/06/28 09:56:32	1.3
  +++ XSPFormValidatorHelper.java	2001/07/04 07:56:49	1.4
  @@ -18,9 +18,9 @@
   import org.apache.cocoon.components.parser.Parser;
   import org.apache.cocoon.components.url.URLFactory;
   import org.apache.cocoon.components.language.markup.xsp.XSPObjectHelper;
  +import org.apache.cocoon.components.source.URLSource;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Source;
  -import org.apache.cocoon.environment.URLSource;
   
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
  @@ -39,7 +39,7 @@
    * The <code>ValidatorActionResult</code> object helper
    *
    * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/06/28 09:56:32 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/07/04 07:56:49 $
    */
   public class XSPFormValidatorHelper {
     /**
  @@ -48,11 +48,11 @@
       private static final String URI = Constants.XSP_FORMVALIDATOR_URI;
       private static final String PREFIX = Constants.XSP_FORMVALIDATOR_PREFIX;
       private static Map configurations = new HashMap();
  -    
  +
       /**
        * these make it easier for the xsl
        */
  -    
  +
       String current_descriptor = null;
       boolean current_reloadable = true;
       Logger current_logger = null;
  @@ -60,35 +60,35 @@
       String current_parameter = null;
       ComponentManager current_manager = null;
   
  -    public XSPFormValidatorHelper ( String descriptor, 
  -				    boolean reloadable,
  -				    Logger logger,
  -				    ComponentManager manager
  -				    ) {
  -	current_descriptor = descriptor;
  -	current_reloadable = reloadable;
  -	current_logger = logger;
  -	current_manager = manager;
  -    }
  -
  -    public XSPFormValidatorHelper ( String descriptor, 
  -				    boolean reloadable,
  -				    Logger logger,
  -				    ComponentManager manager,
  -				    String constraintset
  -				    ) {
  -	current_descriptor = descriptor;
  -	current_reloadable = reloadable;
  -	current_logger = logger;
  -	current_manager = manager;
  -	current_constraint_set = constraintset;
  +    public XSPFormValidatorHelper ( String descriptor,
  +                    boolean reloadable,
  +                    Logger logger,
  +                    ComponentManager manager
  +                    ) {
  +    current_descriptor = descriptor;
  +    current_reloadable = reloadable;
  +    current_logger = logger;
  +    current_manager = manager;
  +    }
  +
  +    public XSPFormValidatorHelper ( String descriptor,
  +                    boolean reloadable,
  +                    Logger logger,
  +                    ComponentManager manager,
  +                    String constraintset
  +                    ) {
  +    current_descriptor = descriptor;
  +    current_reloadable = reloadable;
  +    current_logger = logger;
  +    current_manager = manager;
  +    current_constraint_set = constraintset;
       }
   
       /**
        * keep track of current parameter context
        */
       public void setParameter ( String parameter ) {
  -	current_parameter = parameter;
  +    current_parameter = parameter;
       }
   
       /**
  @@ -96,7 +96,7 @@
        * (probably this is not needed?)
        */
       public void setConstraintSet ( String constraintset ) {
  -	current_constraint_set = constraintset;
  +    current_constraint_set = constraintset;
       }
   
     /**
  @@ -120,13 +120,13 @@
      * @return Map with ValidatorActionResults
      * @see org.apache.cocoon.acting.ValitatorActionResult
      */
  -    public static 
  -	Map getResults ( 
  -			Map objectModel 
  -			) 
  +    public static
  +    Map getResults (
  +            Map objectModel
  +            )
       {
  -	Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
  -	return (Map) request.getAttribute(Constants.XSP_FORMVALIDATOR_PATH);
  +    Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
  +    return (Map) request.getAttribute(Constants.XSP_FORMVALIDATOR_PATH);
       }
   
   
  @@ -140,18 +140,18 @@
      * @see org.apache.cocoon.acting.ValitatorActionResult
      */
       public static
  -	ValidatorActionResult getParamResult (
  -					      Map objectModel,
  -					      String name
  -					      )
  -    {
  -	ValidatorActionResult result = ValidatorActionResult.NOTPRESENT;
  -	Map param_result = (Map) getResults(objectModel);
  -	if (param_result != null ) {
  -	    result = (ValidatorActionResult) param_result.get(name);
  -	}
  -	return result;
  +    ValidatorActionResult getParamResult (
  +                          Map objectModel,
  +                          String name
  +                          )
  +    {
  +    ValidatorActionResult result = ValidatorActionResult.NOTPRESENT;
  +    Map param_result = (Map) getResults(objectModel);
  +    if (param_result != null ) {
  +        result = (ValidatorActionResult) param_result.get(name);
       }
  +    return result;
  +    }
   
     /**
      * Extracts the validation results from the request attribute
  @@ -160,22 +160,22 @@
      * @param objectModel The Map objectModel
      * @see org.apache.cocoon.acting.ValitatorActionResult
      */
  -    public 
  -	ValidatorActionResult getParamResult (
  -					      Map objectModel
  -					      )
  +    public
  +    ValidatorActionResult getParamResult (
  +                          Map objectModel
  +                          )
       {
  -	ValidatorActionResult result = ValidatorActionResult.NOTPRESENT;
  -	Map param_result = (Map) getResults(objectModel);
  -	if (param_result != null ) {
  -	    result = (ValidatorActionResult) param_result.get(current_parameter);
  -	}
  -	return result;
  +    ValidatorActionResult result = ValidatorActionResult.NOTPRESENT;
  +    Map param_result = (Map) getResults(objectModel);
  +    if (param_result != null ) {
  +        result = (ValidatorActionResult) param_result.get(current_parameter);
  +    }
  +    return result;
       }
   
   
     /**
  -   * Test whether the validation returned no error for this 
  +   * Test whether the validation returned no error for this
      * parameter.
      *
      * @param objectModel The Map objectModel
  @@ -183,14 +183,14 @@
      * @return true only if the parameter was validated and the validation
      * did not return an error.
      */
  -    public static 
  -	boolean isOK(
  -		     Map objectModel, 
  -		     String name 
  -		     ) 
  +    public static
  +    boolean isOK(
  +             Map objectModel,
  +             String name
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, name).equals(ValidatorActionResult.OK);
  +    boolean ok = false;
  +    return getParamResult(objectModel, name).equals(ValidatorActionResult.OK);
       }
   
     /**
  @@ -201,18 +201,18 @@
      * @return true only if the parameter was validated and the validation
      * did not return an error.
      */
  -    public 
  -	boolean isOK(
  -		     Map objectModel
  -		     ) 
  +    public
  +    boolean isOK(
  +             Map objectModel
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.OK);
  +    boolean ok = false;
  +    return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.OK);
       }
   
   
     /**
  -   * Test whether the validation returned an error for this 
  +   * Test whether the validation returned an error for this
      * parameter.
      *
      * @param objectModel The Map objectModel
  @@ -220,14 +220,14 @@
      * @return true if the parameter was either not validated or the validation
      * returned an error.
      */
  -    public static 
  -	boolean isError(
  -		     Map objectModel, 
  -		     String name 
  -		     ) 
  +    public static
  +    boolean isError(
  +             Map objectModel,
  +             String name
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, name).ge(ValidatorActionResult.ERROR);
  +    boolean ok = false;
  +    return getParamResult(objectModel, name).ge(ValidatorActionResult.ERROR);
       }
   
     /**
  @@ -238,13 +238,13 @@
      * @return true if the parameter was either not validated or the validation
      * returned an error.
      */
  -    public 
  -	boolean isError(
  -		     Map objectModel
  -		     ) 
  +    public
  +    boolean isError(
  +             Map objectModel
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, current_parameter).ge(ValidatorActionResult.ERROR);
  +    boolean ok = false;
  +    return getParamResult(objectModel, current_parameter).ge(ValidatorActionResult.ERROR);
       }
   
   
  @@ -256,31 +256,31 @@
      * @return true if the parameter was validated and the validation
      * returned an error because the parameter was null but wasn't allowd to.
      */
  -    public static 
  -	boolean isNull(
  -		     Map objectModel, 
  -		     String name 
  -		     ) 
  +    public static
  +    boolean isNull(
  +             Map objectModel,
  +             String name
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, name).equals(ValidatorActionResult.ISNULL);
  +    boolean ok = false;
  +    return getParamResult(objectModel, name).equals(ValidatorActionResult.ISNULL);
       }
   
     /**
  -   * Test whether the context's current parameter as validated was null but 
  +   * Test whether the context's current parameter as validated was null but
      * wasn't allowed to.
      *
      * @param objectModel The Map objectModel
      * @return true if the parameter was validated and the validation
      * returned an error because the parameter was null but wasn't allowd to.
      */
  -    public 
  -	boolean isNull(
  -		     Map objectModel
  -		     ) 
  +    public
  +    boolean isNull(
  +             Map objectModel
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.ISNULL);
  +    boolean ok = false;
  +    return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.ISNULL);
       }
   
   
  @@ -293,14 +293,14 @@
      * returned an error because either its value or its length was
      * too small.
      */
  -    public static 
  -	boolean isTooSmall(
  -		     Map objectModel, 
  -		     String name 
  -		     ) 
  +    public static
  +    boolean isTooSmall(
  +             Map objectModel,
  +             String name
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, name).equals(ValidatorActionResult.TOOSMALL);
  +    boolean ok = false;
  +    return getParamResult(objectModel, name).equals(ValidatorActionResult.TOOSMALL);
       }
   
     /**
  @@ -311,13 +311,13 @@
      * returned an error because either its value or its length was
      * too small.
      */
  -    public 
  -	boolean isTooSmall(
  -		     Map objectModel
  -		     ) 
  +    public
  +    boolean isTooSmall(
  +             Map objectModel
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.TOOSMALL);
  +    boolean ok = false;
  +    return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.TOOSMALL);
       }
   
   
  @@ -330,14 +330,14 @@
      * returned an error because either its value or its length was
      * too large.
      */
  -    public static 
  -	boolean isTooLarge(
  -		     Map objectModel, 
  -		     String name 
  -		     ) 
  +    public static
  +    boolean isTooLarge(
  +             Map objectModel,
  +             String name
  +             )
       {
  -	boolean ok = false;
  -	return (getParamResult(objectModel, name) == ValidatorActionResult.TOOLARGE);
  +    boolean ok = false;
  +    return (getParamResult(objectModel, name) == ValidatorActionResult.TOOLARGE);
       }
   
     /**
  @@ -348,18 +348,18 @@
      * returned an error because either its value or its length was
      * too large.
      */
  -    public 
  -	boolean isTooLarge(
  -		     Map objectModel
  -		     ) 
  +    public
  +    boolean isTooLarge(
  +             Map objectModel
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.TOOLARGE);
  +    boolean ok = false;
  +    return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.TOOLARGE);
       }
   
   
     /**
  -   * Test whether the validated parameter wasn't matched by the requested 
  +   * Test whether the validated parameter wasn't matched by the requested
      * regular expression.
      *
      * @param objectModel The Map objectModel
  @@ -368,18 +368,18 @@
      * returned an error because its value wasn't matched by the requested
      * regular expression.
      */
  -    public static 
  -	boolean isNoMatch(
  -		     Map objectModel, 
  -		     String name 
  -		     ) 
  +    public static
  +    boolean isNoMatch(
  +             Map objectModel,
  +             String name
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, name).equals(ValidatorActionResult.NOMATCH);
  +    boolean ok = false;
  +    return getParamResult(objectModel, name).equals(ValidatorActionResult.NOMATCH);
       }
   
     /**
  -   * Test whether the context's current parameter wasn't matched by the requested 
  +   * Test whether the context's current parameter wasn't matched by the requested
      * regular expression.
      *
      * @param objectModel The Map objectModel
  @@ -387,13 +387,13 @@
      * returned an error because its value wasn't matched by the requested
      * regular expression.
      */
  -    public 
  -	boolean isNoMatch(
  -		     Map objectModel
  -		     ) 
  +    public
  +    boolean isNoMatch(
  +             Map objectModel
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.NOMATCH);
  +    boolean ok = false;
  +    return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.NOMATCH);
       }
   
   
  @@ -404,14 +404,14 @@
      * @param name Request parameter's name
      * @return true if the parameter was not validated.
      */
  -    public static 
  -	boolean isNotPresent(
  -		     Map objectModel, 
  -		     String name 
  -		     ) 
  +    public static
  +    boolean isNotPresent(
  +             Map objectModel,
  +             String name
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, name).equals(ValidatorActionResult.NOTPRESENT);
  +    boolean ok = false;
  +    return getParamResult(objectModel, name).equals(ValidatorActionResult.NOTPRESENT);
       }
   
     /**
  @@ -420,13 +420,13 @@
      * @param objectModel The Map objectModel
      * @return true if the parameter was not validated.
      */
  -    public 
  -	boolean isNotPresent(
  -		     Map objectModel
  -		     ) 
  +    public
  +    boolean isNotPresent(
  +             Map objectModel
  +             )
       {
  -	boolean ok = false;
  -	return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.NOTPRESENT);
  +    boolean ok = false;
  +    return getParamResult(objectModel, current_parameter).equals(ValidatorActionResult.NOTPRESENT);
       }
   
   
  @@ -436,13 +436,13 @@
        * this approach, we can limit the number of config files.
        * Also note that the configuration file does not have to be a file.
        *
  -     * This is based on the similar named functions in 
  +     * This is based on the similar named functions in
        * org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
        * with the addition of reloadable configuration files, reloadable
        * flagg, manager, and logger  parameter.
        *
        * @param descriptor URL of descriptor.xml file @see org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
  -     * @param manager 
  +     * @param manager
        * @param reloadable set to <code>true</code> if changes of
        * <code>descriptor</code> should trigger a reload. Note that this
        * only works if <code>Source</code> is able to determine the
  @@ -452,11 +452,11 @@
        */
   
       protected static Configuration getConfiguration(
  -					     String descriptor, 
  -					     ComponentManager manager,
  -					     boolean reloadable,
  -					     Logger logger  
  -				     ) throws ConfigurationException {
  +                         String descriptor,
  +                         ComponentManager manager,
  +                         boolean reloadable,
  +                         Logger logger
  +                     ) throws ConfigurationException {
           ConfigurationHelper conf = null;
   
           if (descriptor == null) {
  @@ -465,43 +465,43 @@
   
           synchronized (XSPFormValidatorHelper.configurations) {
               conf = (ConfigurationHelper) XSPFormValidatorHelper.configurations.get(descriptor);
  -	    Source source = null;
  -	    Parser parser = null;
  -	    URLFactory urlFactory = null;
  -	    try {
  -		urlFactory = (URLFactory) manager.lookup(Roles.URL_FACTORY);
  -		URL resource = urlFactory.getURL(descriptor);
  +        Source source = null;
  +        Parser parser = null;
  +        URLFactory urlFactory = null;
  +        try {
  +        urlFactory = (URLFactory) manager.lookup(Roles.URL_FACTORY);
  +        URL resource = urlFactory.getURL(descriptor);
           source = new URLSource(resource, manager);
  -		
  -		if (conf == null || ( reloadable && conf.lastModified < source.getLastModified())) {
  -		    logger.debug("XSPFormValidatorHelper.getConfiguration: (Re)Loading " + descriptor);
  -		    
  -		    if (conf == null) 
  -			conf = new ConfigurationHelper();
  -
  -		    parser = (Parser) manager.lookup(Roles.PARSER);
  -		    SAXConfigurationHandler builder = new SAXConfigurationHandler();
  -		    
  -		    InputSource inputSource = source.getInputSource();
  -		    inputSource.setSystemId(source.getSystemId());
  -		    
  -		    parser.setContentHandler(builder);
  -		    parser.parse(inputSource);
  -		    
  -		    conf.lastModified = source.getLastModified();
  -		    conf.configuration = builder.getConfiguration();
  -		    
  -		    XSPFormValidatorHelper.cacheConfiguration(descriptor, conf);
  -		} else {
  -		    logger.debug("XSPFormValidatorHelper.getConfiguration: Using cached configuration for " + descriptor);
  -		}
  -	    } catch (Exception e) {
  -		logger.error("XSPFormValidatorHelper.getConfiguration: Could not configure Database mapping environment", e);
  -		throw new ConfigurationException("Error trying to load configurations for resource: " + source.getSystemId());
  -	    } finally {
  -		if (urlFactory != null) manager.release((Component) urlFactory);
  -		if (parser != null) manager.release(parser);
  -	    }
  +
  +        if (conf == null || ( reloadable && conf.lastModified < source.getLastModified())) {
  +            logger.debug("XSPFormValidatorHelper.getConfiguration: (Re)Loading " + descriptor);
  +
  +            if (conf == null)
  +            conf = new ConfigurationHelper();
  +
  +            parser = (Parser) manager.lookup(Roles.PARSER);
  +            SAXConfigurationHandler builder = new SAXConfigurationHandler();
  +
  +            InputSource inputSource = source.getInputSource();
  +            inputSource.setSystemId(source.getSystemId());
  +
  +            parser.setContentHandler(builder);
  +            parser.parse(inputSource);
  +
  +            conf.lastModified = source.getLastModified();
  +            conf.configuration = builder.getConfiguration();
  +
  +            XSPFormValidatorHelper.cacheConfiguration(descriptor, conf);
  +        } else {
  +            logger.debug("XSPFormValidatorHelper.getConfiguration: Using cached configuration for " + descriptor);
  +        }
  +        } catch (Exception e) {
  +        logger.error("XSPFormValidatorHelper.getConfiguration: Could not configure Database mapping environment", e);
  +        throw new ConfigurationException("Error trying to load configurations for resource: " + source.getSystemId());
  +        } finally {
  +        if (urlFactory != null) manager.release((Component) urlFactory);
  +        if (parser != null) manager.release(parser);
  +        }
           }
   
           return conf.configuration;
  @@ -522,29 +522,29 @@
        *
        * @param conf set of configurations
        * @param name name of configuration
  -     * @param logger 
  +     * @param logger
        * @return specified configuration or <code>null</code> if not found.
        */
       protected static Configuration getConfigurationByName ( Configuration[] conf,
  -							    String name ,
  -							    Logger logger  
  -						     )
  -    {
  -	int j = 0;
  -	boolean found = false;
  -	String setname = null;
  -	for (j = 0; j < conf.length; j ++) {
  -	    setname = conf[j].getAttribute ("name", "");
  -	    if (name.trim().equals (setname.trim ())) {
  -		found = true;
  -		break;
  -	    }
  -	}
  -	if (!found) {
  -	    logger.debug("XSPFormValidatorHelper.getConfigurationByName: configuration " + name + " not found.");
  -	    return null;
  -	}
  -	return conf[j];
  +                                String name ,
  +                                Logger logger
  +                             )
  +    {
  +    int j = 0;
  +    boolean found = false;
  +    String setname = null;
  +    for (j = 0; j < conf.length; j ++) {
  +        setname = conf[j].getAttribute ("name", "");
  +        if (name.trim().equals (setname.trim ())) {
  +        found = true;
  +        break;
  +        }
  +    }
  +    if (!found) {
  +        logger.debug("XSPFormValidatorHelper.getConfigurationByName: configuration " + name + " not found.");
  +        return null;
  +    }
  +    return conf[j];
       }
   
       /**
  @@ -552,7 +552,7 @@
        * descriptor.xml.
        *
        * @param descriptor URL of descriptor.xml file @see org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
  -     * @param manager 
  +     * @param manager
        * @param reloadable set to <code>true</code> if changes of
        * <code>descriptor</code> should trigger a reload. Note that this
        * only works if <code>Source</code> is able to determine the
  @@ -562,29 +562,29 @@
        * @return attribute value or <code>null</code>
        */
       public static String getParameterAttributes ( String descriptor,
  -						  ComponentManager manager,
  -						  boolean reloadable,
  -						  String constraintset,
  -						  String parameter,
  -						  String attribute,
  -						  Logger logger  
  -					   )
  -    {
  -	try {
  -	    Configuration conf = getConfiguration(descriptor, manager, reloadable, logger);
  -	    Configuration[] desc = conf.getChildren ("parameter");
  -	    Configuration[] csets = conf.getChildren ("constraint-set");
  -	    
  -	    Configuration cset = getConfigurationByName ( csets, constraintset, logger );
  -	    
  -	    Configuration[] set = cset.getChildren ("validate");
  -	    Configuration constraints = getConfigurationByName(set,parameter, logger);
  -	    Configuration descr = getConfigurationByName(desc,parameter, logger);
  -	    return constraints.getAttribute(attribute,descr.getAttribute(attribute,""));
  -	} catch (Exception e ) {
  -	    logger.debug("XSPFormValidatorHelper.getParameterAttributes Exception " +e);
  -	};
  -	return "";
  +                          ComponentManager manager,
  +                          boolean reloadable,
  +                          String constraintset,
  +                          String parameter,
  +                          String attribute,
  +                          Logger logger
  +                       )
  +    {
  +    try {
  +        Configuration conf = getConfiguration(descriptor, manager, reloadable, logger);
  +        Configuration[] desc = conf.getChildren ("parameter");
  +        Configuration[] csets = conf.getChildren ("constraint-set");
  +
  +        Configuration cset = getConfigurationByName ( csets, constraintset, logger );
  +
  +        Configuration[] set = cset.getChildren ("validate");
  +        Configuration constraints = getConfigurationByName(set,parameter, logger);
  +        Configuration descr = getConfigurationByName(desc,parameter, logger);
  +        return constraints.getAttribute(attribute,descr.getAttribute(attribute,""));
  +    } catch (Exception e ) {
  +        logger.debug("XSPFormValidatorHelper.getParameterAttributes Exception " +e);
  +    };
  +    return "";
       }
   
   
  @@ -597,13 +597,13 @@
        */
       public String getParameterAttribute ( String attribute )
       {
  -	return XSPFormValidatorHelper.getParameterAttributes ( current_descriptor,
  -							       current_manager, 
  -							       current_reloadable, 
  -							       current_constraint_set, 
  -							       current_parameter, 
  -							       attribute, 
  -							       current_logger );
  +    return XSPFormValidatorHelper.getParameterAttributes ( current_descriptor,
  +                                   current_manager,
  +                                   current_reloadable,
  +                                   current_constraint_set,
  +                                   current_parameter,
  +                                   attribute,
  +                                   current_logger );
       }
   
       /**
  @@ -615,13 +615,13 @@
        */
       public String getParameterAttribute ( String parameter, String attribute )
       {
  -	return XSPFormValidatorHelper.getParameterAttributes ( current_descriptor,
  -							       current_manager, 
  -							       current_reloadable, 
  -							       current_constraint_set, 
  -							       parameter, 
  -							       attribute, 
  -							       current_logger );
  +    return XSPFormValidatorHelper.getParameterAttributes ( current_descriptor,
  +                                   current_manager,
  +                                   current_reloadable,
  +                                   current_constraint_set,
  +                                   parameter,
  +                                   attribute,
  +                                   current_logger );
       }
   
   }
  
  
  
  1.2       +64 -0     xml-cocoon2/src/org/apache/cocoon/components/source/CocoonSourceFactory.java
  
  
  
  
  1.2       +240 -0    xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java
  
  
  
  
  1.2       +35 -0     xml-cocoon2/src/org/apache/cocoon/components/source/SourceFactory.java
  
  
  
  
  1.2       +49 -0     xml-cocoon2/src/org/apache/cocoon/components/source/SourceHandler.java
  
  
  
  
  1.2       +196 -0    xml-cocoon2/src/org/apache/cocoon/components/source/SourceHandlerImpl.java
  
  
  
  
  1.2       +292 -0    xml-cocoon2/src/org/apache/cocoon/components/source/URLSource.java
  
  
  
  
  1.8       +16 -17    xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java
  
  Index: AbstractEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractEnvironment.java	2001/06/28 09:56:34	1.7
  +++ AbstractEnvironment.java	2001/07/04 07:57:08	1.8
  @@ -16,8 +16,7 @@
   import java.util.Map;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.log.LogKit;
  +import org.apache.cocoon.components.source.SourceHandler;
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   
  @@ -41,8 +40,8 @@
       /** The servlet object model */
       protected HashMap objectModel = null;
   
  -    /** The URL Resolver for the current environment */
  -    protected URLResolver urlResolver;
  +    /** The source handler for the current environment */
  +    protected SourceHandler sourceHandler;
   
       /**
        * Constructs the abstract enviornment
  @@ -89,10 +88,10 @@
       }
   
       /**
  -     * Set the URLFactory for the current request
  +     * Set the <code>SourceHandler</code> for the current request
        */
  -    public void setURLResolver(URLResolver resolver) {
  -        this.urlResolver = resolver;
  +    public void setSourceHandler(SourceHandler sourceHandler) {
  +        this.sourceHandler = sourceHandler;
       }
   
       // Sitemap methods
  @@ -110,9 +109,9 @@
       public void changeContext(String prefix, String context)
       throws MalformedURLException {
           String uri = (String)this.uris.get(this.uris.size()-1);
  -        LogKit.getLoggerFor("cocoon").debug("Changing Cocoon context(" + context + ") to prefix(" + prefix + ")");
  -        LogKit.getLoggerFor("cocoon").debug("\tfrom context(" + this.context.toExternalForm() + ") and prefix(" + this.prefix + ")");
  -        LogKit.getLoggerFor("cocoon").debug("\tat URI " + uri);
  +        getLogger().debug("Changing Cocoon context(" + context + ") to prefix(" + prefix + ")");
  +        getLogger().debug("\tfrom context(" + this.context.toExternalForm() + ") and prefix(" + this.prefix + ")");
  +        getLogger().debug("\tat URI " + uri);
           if(prefix.length()>=1){
               if (uri.startsWith(prefix)) {
                   this.prefix.append(prefix);
  @@ -149,7 +148,7 @@
                   );
               }
           }
  -        LogKit.getLoggerFor("cocoon").debug("New context is " + this.context.toExternalForm());
  +        getLogger().debug("New context is " + this.context.toExternalForm());
           this.uris.set(this.uris.size()-1, uri);
       }
   
  @@ -199,19 +198,19 @@
           if (systemId == null) throw new SAXException("Invalid System ID");
   
           if (systemId.length() == 0)
  -            return this.urlResolver.getSource(this, this.context.toExternalForm());
  +            return this.sourceHandler.getSource(this, this.context.toExternalForm());
           if (systemId.indexOf(":") > 1)
  -            return this.urlResolver.getSource(this, systemId);
  +            return this.sourceHandler.getSource(this, systemId);
           if (systemId.charAt(0) == '/')
  -            return this.urlResolver.getSource(this, this.context.getProtocol() + ":" + systemId);
  -        return this.urlResolver.getSource(this, this.context, systemId);
  +            return this.sourceHandler.getSource(this, this.context.getProtocol() + ":" + systemId);
  +        return this.sourceHandler.getSource(this, this.context, systemId);
       }
   
       /**
        * Push a new URI for processing
        */
       public void pushURI(String uri) {
  -        this.uris.add(this.urlResolver);
  +        this.uris.add(this.sourceHandler);
           this.uris.add(uri);
       }
   
  @@ -221,7 +220,7 @@
       public String popURI() {
           String uri = (String)this.uris.get(this.uris.size()-1);
           this.uris.remove(this.uris.size()-1);
  -        this.urlResolver = (URLResolver)this.uris.get(this.uris.size()-1);
  +        this.sourceHandler = (SourceHandler)this.uris.get(this.uris.size()-1);
           this.uris.remove(this.uris.size()-1);
           return uri;
       }
  
  
  
  1.3       +4 -3      xml-cocoon2/src/org/apache/cocoon/environment/Environment.java
  
  Index: Environment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/Environment.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Environment.java	2001/05/22 14:38:43	1.2
  +++ Environment.java	2001/07/04 07:57:10	1.3
  @@ -12,21 +12,22 @@
   import java.io.OutputStream;
   import java.net.MalformedURLException;
   import java.util.Map;
  +import org.apache.cocoon.components.source.SourceHandler;
   import org.xml.sax.SAXException;
   
   /**
    * Base interface for an environment abstraction
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/05/22 14:38:43 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/07/04 07:57:10 $
    */
   
   public interface Environment extends SourceResolver {
   
       /**
  -     * Set the URLFactory for the current request
  +     * Set the <code>SourceHandler</code> for the current request
        */
  -    void setURLResolver(URLResolver resolver);
  +    void setSourceHandler(SourceHandler sourceHandler);
   
       /**
        * Get the URI to process
  
  
  
  1.4       +8 -3      xml-cocoon2/src/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
  
  Index: AbstractCommandLineEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractCommandLineEnvironment.java	2001/06/08 20:28:19	1.3
  +++ AbstractCommandLineEnvironment.java	2001/07/04 07:57:23	1.4
  @@ -14,13 +14,13 @@
   import java.net.MalformedURLException;
   import org.apache.cocoon.environment.AbstractEnvironment;
   import org.apache.cocoon.environment.Redirector;
  +import org.apache.log.Logger;
   
  -
   /**
    * This environment is used to save the requested file to disk.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/06/08 20:28:19 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/07/04 07:57:23 $
    */
   
   public abstract class AbstractCommandLineEnvironment
  @@ -31,9 +31,14 @@
       protected OutputStream stream;
       protected int contentLength;
   
  -    public AbstractCommandLineEnvironment(String uri, String view, File context, OutputStream stream)
  +    public AbstractCommandLineEnvironment(String uri,
  +                                          String view,
  +                                          File context,
  +                                          OutputStream stream,
  +                                          Logger log)
       throws MalformedURLException {
           super(uri, view, context);
  +        this.setLogger(log);
           this.stream = stream;
       }
   
  
  
  
  1.3       +11 -5     xml-cocoon2/src/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java
  
  Index: FileSavingEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileSavingEnvironment.java	2001/05/10 22:19:34	1.2
  +++ FileSavingEnvironment.java	2001/07/04 07:57:25	1.3
  @@ -14,23 +14,29 @@
   import java.io.OutputStream;
   import java.net.MalformedURLException;
   import java.util.Map;
  +import org.apache.log.Logger;
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.environment.AbstractEnvironment;
  -import org.apache.log.LogKit;
   
   /**
    * This environment is used to save the requested file to disk.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/05/10 22:19:34 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/07/04 07:57:25 $
    */
   
   public class FileSavingEnvironment extends AbstractCommandLineEnvironment {
   
  -    public FileSavingEnvironment(String uri, File context, Map attributes, Map parameters, Map links, OutputStream stream)
  +    public FileSavingEnvironment(String uri,
  +                                 File context,
  +                                 Map attributes,
  +                                 Map parameters,
  +                                 Map links,
  +                                 OutputStream stream,
  +                                 Logger log)
       throws MalformedURLException {
  -        super(uri, null, context, stream);
  -        LogKit.getLoggerFor("cocoon").debug("FileSavingEnvironment: uri=" + uri);
  +        super(uri, null, context, stream, log);
  +        this.getLogger().debug("FileSavingEnvironment: uri=" + uri);
           this.objectModel.put(Constants.LINK_OBJECT, links);
           this.objectModel.put(Constants.REQUEST_OBJECT, new CommandLineRequest(this, null, uri, null, attributes, parameters));
           this.objectModel.put(Constants.RESPONSE_OBJECT, new CommandLineResponse());
  
  
  
  1.3       +9 -5      xml-cocoon2/src/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java
  
  Index: LinkSamplingEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LinkSamplingEnvironment.java	2001/05/10 22:19:35	1.2
  +++ LinkSamplingEnvironment.java	2001/07/04 07:57:26	1.3
  @@ -24,23 +24,27 @@
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.Main;
   import org.apache.cocoon.environment.AbstractEnvironment;
  -import org.apache.log.LogKit;
  +import org.apache.log.Logger;
   
   /**
    * This environment is sample the links of the resource.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/05/10 22:19:35 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/07/04 07:57:26 $
    */
   
   public class LinkSamplingEnvironment extends AbstractCommandLineEnvironment {
   
       private boolean skip = false;
   
  -    public LinkSamplingEnvironment(String uri, File contextFile, Map attributes, Map parameters)
  +    public LinkSamplingEnvironment(String uri,
  +                                   File contextFile,
  +                                   Map attributes,
  +                                   Map parameters,
  +                                   Logger log)
       throws MalformedURLException, IOException {
  -        super(uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream());
  -        LogKit.getLoggerFor("cocoon").debug("LinkSamplingEnvironment: uri=" + uri);
  +        super(uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream(), log);
  +        this.getLogger().debug("LinkSamplingEnvironment: uri=" + uri);
           this.objectModel.put(Constants.REQUEST_OBJECT, new CommandLineRequest(this, null, uri, null, attributes, parameters));
           this.objectModel.put(Constants.RESPONSE_OBJECT, new CommandLineResponse());
       }
  
  
  
  1.13      +167 -190  xml-cocoon2/src/org/apache/cocoon/sitemap/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/Handler.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Handler.java	2001/07/02 20:50:45	1.12
  +++ Handler.java	2001/07/04 07:57:31	1.13
  @@ -11,13 +11,9 @@
   import java.io.FileNotFoundException;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.excalibur.component.RoleManager;
   import org.apache.cocoon.ProcessingException;
  @@ -27,11 +23,10 @@
   import org.apache.cocoon.components.language.generator.ProgramGenerator;
   import org.apache.cocoon.components.pipeline.EventPipeline;
   import org.apache.cocoon.components.pipeline.StreamPipeline;
  -import org.apache.cocoon.components.url.URLFactory;
  -import org.apache.cocoon.environment.FactoryURLResolver;
  +import org.apache.cocoon.components.source.CocoonSourceFactory;
  +import org.apache.cocoon.components.source.SourceHandler;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.Source;
  -import org.apache.cocoon.environment.URLResolver;
   
   /**
    * Handles the manageing and stating of one <code>Sitemap</code>
  @@ -39,231 +34,213 @@
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.12 $ $Date: 2001/07/02 20:50:45 $
  + * @version CVS $Revision: 1.13 $ $Date: 2001/07/04 07:57:31 $
    */
  -public class Handler extends AbstractLoggable implements Runnable, Configurable, Composable,
  -    Contextualizable, Processor, Disposable {
  -        private Context context;
  +public class Handler extends AbstractLoggable
  +implements Runnable, Composable, Processor, Disposable {
   
  -    /** the configuration */
  -        private Configuration conf;
  -
       /** the component manager */
  -        private ComponentManager manager;
  +    private ComponentManager manager;
   
       /** the source of this sitemap */
  -        private String sourceFileName;
  -        private Source source;
  -
  -    /** the URLFactory */
  -        private URLFactory urlFactory;
  +    private String sourceFileName;
  +    private Source source;
   
       /** the last error */
  -        private Exception exception;
  +    private Exception exception;
   
       /** the managed sitemap */
  -        private Sitemap sitemap = null;
  -        private boolean check_reload = true;
  +    private Sitemap sitemap = null;
  +    private boolean check_reload = true;
   
       /** the regenerating thread */
  -        private Thread regeneration;
  -        private volatile boolean isRegenerationRunning = false;
  -        private Environment environment;
  +    private Thread regeneration;
  +    private volatile boolean isRegenerationRunning = false;
  +    /** The environment for (re)generation the sitemap */
  +    private Environment environment;
   
       /** the sitemaps base path */
  -        private String basePath;
  -
  -    /** The URLResolver for the sitemap components */
  -        private URLResolver urlResolver;
  +    private String basePath;
   
  -        public void compose(ComponentManager manager) {
  -            this.manager = manager;
  -            try {
  -                urlFactory = (URLFactory)manager.lookup(Roles.URL_FACTORY);
  -            } catch (Exception e) {
  -                getLogger().error("cannot obtain URLFactory", e);
  -            }
  -        }
  +    /** The source handler for the sitemap components */
  +    private SourceHandler sourceHandler;
   
  -        public void configure(Configuration conf) {
  -            this.conf = conf;
  -        }
  +    public void compose(ComponentManager manager)
  +    throws ComponentException {
  +        this.manager = manager;
  +        this.sourceHandler = (SourceHandler)manager.lookup(Roles.SOURCE_HANDLER);
  +    }
  +
  +    protected Handler(String sourceFileName, boolean check_reload) throws FileNotFoundException {
  +        this.check_reload = check_reload;
  +        this.sourceFileName = sourceFileName;
  +    }
  +
  +    protected boolean available() {
  +        return (sitemap != null);
  +    }
  +
  +    protected boolean hasChanged() {
  +        if (available()) {
  +            if (check_reload) {
  +                this.source.refresh();
  +                return sitemap.modifiedSince(this.source.getLastModified());
  +            }
  +            return false;
  +        }
  +        return true;
  +    }
  +
  +    protected boolean isRegenerating() {
  +        return isRegenerationRunning;
  +    }
  +
  +    protected void regenerateAsynchronously(Environment environment) throws Exception {
  +        if (this.sourceFileName.charAt(this.sourceFileName.length() - 1) == '/') {
  +            this.sourceFileName = this.sourceFileName + "sitemap.xmap";
  +        }
  +        try {
  +            environment.setSourceHandler(this.sourceHandler);
  +            this.source = environment.resolve(this.sourceFileName);
  +        } finally {
  +            environment.setSourceHandler(null);
  +        }
  +        if (!this.isRegenerationRunning) {
  +            isRegenerationRunning = true;
  +            regeneration = new Thread(this);
   
  -        public void contextualize(Context context) throws ContextException {
  -            this.context = context;
  -        }
  +            /* HACK for reducing class loader problems. */
   
  -        protected Handler(String sourceFileName, boolean check_reload) throws FileNotFoundException {
  -            this.check_reload = check_reload;
  -            this.sourceFileName = sourceFileName;
  -        }
  +            /* example: xalan extensions fail if someone adds xalan jars in tomcat3.2.1/lib */
   
  -        protected boolean available() {
  -            return (sitemap != null);
  -        }
  -
  -        protected boolean hasChanged() {
  -            if (available()) {
  -                if (check_reload) {
  -                    this.source.refresh();
  -                    return sitemap.modifiedSince(this.source.getLastModified());
  -                }
  -                return false;
  -            }
  -            return true;
  -        }
  -
  -        protected boolean isRegenerating() {
  -            return isRegenerationRunning;
  -        }
  -
  -        protected void regenerateAsynchronously(Environment environment) throws Exception {
  -            if (this.sourceFileName.charAt(this.sourceFileName.length() - 1) == '/') {
  -                this.sourceFileName = this.sourceFileName + "sitemap.xmap";
  -            }
               try {
  -                environment.setURLResolver(new FactoryURLResolver(this.manager, this.urlFactory));
  -                this.source = environment.resolve(this.sourceFileName);
  -            } finally {
  -                environment.setURLResolver(null);
  +                regeneration.setContextClassLoader(Thread.currentThread().getContextClassLoader());
  +            } catch (Exception e) {
               }
  -            if (!this.isRegenerationRunning) {
  -                isRegenerationRunning = true;
  -                regeneration = new Thread(this);
  -
  -                /* HACK for reducing class loader problems. */
  -
  -                /* example: xalan extensions fail if someone adds xalan jars in tomcat3.2.1/lib */
  +            this.environment = environment;
   
  -                try {
  -                    regeneration.setContextClassLoader(Thread.currentThread().getContextClassLoader());
  -                } catch (Exception e) {
  -                }
  -                this.environment = environment;
  +            /* clear old exception if any */
   
  -                /* clear old exception if any */
  +            this.exception = null;
   
  -                this.exception = null;
  +            /* start the thread */
   
  -                /* start the thread */
  -
  -                regeneration.start();
  -            }
  +            regeneration.start();
           }
  +    }
   
  -        protected void regenerate(Environment environment) throws Exception {
  -            getLogger().debug("Beginning sitemap regeneration");
  -            this.regenerateAsynchronously(environment);
  -            if (regeneration != null) {
  -                this.regeneration.join();
  -            }
  -            throwEventualException();
  +    protected void regenerate(Environment environment) throws Exception {
  +        getLogger().debug("Beginning sitemap regeneration");
  +        this.regenerateAsynchronously(environment);
  +        if (regeneration != null) {
  +            this.regeneration.join();
           }
  +        throwEventualException();
  +    }
   
  -        public boolean process(Environment environment) throws Exception {
  -            checkSanity();
  -            try {
  -                environment.setURLResolver(this.urlResolver);
  -                return sitemap.process(environment);
  -            } finally {
  -                environment.setURLResolver(null);
  -            }
  +    public boolean process(Environment environment) throws Exception {
  +        checkSanity();
  +        try {
  +            environment.setSourceHandler(this.sourceHandler);
  +            return sitemap.process(environment);
  +        } finally {
  +            environment.setSourceHandler(null);
           }
  +    }
   
  -        public boolean process(Environment environment, StreamPipeline pipeline,
  -            EventPipeline eventPipeline) throws Exception {
  -                checkSanity();
  -                try {
  -                    environment.setURLResolver(this.urlResolver);
  -                    return sitemap.process(environment, pipeline, eventPipeline);
  -                } finally {
  -                    environment.setURLResolver(null);
  -                }
  +    public boolean process(Environment environment, StreamPipeline pipeline,
  +        EventPipeline eventPipeline) throws Exception {
  +        checkSanity();
  +        try {
  +            environment.setSourceHandler(this.sourceHandler);
  +            return sitemap.process(environment, pipeline, eventPipeline);
  +        } finally {
  +            environment.setSourceHandler(null);
           }
  +    }
   
  -        private void checkSanity() throws Exception {
  -            throwEventualException();
  -            if (sitemap == null) {
  -                getLogger().fatalError("Sitemap is not set for the Handler!!!!");
  -                throw new RuntimeException("The Sitemap is null, this should never be!");
  -            }
  +    private void checkSanity() throws Exception {
  +        throwEventualException();
  +        if (sitemap == null) {
  +            getLogger().fatalError("Sitemap is not set for the Handler!!!!");
  +            throw new RuntimeException("The Sitemap is null, this should never be!");
           }
  +    }
   
  -        public void setBasePath(String basePath) {
  -            this.basePath = basePath;
  -        }
  +    public void setBasePath(String basePath) {
  +        this.basePath = basePath;
  +    }
   
       /** Generate the Sitemap class */
  -        public void run() {
  -            Sitemap smap = null;
  -            String markupLanguage = "sitemap";
  -            String programmingLanguage = "java";
  -            ProgramGenerator programGenerator = null;
  +    public void run() {
  +        Sitemap smap = null;
  +        String markupLanguage = "sitemap";
  +        String programmingLanguage = "java";
  +        ProgramGenerator programGenerator = null;
  +        try {
  +            /* FIXME: Workaround -- set the logger XSLTFactoryLoader used to generate source
  +             * within the sitemap generation phase.
  +             * Needed because we never have the opportunity to handle the lifecycle of the
  +             * XSLTFactoryLoader, since it is created by the Xalan engine.
  +             */
  +
  +            XSLTFactoryLoader.setLogger(getLogger());
  +            programGenerator = (ProgramGenerator)this.manager.lookup(Roles.PROGRAM_GENERATOR);
               try {
  -                /* FIXME: Workaround -- set the logger XSLTFactoryLoader used to generate source
  -                * within the sitemap generation phase.
  -                * Needed because we never have the opportunity to handle the lifecycle of the
  -                * XSLTFactoryLoader, since it is created by the Xalan engine.
  -                */
  -
  -                XSLTFactoryLoader.setLogger(getLogger());
  -                programGenerator = (ProgramGenerator)this.manager.lookup(Roles.PROGRAM_GENERATOR);
  -                try {
  -                    environment.setURLResolver(new FactoryURLResolver(this.manager, this.urlFactory));
  -                    smap = (Sitemap)programGenerator.load(this.manager, this.sourceFileName, markupLanguage,
  -                        programmingLanguage, environment);
  -                } finally {
  -                    environment.setURLResolver(null);
  -                }
  -                if (this.sitemap != null) {
  -                    programGenerator.release((CompiledComponent)this.sitemap);
  -                }
  -                this.sitemap = smap;
  -                // create the urlResolver
  -                this.urlResolver = new SitemapURLResolver(this.sitemap.getComponentManager(),
  -                                                          this.urlFactory,
  -                                                          this.sitemap);
  -                getLogger().debug("Sitemap regeneration complete");
  -                if (this.sitemap != null) {
  -                    getLogger().debug("The sitemap has been successfully compiled!");
  -                } else {
  -                    getLogger().debug("No errors, but the sitemap has not been set.");
  -                }
  -            } catch (Throwable t) {
  -                getLogger().error("Error compiling sitemap", t);
  -                if (t instanceof Exception) {
  -                    this.exception = (Exception)t;
  -                }
  +                this.environment.setSourceHandler(this.sourceHandler);
  +                smap = (Sitemap)programGenerator.load(this.manager, this.sourceFileName, markupLanguage,
  +                    programmingLanguage, this.environment);
               } finally {
  -                if (programGenerator != null) {
  -                    this.manager.release(programGenerator);
  -                }
  -                this.regeneration = null;
  -                this.environment = null;
  -                this.isRegenerationRunning = false;
  +                this.environment.setSourceHandler(null);
               }
  -        }
  -
  -        public void throwEventualException() throws Exception {
  -            if (this.exception != null) {
  -                if(this.exception instanceof ProcessingException)
  -                    throw this.exception;
  -                else
  -                    throw new ProcessingException("Exception in Handler", this.exception);
  +            if (this.sitemap != null) {
  +                programGenerator.release((CompiledComponent)this.sitemap);
               }
  -        }
  -
  -        public Exception getException() {
  -            return this.exception;
  -        }
  +            this.sitemap = smap;
  +            // add the source factory for the cocoon protocol
  +            this.sourceHandler.addFactory("cocoon", new CocoonSourceFactory(this.sitemap,
  +                                                                            this.sitemap.getComponentManager()));
  +            getLogger().debug("Sitemap regeneration complete");
  +            if (this.sitemap != null) {
  +                getLogger().debug("The sitemap has been successfully compiled!");
  +            } else {
  +                getLogger().debug("No errors, but the sitemap has not been set.");
  +            }
  +        } catch (Throwable t) {
  +            getLogger().error("Error compiling sitemap", t);
  +            if (t instanceof Exception) {
  +                this.exception = (Exception)t;
  +            }
  +        } finally {
  +            if (programGenerator != null) {
  +                this.manager.release(programGenerator);
  +            }
  +            this.regeneration = null;
  +            this.environment = null;
  +            this.isRegenerationRunning = false;
  +        }
  +    }
  +
  +    public void throwEventualException() throws Exception {
  +        if (this.exception != null) {
  +            if(this.exception instanceof ProcessingException)
  +                throw this.exception;
  +            else
  +                throw new ProcessingException("Exception in Handler", this.exception);
  +       }
  +    }
  +
  +    public Exception getException() {
  +        return this.exception;
  +    }
   
       /**
        * dispose
        */
  -        public void dispose() {
  -            if (urlFactory != null) {
  -                manager.release((Component)urlFactory);
  -            }
  -            this.urlResolver = null;
  +    public void dispose() {
  +        if (this.sourceHandler != null) {
  +            manager.release((Component)this.sourceHandler);
  +            this.sourceHandler = null;
           }
  +    }
   }
  
  
  
  1.4       +1 -3      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Manager.java	2001/06/08 20:28:25	1.3
  +++ Manager.java	2001/07/04 07:57:33	1.4
  @@ -33,7 +33,7 @@
    * checking regeneration of the sub <code>Sitemap</code>
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/06/08 20:28:25 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/07/04 07:57:33 $
    */
   public class Manager extends AbstractLoggable implements Component, Configurable, Composable, Contextualizable, ThreadSafe {
       private Context context;
  @@ -161,10 +161,8 @@
                   }
               } else {
                   sitemapHandler = new Handler(source, check_reload);
  -                sitemapHandler.contextualize(this.context);
                   sitemapHandler.setLogger(getLogger());
                   sitemapHandler.compose(newManager);
  -                sitemapHandler.configure(this.conf);
                   sitemapHandler.regenerate(environment);
                   sitemaps.put(source, sitemapHandler);
               }
  
  
  
  1.13      +9 -0      xml-cocoon2/webapp/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/cocoon.xconf,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- cocoon.xconf	2001/06/21 19:28:59	1.12
  +++ cocoon.xconf	2001/07/04 07:57:42	1.13
  @@ -44,10 +44,19 @@
        <parameter name="threadpriority" value="5"/>
     </store>
   
  +  <!-- The url factory adds special url protocols to the system, they
  +       are then available inside Cocoon, e.g. as a source argument
  +       for one of the sitemap components -->
     <url-factory>
       <protocol name="resource" class="org.apache.cocoon.components.url.ResourceURLFactory"/>
       <protocol name="context"  class="org.apache.cocoon.components.url.ContextURLFactory"/>
     </url-factory>
  +
  +  <!-- The source handler adds special url protocols to the system, they
  +       are then available inside Cocoon, e.g. as a source argument
  +       for one of the sitemap components. -->
  +  <source-handler>
  +  </source-handler>
   
     <program-generator>
       <parameter name="auto-reload" value="true"/>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message