giacomo     01/02/14 03:40:02

  Modified:    src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        AbstractSitemap.java ComponentHolderFactory.java
                        DefaultComponentHolder.java Handler.java
                        PoolableComponentHolder.java
                        ThreadSafeComponentHolder.java
               src/org/apache/cocoon/components/classloader Tag:
                        xml-cocoon2 RepositoryClassLoader.java
               src/org/apache/cocoon/components/language/markup/sitemap/java
                        Tag: xml-cocoon2 sitemap.xsl
               src/org/apache/cocoon/components/url Tag: xml-cocoon2
                        URLFactoryImpl.java
               src/org/apache/cocoon/selection Tag: xml-cocoon2
                        CodedSelectorFactory.java
               src/org/apache/cocoon/util Tag: xml-cocoon2 ClassUtils.java
  Added:       src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        SitemapComponentManager.java
  Log:
  Now it is possible to user URLs to specify the classes that make up a sitemap 
component
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.19  +71 -18    
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/AbstractSitemap.java
  
  Index: AbstractSitemap.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/AbstractSitemap.java,v
  retrieving revision 1.1.2.18
  retrieving revision 1.1.2.19
  diff -u -r1.1.2.18 -r1.1.2.19
  --- AbstractSitemap.java      2001/01/22 21:56:48     1.1.2.18
  +++ AbstractSitemap.java      2001/02/14 11:39:10     1.1.2.19
  @@ -9,7 +9,10 @@
   
   import java.io.File;
   import java.io.IOException;
  +import java.io.InputStream;
   import java.io.OutputStream;
  +import java.net.URL;
  +import java.util.ArrayList;
   import java.util.List;
   import java.util.Map;
   
  @@ -18,16 +21,20 @@
   import org.apache.avalon.Composer;
   import org.apache.avalon.Configurable;
   import org.apache.avalon.Configuration;
  -import org.apache.avalon.DefaultComponentManager;
  +import org.apache.avalon.ConfigurationException;
   
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.Processor;
  +import org.apache.cocoon.Roles;
  +import org.apache.cocoon.components.url.URLFactory;
  +import org.apache.cocoon.components.classloader.RepositoryClassLoader;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.sitemap.ComponentHolderFactory;
  +import org.apache.cocoon.sitemap.SitemapComponentManager;
   import org.apache.cocoon.util.ClassUtils;
   
  -import org.apache.avalon.Loggable;
  -import org.apache.log.Logger;
  +import org.apache.avalon.AbstractLoggable;
  +//import org.apache.log.Logger;
   
   import org.xml.sax.SAXException;
   
  @@ -35,20 +42,24 @@
    * Base class for generated <code>Sitemap</code> classes
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.18 $ $Date: 2001/01/22 21:56:48 $
  + * @version CVS $Revision: 1.1.2.19 $ $Date: 2001/02/14 11:39:10 $
    */
  -public abstract class AbstractSitemap implements Sitemap, Loggable {
  -    protected Logger log;
  +public abstract class AbstractSitemap extends AbstractLoggable implements 
Sitemap {
   
  +    private static final int BYTE_ARRAY_SIZE = 1024;
  +
       /** The component manager instance */
       protected ComponentManager manager;
   
       /** The sitemap component manager instance */
  -    protected DefaultComponentManager sitemapComponentManager;
  +    protected SitemapComponentManager sitemapComponentManager;
   
       /** The sitemap manager instance */
       protected Manager sitemapManager;
   
  +    /** The URLFactory instance */
  +    protected URLFactory urlFactory;
  +
       /** The creation date */
       protected static long dateCreated = -1L;
   
  @@ -57,12 +68,11 @@
        * <code>Composer</code>.
        */
       public void setParentSitemapComponentManager(ComponentManager 
parentSitemapComponentManager) {
  -        this.sitemapComponentManager = new DefaultComponentManager 
(parentSitemapComponentManager);
  -    }
  -
  -    public void setLogger(Logger logger) {
  -        if (this.log == null) {
  -            this.log = logger;
  +        this.sitemapComponentManager = new SitemapComponentManager 
(parentSitemapComponentManager);
  +        try {
  +            
this.sitemapComponentManager.setURLFactory((URLFactory)manager.lookup(Roles.URL_FACTORY));
  +        } catch (Exception e) {
  +            getLogger().warn("cannot obtain URLFactory", e);
           }
       }
   
  @@ -75,6 +85,18 @@
       }
   
       /**
  +     * Configure this instance
  +     */
  +    public void configure(Configuration conf) throws ConfigurationException {
  +        try {
  +            this.urlFactory = (URLFactory)manager.lookup(Roles.URL_FACTORY);
  +        } catch (Exception e) {
  +            getLogger().error("cannot obtain the URLFactory", e);
  +            throw new ConfigurationException ("cannot obtain the 
URLFactory", e);
  +        }
  +    }
  +
  +    /**
        * Determines whether this generator's source files have changed
        *
        * @return Whether any of the files this sitemap depends on has changed
  @@ -101,18 +123,49 @@
         * Loads a class specified in a sitemap component definition and
         * initialize it
         */
  -    protected void load_component(String type, String classURL, 
Configuration configuration, String mime_type)
  +    public void load_component(String type, String classURL, Configuration 
configuration, String mime_type)
       throws Exception {
  -        if (!(ClassUtils.implementsInterface (classURL, 
Component.class.getName()))) {
  +        Class clazz;
  +        //FIXME(GP): Is it true that a class name containing a colon should 
be an URL?
  +        if (classURL.indexOf(':') > 1) {
  +            URL url = urlFactory.getURL(classURL);
  +            byte [] b = getByteArrayFromStream(url.openStream());
  +            clazz = 
((RepositoryClassLoader)ClassUtils.getClassLoader()).defineClass(b);
  +        } else {
  +            clazz = ClassUtils.loadClass(classURL);
  +        }
  +        if (!Component.class.isAssignableFrom(clazz)) {
               throw new IllegalAccessException ("Object " + classURL + " is 
not a Component");
           }
           this.sitemapComponentManager.put(
               type, ComponentHolderFactory.getComponentHolder(
  -                this.log, classURL, configuration, this.manager, mime_type
  +                getLogger(), clazz, configuration, this.manager, mime_type
               )
           );
       }
   
  +    private byte [] getByteArrayFromStream (InputStream stream) {
  +        List list = new ArrayList();
  +        byte [] b = new byte[BYTE_ARRAY_SIZE];
  +        int last = 0;
  +        try {
  +            while ((last = stream.read(b)) == BYTE_ARRAY_SIZE) {
  +                list.add(b);
  +                b = new byte[BYTE_ARRAY_SIZE];
  +            }
  +        } catch (IOException ioe) {
  +            getLogger().error ("cannot read class byte stream", ioe);
  +        }
  +        list.add(b);
  +        b = new byte [(list.size()-1) * BYTE_ARRAY_SIZE + last];
  +        int i;
  +        for (i = 0; i < list.size()-1; i++) {
  +            System.arraycopy(list.get(i), 0, b, i * BYTE_ARRAY_SIZE, 
BYTE_ARRAY_SIZE);
  +        }
  +        System.arraycopy(list.get(i), 0, b, i * BYTE_ARRAY_SIZE, last);
  +        return b;
  +    }
  +
        /**
         * Replaces occurences of xpath like expressions in an argument String
         * with content from a List of Maps
  @@ -148,7 +201,7 @@
                   } else {
                       
result.append((String)((Map)list.get(k)).get(s.substring(m+1)));
                   }
  -                log.debug("substitute evaluated value for " + (m == -1 ? s : 
s.substring(m+1))
  +                getLogger().debug("substitute evaluated value for " + (m == 
-1 ? s : s.substring(m+1))
                          + " as " + (String)((Map)list.get(k)).get(m == -1 ? s 
: s.substring(m+1)));
               }
               if (ii < expr.length()) {
  @@ -156,7 +209,7 @@
               }
               return (result.toString());
           } catch (Exception e) {
  -            log.error("AbstractSitemap:substitute()", e);
  +            getLogger().error("AbstractSitemap:substitute()", e);
               throw new PatternException
                       ("error occurred during evaluation of expression \""
                        +expr+"\" at position "+(i+1)+"\n"
  
  
  
  1.1.2.6   +11 -11    
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ComponentHolderFactory.java
  
  Index: ComponentHolderFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ComponentHolderFactory.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- ComponentHolderFactory.java       2001/01/22 21:56:48     1.1.2.5
  +++ ComponentHolderFactory.java       2001/02/14 11:39:11     1.1.2.6
  @@ -22,25 +22,25 @@
    * interfaces the passed component implements.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/01/22 21:56:48 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/02/14 11:39:11 $
    */
   public class ComponentHolderFactory {
   
  -    public static ComponentHolder getComponentHolder (Logger logger, String 
componentName, Configuration configuration, ComponentManager manager)
  +    public static ComponentHolder getComponentHolder (Logger logger, Class 
component, Configuration configuration, ComponentManager manager)
       throws Exception {
  -        return (getComponentHolder(logger, componentName, configuration, 
manager, null));
  +        return (getComponentHolder(logger, component, configuration, 
manager, null));
       }
   
  -    public static ComponentHolder getComponentHolder (Logger logger, String 
componentName, Configuration configuration, ComponentManager manager, String 
mime_type)
  +    public static ComponentHolder getComponentHolder (Logger logger, Class 
component, Configuration configuration, ComponentManager manager, String 
mime_type)
       throws Exception {
  -        if (ClassUtils.implementsInterface (componentName, 
Poolable.class.getName())) {
  -            return new PoolableComponentHolder (logger, componentName, 
configuration, manager, mime_type);
  -        } else if (ClassUtils.implementsInterface (componentName, 
SingleThreaded.class.getName())) {
  -            return new DefaultComponentHolder (logger, componentName, 
configuration, manager, mime_type);
  -        } else if (ClassUtils.implementsInterface (componentName, 
ThreadSafe.class.getName())) {
  -            return new ThreadSafeComponentHolder (logger, componentName, 
configuration, manager, mime_type);
  +        if (Poolable.class.isAssignableFrom(component)) {
  +            return new PoolableComponentHolder (logger, component, 
configuration, manager, mime_type);
  +        } else if (SingleThreaded.class.isAssignableFrom(component)) {
  +            return new DefaultComponentHolder (logger, component, 
configuration, manager, mime_type);
  +        } else if (ThreadSafe.class.isAssignableFrom(component)) {
  +            return new ThreadSafeComponentHolder (logger, component, 
configuration, manager, mime_type);
           } else  {
  -            return new DefaultComponentHolder (logger, componentName, 
configuration, manager, mime_type);
  +            return new DefaultComponentHolder (logger, component, 
configuration, manager, mime_type);
           }
       }
   }
  
  
  
  1.1.2.6   +6 -6      
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/DefaultComponentHolder.java
  
  Index: DefaultComponentHolder.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/DefaultComponentHolder.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- DefaultComponentHolder.java       2001/01/22 21:56:48     1.1.2.5
  +++ DefaultComponentHolder.java       2001/02/14 11:39:13     1.1.2.6
  @@ -24,12 +24,12 @@
    * a spezial behaviour or treatment.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/01/22 21:56:48 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/02/14 11:39:13 $
    */
   public class DefaultComponentHolder implements ComponentHolder {
       protected Logger log;
   
  -    protected String className;
  +    protected Class clazz;
       protected Configuration configuration;
       protected ComponentManager manager;
       protected String mime_type;
  @@ -39,9 +39,9 @@
        * @param configuration The </CODE>Configuration</CODE> for the component
        * @param manager A <CODE>ComponentManager</CODE> for the component
        */
  -    public DefaultComponentHolder(Logger log, String className, 
Configuration configuration, ComponentManager manager, String mime_type) {
  +    public DefaultComponentHolder(Logger log, Class clazz, Configuration 
configuration, ComponentManager manager, String mime_type) {
           this.log = log;
  -        this.className = className;
  +        this.clazz = clazz;
           this.configuration = configuration;
           this.manager = manager;
           this.mime_type = mime_type;
  @@ -51,7 +51,7 @@
        * @return A <CODE>Component</CODE>
        */
       public Component get() throws Exception {
  -        Component comp = (Component) ClassUtils.newInstance (this.className);
  +        Component comp = (Component) this.clazz.newInstance();
           if (comp instanceof Loggable) {
               ((Loggable) comp).setLogger(this.log);
           }
  @@ -77,7 +77,7 @@
        * @return The name of the class this Holder holds
        */
       public String getName() {
  -        return className;
  +        return clazz.getName();
       }
   
       /**
  
  
  
  1.1.2.13  +11 -18    
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Handler.java,v
  retrieving revision 1.1.2.12
  retrieving revision 1.1.2.13
  diff -u -r1.1.2.12 -r1.1.2.13
  --- Handler.java      2001/02/08 14:25:32     1.1.2.12
  +++ Handler.java      2001/02/14 11:39:14     1.1.2.13
  @@ -27,7 +27,7 @@
   import org.apache.avalon.Composer;
   import org.apache.avalon.ComponentManager;
   
  -import org.apache.log.Logger;
  +import org.apache.avalon.AbstractLoggable;
   import org.apache.avalon.Loggable;
   
   /**
  @@ -35,10 +35,9 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.12 $ $Date: 2001/02/08 14:25:32 $
  + * @version CVS $Revision: 1.1.2.13 $ $Date: 2001/02/14 11:39:14 $
    */
  -public class Handler implements Runnable, Configurable, Composer, Processor, 
Loggable {
  -    protected Logger log;
  +public class Handler extends AbstractLoggable implements Runnable, 
Configurable, Composer, Processor {
   
       /** the configuration */
       private Configuration conf;
  @@ -76,12 +75,6 @@
           this.conf = conf;
       }
   
  -    public void setLogger(Logger logger) {
  -        if (this.log == null) {
  -            this.log = logger;
  -        }
  -    }
  -
       protected Handler (ComponentManager sitemapComponentManager, String 
source, boolean check_reload)
       throws FileNotFoundException {
           this.parentSitemapComponentManager = sitemapComponentManager;
  @@ -131,7 +124,7 @@
   
       protected synchronized void regenerate (Environment environment)
       throws Exception {
  -        log.debug("Beginning sitemap regeneration");
  +        getLogger().debug("Beginning sitemap regeneration");
           regenerateAsynchronously(environment);
           if (regeneration != null)
               regeneration.join();
  @@ -141,7 +134,7 @@
       throws Exception {
           throwEventualException();
           if (sitemap == null) {
  -            log.fatalError("Sitemap is not set for the Handler!!!!");
  +            getLogger().fatalError("Sitemap is not set for the Handler!!!!");
               throw new RuntimeException("The Sitemap is null, this should 
never be!");
           }
           return sitemap.process(environment);
  @@ -165,21 +158,21 @@
           try {
               ProgramGenerator programGenerator = (ProgramGenerator) 
this.manager.lookup(Roles.PROGRAM_GENERATOR);
               smap = (Sitemap) programGenerator.load(file, markupLanguage, 
programmingLanguage, environment);
  -            smap.setParentSitemapComponentManager 
(this.parentSitemapComponentManager);
  -            if (smap instanceof Loggable) ((Loggable) 
smap).setLogger(this.log);
  +            if (smap instanceof Loggable) ((Loggable) 
smap).setLogger(getLogger());
               if (smap instanceof Composer) smap.compose(this.manager);
  +            smap.setParentSitemapComponentManager 
(this.parentSitemapComponentManager);
               if (smap instanceof Configurable) smap.configure(this.conf);
   
               this.sitemap = smap;
  -            log.debug("Sitemap regeneration complete");
  +            getLogger().debug("Sitemap regeneration complete");
   
               if (this.sitemap != null) {
  -                log.debug("The sitemap has been successfully compiled!");
  +                getLogger().debug("The sitemap has been successfully 
compiled!");
               } else {
  -                log.debug("No errors, but the sitemap has not been set.");
  +                getLogger().debug("No errors, but the sitemap has not been 
set.");
               }
           } catch (Throwable t) {
  -            log.error("Error compiling sitemap", t);
  +            getLogger().error("Error compiling sitemap", t);
   
               if (t instanceof Exception) {
                 this.exception = (Exception) t;
  
  
  
  1.1.2.6   +5 -10     
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/PoolableComponentHolder.java
  
  Index: PoolableComponentHolder.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/PoolableComponentHolder.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- PoolableComponentHolder.java      2001/01/22 21:56:49     1.1.2.5
  +++ PoolableComponentHolder.java      2001/02/14 11:39:16     1.1.2.6
  @@ -28,7 +28,7 @@
    * a spezial behaviour or treatment.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/01/22 21:56:49 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/02/14 11:39:16 $
    */
   public class PoolableComponentHolder extends DefaultComponentHolder 
implements ObjectFactory {
   
  @@ -49,15 +49,10 @@
        * @param configuration The </CODE>Configuration</CODE> for the component
        * @param manager A <CODE>ComponentManager</CODE> for the component
        */
  -    public PoolableComponentHolder(Logger log, String className, 
Configuration configuration, ComponentManager manager, String mime_type)
  +    public PoolableComponentHolder(Logger log, Class clazz, Configuration 
configuration, ComponentManager manager, String mime_type)
       throws Exception {
  -        super(log, className, configuration, manager, mime_type);
  -        try {
  -            this.clazz = ClassUtils.loadClass (super.className);
  -        } catch (Exception e) {
  -            log.debug("Class is null", e);
  -            this.clazz = null;
  -        }
  +        super(log, clazz, configuration, manager, mime_type);
  +        this.clazz = clazz;
           PoolController pc = (PoolController)super.manager.lookup 
(Roles.POOL_CONTROLLER);
           ComponentPool cp = new ComponentPool (this, pc, amount, 
DEFAULT_AMOUNT);
           cp.setLogger(this.log);
  @@ -86,7 +81,7 @@
        * @return The name of the class this Holder holds
        */
       public String getName() {
  -        return className;
  +        return clazz.getName();
       }
   
       /**
  
  
  
  1.1.2.4   +4 -4      
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ThreadSafeComponentHolder.java
  
  Index: ThreadSafeComponentHolder.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ThreadSafeComponentHolder.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- ThreadSafeComponentHolder.java    2001/01/22 21:56:49     1.1.2.3
  +++ ThreadSafeComponentHolder.java    2001/02/14 11:39:17     1.1.2.4
  @@ -21,7 +21,7 @@
    * This class holds a sitemap component which is specially marked as beeing 
thread safe
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2001/01/22 21:56:49 $
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/02/14 11:39:17 $
    */
   public class ThreadSafeComponentHolder extends DefaultComponentHolder {
   
  @@ -32,9 +32,9 @@
        * @param configuration The </CODE>Configuration</CODE> for the component
        * @param manager A <CODE>ComponentManager</CODE> for the component
        */
  -    public ThreadSafeComponentHolder(Logger log, String className, 
Configuration configuration, ComponentManager manager, String mime_type)
  +    public ThreadSafeComponentHolder(Logger log, Class clazz, Configuration 
configuration, ComponentManager manager, String mime_type)
       throws Exception {
  -        super(log, className, configuration, manager, mime_type);
  +        super(log, clazz, configuration, manager, mime_type);
           this.comp = super.get();
       }
   
  @@ -58,6 +58,6 @@
        * @return The name of the class this Holder holds
        */
       public String getName() {
  -        return className;
  +        return this.comp.getClass().getName();
       }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +41 -0     
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapComponentManager.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.21  +8 -1      
xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/RepositoryClassLoader.java
  
  Index: RepositoryClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/RepositoryClassLoader.java,v
  retrieving revision 1.1.2.20
  retrieving revision 1.1.2.21
  diff -u -r1.1.2.20 -r1.1.2.21
  --- RepositoryClassLoader.java        2001/02/09 04:19:26     1.1.2.20
  +++ RepositoryClassLoader.java        2001/02/14 11:39:34     1.1.2.21
  @@ -34,7 +34,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1.2.20 $ $Date: 2001/02/09 04:19:26 $
  + * @version CVS $Revision: 1.1.2.21 $ $Date: 2001/02/14 11:39:34 $
    */
   public class RepositoryClassLoader extends URLClassLoader implements 
Loggable {
   
  @@ -103,5 +103,12 @@
             log.error("The repository had a bad URL", mue);
             throw new IOException("Could not add repository");
         }
  +  }
  +
  +  /**
  +   * Create a Class from a byte array
  +   */
  +  public Class defineClass(byte [] b) throws ClassFormatError {
  +      return super.defineClass(null, b, 0, b.length);
     }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.75  +103 -41   
xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
  
  Index: sitemap.xsl
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
  retrieving revision 1.1.2.74
  retrieving revision 1.1.2.75
  diff -u -r1.1.2.74 -r1.1.2.75
  --- sitemap.xsl       2001/02/05 16:23:06     1.1.2.74
  +++ sitemap.xsl       2001/02/14 11:39:39     1.1.2.75
  @@ -18,18 +18,34 @@
   
     <xsl:output method="text"/>
   
  -  <xsl:variable name="prefix">map</xsl:variable>
   
  +  <!-- FIXME(GP): This global variable is used to match the attributes 
map:value
  +                  and map:param. I'm sure there is a way around it but 
haven't
  +                  investigated yet.
  +  -->
  +  <xsl:variable name="nsprefix">map</xsl:variable>
  +
  +
     <!-- this variable holds the factory loader used to get at the code 
matcher/selector factories
  -       are producing -->
  +       are producing
  +       FIXME(GP): This approach seem Xalan dependant and not (yet) portable
  +  -->
     <xsl:variable name="factory-loader" 
select="java:org.apache.cocoon.sitemap.XSLTFactoryLoader.new()"/>
   
  +
  +  <!-- this template wraps the hole content within a single <code> element 
which
  +       the xsp core logicsheet uses to build the java source code out of it
  +  -->
     <xsl:template match="/">
       <code xml:space="preserve">
         <xsl:apply-templates/>
       </code>
     </xsl:template>
   
  +
  +  <!-- This is the root element we are looking for here. It defines all the 
java
  +       code necessary to build up a sitemap engine class
  +  -->
     <xsl:template match="map:sitemap">
       
/*****************************************************************************/
       /* Copyright (C) The Apache Software Foundation. All rights reserved.    
    */
  @@ -77,9 +93,9 @@
       /**
        * This is the automatically generated class from the sitemap definitions
        *
  -     * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Giacomo 
Pati&lt;/a&gt;
  +     * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Giacomo 
Pati&lt;/a&gt;
        * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Berin 
Loritsch&lt;/a&gt;
  -     * @version CVS $Revision: 1.1.2.74 $ $Date: 2001/02/05 16:23:06 $
  +     * @version CVS $Id: sitemap.xsl,v 1.1.2.75 2001/02/14 11:39:39 giacomo 
Exp $
        */
       public class <xsl:value-of select="@file-name"/> extends AbstractSitemap 
{
         static final String LOCATION = "<xsl:value-of 
select="translate(@file-path, '/', '.')"/>.<xsl:value-of select="@file-name"/>";
  @@ -91,7 +107,12 @@
         /** An empty &lt;code&gt;Parameter&lt;/code&gt; used to pass to the 
sitemap components */
         private Parameters emptyParam = new Parameters();
   
  -      <!-- Generate matchers which implements CodeFactory -->
  +
  +      <!-- Generate matchers which implements CodeFactory
  +           FIXME(GP): We should get rid of the additional factory attribute 
in the sitemap
  +                      schema definition because this stylesheet is able to 
determine that
  +                      based on the fact that a Matcher implements the 
CodeFactory interface
  +      -->
         <xsl:for-each 
select="/map:sitemap/map:components/map:matchers/map:matcher">
           <xsl:variable name="src">
             <xsl:choose>
  @@ -123,8 +144,13 @@
             </xsl:for-each>
           </xsl:if>
         </xsl:for-each>
  +
   
  -      <!-- Generate selectors which implements CodeFactory -->
  +      <!-- Generate selectors which implements CodeFactory
  +           FIXME(GP): We should get rid of the additional factory attribute 
in the sitemap
  +                      schema definition because this stylesheet is able to 
determine that
  +                      based on the fact that a Selector implements the 
CodeFactory interface
  +      -->
         <xsl:for-each 
select="/map:sitemap/map:components/map:selectors/map:selector">
           <xsl:variable name="src">
             <xsl:choose>
  @@ -165,67 +191,103 @@
          * &lt;code&gt;Configurable&lt;/code&gt; class.
          */
         public void configure(Configuration conf) throws 
ConfigurationException {
  +        super.configure(conf);
           this.sitemapManager = new Manager(super.sitemapComponentManager);
           this.sitemapManager.compose(this.manager);
           this.sitemapManager.configure(conf);
           try {
  -          <!-- configure all components -->
  +          <!-- configure well known components first -->
             load_component ("!generator:error-notifier!", 
"org.apache.cocoon.sitemap.ErrorNotifier", new DefaultConfiguration("", 
LOCATION), null);
             load_component ("!transformer:link-translator!", 
"org.apache.cocoon.sitemap.LinkTranslator", new DefaultConfiguration("", 
LOCATION), null);
  +
  +          Configurer configurer = new Configurer(this, LOCATION);
  +          configurer.configGenerators();
  +          configurer.configTransformers();
  +          configurer.configReaders();
  +          configurer.configSerializers();
  +          configurer.configMatchers();
  +          configurer.configSelectors();
  +          configurer.configActions();
  +
  +        /* catch any exception thrown by a component during configuration */
  +        } catch (Exception e) {
  +          getLogger().warn(e.getMessage(), e);
  +          throw new ConfigurationException ("Sitemap: " + e.getMessage(), e);
  +        }
  +      }
   
  -          <!-- Configure generators -->
  -      <xsl:call-template name="config-components">
  +      <!-- This class handles all component configuration. Because this is 
done once
  +          at instantiation time we can get rid of this code afterwards.
  +      -->
  +      class Configurer {
  +        <xsl:value-of select="@file-name"/> sitemap;
  +        String LOCATION;
  +        public Configurer (<xsl:value-of select="@file-name"/> sitemap, 
String location) {
  +          this.sitemap = sitemap;
  +          this.LOCATION = location;
  +        }
  +
  +        /** Configure generators */
  +        public void configGenerators() throws Exception {
  +          <xsl:call-template name="config-components">
               <xsl:with-param name="name">generator</xsl:with-param>
               <xsl:with-param name="components"
                   
select="/map:sitemap/map:components/map:generators/map:generator"/>
             </xsl:call-template>
  +        }
   
  -          <!-- Configure transformers -->
  +        /** Configure transformers */
  +        public void configTransformers() throws Exception {
             <xsl:call-template name="config-components">
               <xsl:with-param name="name">transformer</xsl:with-param>
               <xsl:with-param name="components"
                   
select="/map:sitemap/map:components/map:transformers/map:transformer"/>
             </xsl:call-template>
  +        }
   
  -          <!-- Configure readers -->
  +        /** Configure readers */
  +        public void configReaders() throws Exception {
             <xsl:call-template name="config-components">
               <xsl:with-param name="name">reader</xsl:with-param>
               <xsl:with-param name="components"
                   select="/map:sitemap/map:components/map:readers/map:reader"/>
             </xsl:call-template>
  +        }
   
  -          <!-- Configure serializers -->
  +        /* Configure serializers */
  +        public void configSerializers() throws Exception {
             <xsl:call-template name="config-components">
               <xsl:with-param name="name">serializer</xsl:with-param>
               <xsl:with-param name="components"
                   
select="/map:sitemap/map:components/map:serializers/map:serializer"/>
             </xsl:call-template>
  +        }
   
  -          <!-- Configure matchers -->
  +        /** Configure matchers */
  +        public void configMatchers() throws Exception {
             <xsl:call-template name="config-components">
               <xsl:with-param name="name">matcher</xsl:with-param>
               <xsl:with-param name="components"
                   
select="/map:sitemap/map:components/map:matchers/map:matcher"/>
             </xsl:call-template>
  +        }
   
  -          <!-- Configure selectors -->
  +        /** Configure selectors */
  +        public void configSelectors() throws Exception {
             <xsl:call-template name="config-components">
               <xsl:with-param name="name">selector</xsl:with-param>
               <xsl:with-param name="components"
                   
select="/map:sitemap/map:components/map:selectors/map:selector"/>
             </xsl:call-template>
  +        }
   
  -          <!-- Configure actions -->
  +        /** Configure actions */
  +        public void configActions() throws Exception {
             <xsl:call-template name="config-components">
               <xsl:with-param name="name">action</xsl:with-param>
               <xsl:with-param name="components"
                   select="/map:sitemap/map:components/map:actions/map:action"/>
             </xsl:call-template>
  -
  -        /* catch any exception thrown by a component during configuration */
  -        } catch (Exception e) {
  -          log.warn(e.getMessage(), e);
  -          throw new ConfigurationException ("Sitemap: " + e.getMessage(), e);
           }
         }
   
  @@ -331,20 +393,20 @@
             try {
               <xsl:apply-templates select="./*"/>
             } catch (ResourceNotFoundException rse) {
  -            log.warn("404 Resource Not Found", rse);
  +            getLogger().warn("404 Resource Not Found", rse);
               throw rse;
             } catch (Exception e) {
  -            log.warn("Error, try to process the error page", e);
  +            getLogger().warn("Error, try to process the error page", e);
               <xsl:choose>
                 <xsl:when test="(./map:handle-errors)">
                   try {
                     return error_process_<xsl:value-of 
select="$pipeline-position"/> (environment, objectModel, e);
                   } catch (Exception ex) {
  -                  log.warn("Sitemap Error Process", ex);
  +                  getLogger().warn("Sitemap Error Process", ex);
                   }
                 </xsl:when>
                 <xsl:otherwise>
  -                log.error("Sitemap", e);
  +                getLogger().error("Sitemap", e);
                 </xsl:otherwise>
               </xsl:choose>
             }
  @@ -435,7 +497,7 @@
       <!-- this is the actual code produced -->
       if ((map = <xsl:value-of select="translate($matcher-type, '- ', 
'__')"/>Match(<xsl:value-of select="$matcher-name"/>_expr,
             objectModel)) != null) {
  -      log.debug("Matched <xsl:value-of select="$matcher-name"/>");
  +      getLogger().debug("Matched <xsl:value-of select="$matcher-name"/>");
         listOfMaps.add (map);
         <xsl:apply-templates/>
         listOfMaps.remove (listOfMaps.size()-1);
  @@ -510,7 +572,7 @@
           else
         </xsl:if>
         if (<xsl:value-of select="translate($selector-type, '- ', 
'__')"/>Select (<xsl:value-of select="$selector-name"/>_expr, objectModel)) {
  -       log.debug("Select <xsl:value-of select="$selector-name"/>");
  +       getLogger().debug("Select <xsl:value-of select="$selector-name"/>");
          <xsl:apply-templates/>
         }
       </xsl:for-each>
  @@ -518,7 +580,7 @@
       <!-- this is the actual code produced on the otherwise element -->
       <xsl:for-each select="./map:otherwise">
         else {
  -        log.debug("Select Otherwise");
  +        getLogger().debug("Select Otherwise");
         <xsl:apply-templates/>
         }
       </xsl:for-each>
  @@ -572,7 +634,7 @@
       <xsl:choose>
         <xsl:when 
test="./*[namespace-uri()='http://apache.org/cocoon/sitemap/1.0']">
           if ((map = <xsl:value-of select="$action-name"/> (environment, 
objectModel, substitute(listOfMaps,<xsl:value-of select="$action-source"/>), 
<xsl:value-of select="$component-param"/>)) != null) {
  -         log.debug("Action <xsl:value-of 
select="translate($action-name,'&quot;',' ')"/>");
  +         getLogger().debug("Action <xsl:value-of 
select="translate($action-name,'&quot;',' ')"/>");
             listOfMaps.add (map);
             <xsl:apply-templates/>
             listOfMaps.remove(listOfMaps.size()-1);
  @@ -632,7 +694,7 @@
       <xsl:choose>
         <xsl:when 
test="./*[namespace-uri()='http://apache.org/cocoon/sitemap/1.0']">
           if ((map = <xsl:value-of select="$action-name"/> (environment, 
objectModel, substitute(listOfMaps,<xsl:value-of select="$action-source"/>), 
<xsl:value-of select="$component-param"/>)) != null) {
  -         log.debug("Action <xsl:value-of 
select="translate($action-name,'&quot;',' ')"/>");
  +         getLogger().debug("Action <xsl:value-of 
select="translate($action-name,'&quot;',' ')"/>");
             listOfMaps.add (map);
             <xsl:apply-templates/>
             listOfMaps.remove(listOfMaps.size()-1);
  @@ -692,7 +754,7 @@
       <xsl:choose>
         <xsl:when 
test="./*[namespace-uri()='http://apache.org/cocoon/sitemap/1.0']">
           if ((map = <xsl:value-of select="$action-name"/> (cocoon_action, 
listOfMaps, environment, objectModel, substitute(listOfMaps,<xsl:value-of 
select="$action-source"/>), <xsl:value-of select="$component-param"/>)) != 
null) {
  -         log.debug("Action <xsl:value-of 
select="translate($action-name,'&quot;',' ')"/>");
  +         getLogger().debug("Action <xsl:value-of 
select="translate($action-name,'&quot;',' ')"/>");
             listOfMaps.add (map);
             <xsl:apply-templates/>
             listOfMaps.remove(listOfMaps.size()-1);
  @@ -805,7 +867,7 @@
   
         <!-- redirect to a external resource definition. Let the environment 
do the redirect -->
         <xsl:when test="@uri">
  -        log.debug("Redirecting to '<xsl:value-of select="@uri"/>'");
  +        getLogger().debug("Redirecting to '<xsl:value-of select="@uri"/>'");
           environment.redirect (substitute(listOfMaps, "<xsl:value-of 
select="@uri"/>"));
           if(true)return true;
         </xsl:when>
  @@ -844,7 +906,7 @@
       <xsl:param name="components"/>
   
       <xsl:variable name="qname">
  -      <xsl:value-of select="concat($prefix, ':value')"/>
  +      <xsl:value-of select="concat($nsprefix, ':value')"/>
       </xsl:variable>
   
       <xsl:variable name="ns" select="namespace-uri(.)"/>
  @@ -871,10 +933,10 @@
   
           <xsl:choose>
             <xsl:when test="@mime-type">
  -            load_component ("<xsl:value-of select="$name"/>:<xsl:value-of 
select="@name"/>", "<xsl:value-of select="@src"/>", cconf1, "<xsl:value-of 
select="@mime-type"/>");
  +            sitemap.load_component ("<xsl:value-of 
select="$name"/>:<xsl:value-of select="@name"/>", "<xsl:value-of 
select="@src"/>", cconf1, "<xsl:value-of select="@mime-type"/>");
             </xsl:when>
             <xsl:otherwise>
  -            load_component ("<xsl:value-of select="$name"/>:<xsl:value-of 
select="@name"/>", "<xsl:value-of select="@src"/>", cconf1, null);
  +            sitemap.load_component ("<xsl:value-of 
select="$name"/>:<xsl:value-of select="@name"/>", "<xsl:value-of 
select="@src"/>", cconf1, null);
             </xsl:otherwise>
           </xsl:choose>
       }
  @@ -893,7 +955,7 @@
       <xsl:param name="level"/>
   
       <xsl:variable name="qname">
  -      <xsl:value-of select="concat($prefix, ':value')"/>
  +      <xsl:value-of select="concat($nsprefix, ':value')"/>
       </xsl:variable>
   
       <!-- process content -->
  @@ -942,7 +1004,7 @@
         <xsl:if test="$prefix='serializer'">
           <xsl:for-each select="/map:sitemap/map:views/map:[EMAIL 
PROTECTED]'last']">
             if ("<xsl:value-of select="@name"/>".equals(cocoon_view)) {
  -            log.debug("View <xsl:value-of select="@name"/>");
  +            getLogger().debug("View <xsl:value-of select="@name"/>");
               return view_<xsl:value-of select="translate(@name, '- ', 
'__')"/> (pipeline, listOfMaps, environment);
             }
           </xsl:for-each>
  @@ -989,13 +1051,13 @@
       <!-- collect the parameters -->
       <xsl:apply-templates select="parameter"/>
   
  -    log.debug("Component <xsl:value-of select="$prefix"/>:<xsl:value-of 
select="$component-type"/>(<xsl:value-of select="$component-param"/>)");
  +    getLogger().debug("Component <xsl:value-of 
select="$prefix"/>:<xsl:value-of select="$component-type"/>(<xsl:value-of 
select="$component-param"/>)");
       <!-- determine the right invokation according to "has a src attribute" 
and "has a mime-type attribute" -->
       <xsl:choose>
         <xsl:when test="$component-source='null'">
           <xsl:choose>
             <xsl:when test="$mime-type!=''">
  -            log.debug("Mime-type: <xsl:value-of select="$mime-type"/>");
  +            getLogger().debug("Mime-type: <xsl:value-of 
select="$mime-type"/>");
               pipeline.<xsl:value-of select="$method"/> ("<xsl:value-of 
select="$prefix"/>:<xsl:value-of select="$component-type"/>",
                 null, <xsl:value-of select="$component-param"/>,"<xsl:value-of 
select="$mime-type"/>"
               );
  @@ -1008,10 +1070,10 @@
           </xsl:choose>
         </xsl:when>
         <xsl:otherwise>
  -        log.debug("Source=<xsl:value-of select="$component-source"/>");
  +        getLogger().debug("Source=<xsl:value-of 
select="$component-source"/>");
           <xsl:choose>
             <xsl:when test="$mime-type!=''">
  -            log.debug("Mime-type: <xsl:value-of select="$mime-type"/>");
  +            getLogger().debug("Mime-type: <xsl:value-of 
select="$mime-type"/>");
               pipeline.<xsl:value-of select="$method"/> ("<xsl:value-of 
select="$prefix"/>:<xsl:value-of select="$component-type"/>",
                   substitute(listOfMaps,"<xsl:value-of 
select="$component-source"/>"),
                   <xsl:value-of select="$component-param"/>,"<xsl:value-of 
select="$mime-type"/>");
  @@ -1090,7 +1152,7 @@
       <xsl:param name="required">false</xsl:param>
   
       <xsl:variable name="qname">
  -      <xsl:value-of select="concat($prefix, ':param')"/>
  +      <xsl:value-of select="concat($nsprefix, ':param')"/>
       </xsl:variable>
   
       <xsl:choose>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +2 -1      
xml-cocoon/src/org/apache/cocoon/components/url/Attic/URLFactoryImpl.java
  
  Index: URLFactoryImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/url/Attic/URLFactoryImpl.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- URLFactoryImpl.java       2001/02/12 13:50:23     1.1.2.2
  +++ URLFactoryImpl.java       2001/02/14 11:39:45     1.1.2.3
  @@ -29,7 +29,7 @@
   
   /**
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version $Id: URLFactoryImpl.java,v 1.1.2.2 2001/02/12 13:50:23 bloritsch 
Exp $
  + * @version $Id: URLFactoryImpl.java,v 1.1.2.3 2001/02/14 11:39:45 giacomo 
Exp $
    */
   public class URLFactoryImpl extends AbstractLoggable implements URLFactory, 
Component, Configurable, Contextualizable {
   
  @@ -61,6 +61,7 @@
               }
           }
           try {
  +            getLogger().debug("Making URL from " + location);
               return new URL(location);
           } catch (MalformedURLException mue) {
               getLogger().debug("Making URL a File relative to context root", 
mue);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.7   +2 -2      
xml-cocoon/src/org/apache/cocoon/selection/Attic/CodedSelectorFactory.java
  
  Index: CodedSelectorFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/CodedSelectorFactory.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- CodedSelectorFactory.java 2001/01/31 15:48:38     1.1.2.6
  +++ CodedSelectorFactory.java 2001/02/14 11:39:50     1.1.2.7
  @@ -18,7 +18,7 @@
    * embedded java code within the 'test' clause of the select.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
  - * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/01/31 15:48:38 $
  + * @version CVS $Revision: 1.1.2.7 $ $Date: 2001/02/14 11:39:50 $
    */
   public class CodedSelectorFactory extends java.lang.Object
           implements CodeFactory {
  @@ -52,7 +52,7 @@
           sb.append( "try {" )
             .append("return pattern.evaluate(objectModel);" )
             .append("} catch (Exception e) {" )
  -          .append("log.error(\"CodedSelector Exception : \" + e.getMessage() 
+ \", returning false\");" )
  +          .append("getLogger().error(\"CodedSelector Exception : \" + 
e.getMessage() + \", returning false\");" )
             .append( "return false;" )
             .append( "}" );
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.11  +2 -5      
xml-cocoon/src/org/apache/cocoon/util/Attic/ClassUtils.java
  
  Index: ClassUtils.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/ClassUtils.java,v
  retrieving revision 1.1.2.10
  retrieving revision 1.1.2.11
  diff -u -r1.1.2.10 -r1.1.2.11
  --- ClassUtils.java   2001/01/30 17:25:41     1.1.2.10
  +++ ClassUtils.java   2001/02/14 11:39:56     1.1.2.11
  @@ -21,7 +21,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/01/30 17:25:41 $
  + * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/02/14 11:39:56 $
    */
   public class ClassUtils {
   
  @@ -144,10 +144,7 @@
        * @return true if class implements given interface.
        */
       public static boolean implementsInterface(Class class1, Class iface) {
  -        if (iface.isAssignableFrom (class1)) {
  -            return true;
  -        }
  -        return false;
  +        return iface.isAssignableFrom (class1);
       }
   
       /**
  
  
  

Reply via email to