cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/util ClassUtils.java IOUtils.java
Date Wed, 06 Sep 2000 23:22:27 GMT
stefano     00/09/06 16:22:27

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2 Cocoon.java
               src/org/apache/cocoon/components/classloader Tag:
                        xml-cocoon2 RepositoryClassLoader.java
               src/org/apache/cocoon/components/language/programming Tag:
                        xml-cocoon2 AbstractProgrammingLanguage.java
                        CompiledProgrammingLanguage.java
               src/org/apache/cocoon/components/language/programming/java
                        Tag: xml-cocoon2 JavaLanguage.java
               src/org/apache/cocoon/matching Tag: xml-cocoon2
                        MatcherFactory.java
               src/org/apache/cocoon/selection Tag: xml-cocoon2
                        SelectorFactory.java
               src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        AbstractSitemap.java XSLTFactoryLoader.java
               src/org/apache/cocoon/transformation Tag: xml-cocoon2
                        SQLTransformer.java
               src/org/apache/cocoon/util Tag: xml-cocoon2 ClassUtils.java
                        IOUtils.java
  Added:       src/org/apache/cocoon Tag: xml-cocoon2 CodeFactory.java
  Log:
  centralized all class/classloading calls to the ClassUtils static methods for easier management
(sheesh, classloaders are nasty babies)
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.24  +3 -3      xml-cocoon/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.4.2.23
  retrieving revision 1.4.2.24
  diff -u -r1.4.2.23 -r1.4.2.24
  --- Cocoon.java	2000/09/03 13:45:05	1.4.2.23
  +++ Cocoon.java	2000/09/06 23:22:21	1.4.2.24
  @@ -41,7 +41,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.4.2.23 $ $Date: 2000/09/03 13:45:05 $
  + * @version CVS $Revision: 1.4.2.24 $ $Date: 2000/09/06 23:22:21 $
    */
   public class Cocoon
     implements Component, Configurable, ComponentManager, Modifiable, Processor, Constants
{
  @@ -75,7 +75,7 @@
           // If one need to use a different parser, set the given system property
           String parser = System.getProperty(PARSER_PROPERTY, DEFAULT_PARSER);
           try {
  -            this.components.put("parser", ClassUtils.getClass(parser));
  +            this.components.put("parser", ClassUtils.loadClass(parser));
           } catch (Exception e) {
               throw new ConfigurationException("Error creating parser (" + parser + ")",
null);
           }
  @@ -145,7 +145,7 @@
               String role = co.getAttribute("role");
               String className = co.getAttribute("class");
               try {
  -                this.components.put(role, ClassUtils.getClass(className));
  +                this.components.put(role, ClassUtils.loadClass(className));
                   this.configurations.put(role, co);
               } catch (Exception ex) {
                   // if the component is not found, there is no need to stop at this point.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +33 -0     xml-cocoon/src/org/apache/cocoon/Attic/CodeFactory.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +3 -3      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.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- RepositoryClassLoader.java	2000/07/29 18:30:26	1.1.2.3
  +++ RepositoryClassLoader.java	2000/09/06 23:22:22	1.1.2.4
  @@ -15,12 +15,13 @@
   import java.io.IOException;
   
   import org.apache.cocoon.util.IOUtils;
  +import org.apache.cocoon.util.ClassUtils;
   
   /**
    * A class loader with a growable list of path search directories
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:26 $
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/09/06 23:22:22 $
    */
   class RepositoryClassLoader extends ClassLoader {
     /**
  @@ -102,8 +103,7 @@
           byte[] bits = this.loadClassData (name);
   
           if (bits == null) {
  -          // ClassLoader cl = getParent();
  -          ClassLoader cl = this.getClass().getClassLoader();
  +          ClassLoader cl = ClassUtils.getClassLoader();
   
             if (cl != null)  {
               c = cl.loadClass (name);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +3 -3      xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/AbstractProgrammingLanguage.java
  
  Index: AbstractProgrammingLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/AbstractProgrammingLanguage.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- AbstractProgrammingLanguage.java	2000/07/29 18:30:30	1.1.2.4
  +++ AbstractProgrammingLanguage.java	2000/09/06 23:22:22	1.1.2.5
  @@ -16,6 +16,7 @@
   import org.apache.avalon.utils.Parameters;
   import org.apache.avalon.AbstractNamedComponent;
   
  +import org.apache.cocoon.util.ClassUtils;
   import org.apache.cocoon.components.language.LanguageException;
   
   /**
  @@ -24,7 +25,7 @@
    * unloading.
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:30 $
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/09/06 23:22:22 $
    */
   public abstract class AbstractProgrammingLanguage
     extends AbstractNamedComponent
  @@ -45,8 +46,7 @@
       try {
         String className = params.getParameter("code-formatter", null);
         if (className != null) {
  -        this.codeFormatter =
  -	  this.getClass().getClassLoader().loadClass(className);
  +        this.codeFormatter = ClassUtils.loadClass(className);
         }
       } catch (Exception e) { }
     }
  
  
  
  1.1.2.6   +3 -3      xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompiledProgrammingLanguage.java
  
  Index: CompiledProgrammingLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompiledProgrammingLanguage.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- CompiledProgrammingLanguage.java	2000/07/29 18:30:30	1.1.2.5
  +++ CompiledProgrammingLanguage.java	2000/09/06 23:22:23	1.1.2.6
  @@ -15,6 +15,7 @@
   import org.apache.avalon.Component;
   import org.apache.avalon.ComponentManager;
   
  +import org.apache.cocoon.util.ClassUtils;
   import org.apache.cocoon.components.language.LanguageException;
   
   /**
  @@ -23,7 +24,7 @@
    * and object program files
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/29 18:30:30 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/09/06 23:22:23 $
    */
   public abstract class CompiledProgrammingLanguage
     extends AbstractProgrammingLanguage
  @@ -55,8 +56,7 @@
   	this.getName() + "'"
         );
       }
  -    this.compilerClass =
  -      this.getClass().getClassLoader().loadClass(compilerClass);
  +    this.compilerClass = ClassUtils.loadClass(compilerClass);
   
       this.deleteSources = params.getParameterAsBoolean("delete-sources", false);
     }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +3 -5      xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JavaLanguage.java
  
  Index: JavaLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JavaLanguage.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- JavaLanguage.java	2000/08/21 17:41:46	1.1.2.5
  +++ JavaLanguage.java	2000/09/06 23:22:23	1.1.2.6
  @@ -18,17 +18,16 @@
   import org.apache.avalon.Component;
   import org.apache.avalon.ComponentManager;
   
  +import org.apache.cocoon.util.ClassUtils;
   import org.apache.cocoon.components.classloader.ClassLoaderManager;
  -
   import org.apache.cocoon.components.language.programming.*;
  -
   import org.apache.cocoon.components.language.LanguageException;
   
   /**
    * The Java programming language processor
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/08/21 17:41:46 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/09/06 23:22:23 $
    */
   public class JavaLanguage extends CompiledProgrammingLanguage {
       
  @@ -74,8 +73,7 @@
   
       String compilerClass = params.getParameter("class-loader", null);
       if (compilerClass != null) {
  -      this.classLoaderManager = (ClassLoaderManager)
  -        this.getClass().getClassLoader().loadClass(compilerClass).newInstance();
  +      this.classLoaderManager = (ClassLoaderManager) ClassUtils.newInstance(compilerClass);
       }
     }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +6 -11     xml-cocoon/src/org/apache/cocoon/matching/Attic/MatcherFactory.java
  
  Index: MatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/MatcherFactory.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- MatcherFactory.java	2000/07/27 21:49:02	1.1.2.5
  +++ MatcherFactory.java	2000/09/06 23:22:24	1.1.2.6
  @@ -4,12 +4,11 @@
    * This software is published under the terms of the Apache Software License * 
    * version 1.1, a copy of which has been included  with this distribution in * 
    * the LICENSE file.                                                         * 
  - *****************************************************************************/ 
  + *****************************************************************************/
  +  
   package org.apache.cocoon.matching; 
   
  -import org.apache.avalon.ConfigurationException;
  -
  -import org.w3c.dom.DocumentFragment;
  +import org.apache.cocoon.CodeFactory;
    
   /** 
    * Interface a class has to implement that produces java source code 
  @@ -20,13 +19,9 @@
    * sitemap code generation.
    * 
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/27 21:49:02 $ 
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/09/06 23:22:24 $ 
    */ 
  -
  -public interface MatcherFactory {
  -    public String generateClassSource (String prefix, String pattern, DocumentFragment
conf) 
  -    throws ConfigurationException;
   
  -    public String generateMethodSource (String prefix, String pattern, DocumentFragment
conf)
  -    throws ConfigurationException;
  +public interface MatcherFactory extends CodeFactory {
  +    
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +3 -10     xml-cocoon/src/org/apache/cocoon/selection/Attic/SelectorFactory.java
  
  Index: SelectorFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/SelectorFactory.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- SelectorFactory.java	2000/07/27 21:49:04	1.1.2.5
  +++ SelectorFactory.java	2000/09/06 23:22:24	1.1.2.6
  @@ -7,10 +7,8 @@
    *****************************************************************************/ 
   package org.apache.cocoon.selection; 
   
  -import org.apache.avalon.ConfigurationException;
  +import org.apache.cocoon.CodeFactory;
   
  -import org.w3c.dom.DocumentFragment;
  - 
   /** 
    * Interface a class has to implement that produces java source code 
    * representing logic for a <code>Selector</code>s select method. The 
  @@ -20,13 +18,8 @@
    * sitemap code generation.
    * 
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/27 21:49:04 $ 
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/09/06 23:22:24 $ 
    */ 
   
  -public interface SelectorFactory {
  -    public String generateClassSource (String test, String prefix, DocumentFragment conf)

  -    throws ConfigurationException;
  -
  -    public String generateMethodSource (String test, String prefix, DocumentFragment conf)

  -    throws ConfigurationException;
  +public interface SelectorFactory extends CodeFactory {
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +8 -9      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.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- AbstractSitemap.java	2000/08/21 17:35:30	1.1.2.5
  +++ AbstractSitemap.java	2000/09/06 23:22:25	1.1.2.6
  @@ -20,6 +20,7 @@
   import org.apache.cocoon.ProcessingException; 
   import org.apache.cocoon.Processor; 
   import org.apache.cocoon.environment.Environment; 
  +import org.apache.cocoon.util.ClassUtils;
   
   import org.xml.sax.SAXException; 
   
  @@ -27,7 +28,7 @@
    * Base class for generated <code>Sitemap</code> classes
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/08/21 17:35:30 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/09/06 23:22:25 $
    */
   public abstract class AbstractSitemap
            implements Sitemap {      
  @@ -78,20 +79,18 @@
         * Loads a class specified in a sitemap component definition and
         * initialize it
         */ 
  -    protected Component load_component (String classURL, Configuration conf) 
  -    throws ClassNotFoundException, InstantiationException, IllegalAccessException {
  -        Class cl = this.getClass().getClassLoader().loadClass(classURL);
  -        Object comp = cl.newInstance();
  +    protected Component load_component(String classURL, Configuration conf) throws Exception
{
  +        Object comp = ClassUtils.newInstance(classURL);
           if (!(comp instanceof Component)) {
  -            throw new IllegalAccessException ("Object "+classURL+" is not a Component");
  +            throw new IllegalAccessException ("Object " + classURL + " is not a Component");
           }
           if (comp instanceof Composer) {
  -            ((Composer)comp).setComponentManager (this.manager);
  +            ((Composer) comp).setComponentManager(this.manager);
           }
           if (comp instanceof Configurable) {
  -            ((Configurable)comp).setConfiguration (conf);
  +            ((Configurable) comp).setConfiguration(conf);
           }
  -        return ((Component)comp); 
  +        return ((Component) comp); 
       } 
   
        /** 
  
  
  
  1.1.2.2   +31 -36    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTFactoryLoader.java
  
  Index: XSLTFactoryLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTFactoryLoader.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XSLTFactoryLoader.java	2000/07/27 22:08:46	1.1.2.1
  +++ XSLTFactoryLoader.java	2000/09/06 23:22:25	1.1.2.2
  @@ -4,13 +4,14 @@
    * This software is published under the terms of the Apache Software License * 
    * version 1.1, a copy of which has been included  with this distribution in * 
    * the LICENSE file.                                                         * 
  - *****************************************************************************/ 
  + *****************************************************************************/
  +  
   package org.apache.cocoon.sitemap; 
   
  -import java.util.Hashtable;
  +import java.util.HashMap;
   
  -import org.apache.cocoon.matching.MatcherFactory;
  -import org.apache.cocoon.selection.SelectorFactory;
  +import org.apache.cocoon.CodeFactory;
  +import org.apache.cocoon.util.ClassUtils;
   
   import org.w3c.dom.DocumentFragment;
     
  @@ -20,46 +21,40 @@
    * <code>SelectorFactory</code>s to get the generated source code.
    * 
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/27 22:08:46 $ 
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/09/06 23:22:25 $ 
    */ 
   
   public class XSLTFactoryLoader {
  -    Hashtable obj = new Hashtable ();
  -
  -    public XSLTFactoryLoader () {
  -    }
  +    
  +    HashMap obj = new HashMap();
   
  -    public String getClassSource (String className, String prefix, String pattern, DocumentFragment
conf) 
  -    throws ClassNotFoundException, InstantiationException,  
  -           IllegalAccessException, Exception { 
  +    public String getClassSource(String className, String prefix, String pattern, DocumentFragment
conf) 
  +    throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception
{ 
  +        
           Object factory = obj.get(className); 
  -        if (factory == null) { 
  -            Class cl = this.getClass().getClassLoader().loadClass(className); 
  -            factory = cl.newInstance(); 
  -        } 
  -        obj.put (className, factory); 
  -        if (factory instanceof MatcherFactory)
  -            return ((MatcherFactory)factory).generateClassSource (prefix, pattern, conf);
  -        else if (factory instanceof SelectorFactory)
  -            return ((SelectorFactory)factory).generateClassSource (prefix, pattern, conf);
  -        throw new Exception ("wrong class \""+factory.getClass().getName()
  -                            +"\". Should be a MatcherFactory or SelectorFactory");
  +        if (factory == null) factory = ClassUtils.newInstance(className); 
  +        obj.put(className, factory); 
  +        
  +        if (factory instanceof CodeFactory) {
  +            return ((CodeFactory) factory).generateClassSource(prefix, pattern, conf);
  +        }
  +        
  +        throw new Exception ("Wrong class \"" + factory.getClass().getName()
  +                            + "\". Should implement the CodeFactory interface");
       }
                      
  -    public String getMethodSource (String className, String prefix, String pattern, DocumentFragment
conf) 
  -    throws ClassNotFoundException, InstantiationException,  
  -           IllegalAccessException, Exception { 
  +    public String getMethodSource(String className, String prefix, String pattern, DocumentFragment
conf) 
  +    throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception
{ 
  +
           Object factory = obj.get(className); 
  -        if (factory == null) { 
  -            Class cl = this.getClass().getClassLoader().loadClass(className); 
  -            factory = cl.newInstance(); 
  -        } 
  +        if (factory == null) factory = ClassUtils.newInstance(className); 
           obj.put (className, factory); 
  -        if (factory instanceof MatcherFactory)
  -            return ((MatcherFactory)factory).generateMethodSource (prefix, pattern, conf);
  -        else if (factory instanceof SelectorFactory)
  -            return ((SelectorFactory)factory).generateMethodSource (prefix, pattern, conf);
  -        throw new Exception ("wrong class \""+factory.getClass().getName()
  -                            +"\". Should be a MatcherFactory or SelectorFactory");
  +
  +        if (factory instanceof CodeFactory) {
  +            return ((CodeFactory) factory).generateMethodSource(prefix, pattern, conf);
  +        }
  +        
  +        throw new Exception ("Wrong class \"" + factory.getClass().getName()
  +                            + "\". Should implement the CodeFactory interface");
       }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.9   +7 -7      xml-cocoon/src/org/apache/cocoon/transformation/Attic/SQLTransformer.java
  
  Index: SQLTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/SQLTransformer.java,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- SQLTransformer.java	2000/09/02 21:12:40	1.1.2.8
  +++ SQLTransformer.java	2000/09/06 23:22:26	1.1.2.9
  @@ -23,6 +23,7 @@
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.xml.XMLConsumer;
   import org.apache.cocoon.xml.XMLProducer;
  +import org.apache.cocoon.util.ClassUtils;
   
   import org.xml.sax.ContentHandler;
   import org.xml.sax.EntityResolver;
  @@ -37,7 +38,7 @@
    * @author <a href="mailto:balld@webslingerZ.com">Donald Ball</a>
    * @author <a href="mailto:giacomo.pati@pwr.ch">Giacomo Pati</a>
    *         (PWR Organisation & Entwicklung)
  - * @version CVS $Revision: 1.1.2.8 $ $Date: 2000/09/02 21:12:40 $ $Author: giacomo $
  + * @version CVS $Revision: 1.1.2.9 $ $Date: 2000/09/06 23:22:26 $ $Author: stefano $
    */
   
   public class SQLTransformer extends AbstractTransformer {
  @@ -453,10 +454,8 @@
           protected void execute() throws SQLException {
               String driver = properties.getProperty(transformer.MAGIC_DRIVER);
               try {
  -                Class.forName(driver).newInstance();
  -            } catch (ClassNotFoundException e) {}
  -            catch (IllegalAccessException e) {}
  -            catch (InstantiationException e) {}
  +                ClassUtils.newInstance(driver);
  +            } catch (Exception e) {}
               if (null != properties.getProperty(transformer.MAGIC_DOC_ELEMENT)) {
                   this.rowset_name = properties.getProperty(transformer.MAGIC_DOC_ELEMENT);
               }
  @@ -537,9 +536,10 @@
               try {
                   rs.close();
                   st.close();
  +            } finally { 
  +                conn.close();
               }
  -            finally { conn.close();
  -                    } }
  +        }
   
           protected void addQueryPart(Object object) {
               query_parts.addElement(object);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +19 -4     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.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- ClassUtils.java	2000/07/29 18:30:42	1.1.2.3
  +++ ClassUtils.java	2000/09/06 23:22:26	1.1.2.4
  @@ -5,6 +5,7 @@
    * version 1.1, a copy of which has been included  with this distribution in *
    * the LICENSE file.                                                         *
    *****************************************************************************/
  + 
   package org.apache.cocoon.util;
   
   import java.io.File;
  @@ -16,9 +17,11 @@
    * A collection of class management utility methods.
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:42 $
  + * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/09/06 23:22:26 $
    */
   public class ClassUtils {
  +    
     /**
      * Create a new instance given a class name
      *
  @@ -27,7 +30,7 @@
      * @exception Exception If an instantiation error occurs
      */
     public static Object newInstance(String className) throws Exception {
  -    return getClass(className).newInstance();
  +    return loadClass(className).newInstance();
     }
   
     /**
  @@ -37,8 +40,20 @@
      * @return The class pointed to by <code>className</code>
      * @exception Exception If a loading error occurs
      */
  -  public static Class getClass(String className) throws Exception {
  -    return ClassUtils.class.getClassLoader().loadClass(className);
  +  public static Class loadClass(String className) throws Exception {
  +    // return getClassLoader().loadClass(className);
  +    return Class.forName(className);
  +  }
  +
  +  /**
  +   * Return the context classloader
  +   *
  +   * @return The context classloader.
  +   * @exception Exception If a loading error occurs
  +   */
  +  public static ClassLoader getClassLoader() {
  +    // return Thread.currentThread().getContextClassLoader();
  +    return ClassUtils.class.getClassLoader();
     }
   
     /**
  
  
  
  1.1.2.4   +2 -2      xml-cocoon/src/org/apache/cocoon/util/Attic/IOUtils.java
  
  Index: IOUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/IOUtils.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- IOUtils.java	2000/07/29 18:30:42	1.1.2.3
  +++ IOUtils.java	2000/09/06 23:22:26	1.1.2.4
  @@ -25,7 +25,7 @@
    * utility methods
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:42 $
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/09/06 23:22:26 $
    */
   public class IOUtils {
     /**
  @@ -49,7 +49,7 @@
   	getFullFilename(file).replace(File.separatorChar, '/')
         );
       } else if (location.startsWith("resource://")) {
  -      return IOUtils.class.getClassLoader().getSystemResource(
  +      return ClassUtils.getClassLoader().getSystemResource(
           location.substring("resource://".length())
         );
       } else {
  
  
  

Mime
View raw message