cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/util ClassUtils.java
Date Mon, 30 Jul 2001 10:50:44 GMT
dims        01/07/30 03:50:44

  Modified:    src/org/apache/cocoon/components/parser JaxpParser.java
               src/org/apache/cocoon/util ClassUtils.java
  Log:
  Servlet Engine independent way to get which jar file a class was loaded from.
  
  Revision  Changes    Path
  1.4       +5 -5      xml-cocoon2/src/org/apache/cocoon/components/parser/JaxpParser.java
  
  Index: JaxpParser.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/parser/JaxpParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JaxpParser.java	2001/05/30 13:32:25	1.3
  +++ JaxpParser.java	2001/07/30 10:50:44	1.4
  @@ -30,7 +30,7 @@
    * If only we can get rid of the need for the Document...
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/05/30 13:32:25 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/07/30 10:50:44 $
    */
   public class JaxpParser extends AbstractXMLProducer
   implements Parser, ErrorHandler, SingleThreaded {
  @@ -50,12 +50,12 @@
       throws SAXException, IOException {
           SAXParser parser = null;
   
  -        getLogger().debug("SAXParserFactory: " + ClassUtils.which("javax.xml.parsers.SAXParserFactory"));
  -        getLogger().debug("DocumentBuilderFactory: " + ClassUtils.which("javax.xml.parsers.DocumentBuilderFactory"));
  +        getLogger().debug("SAXParserFactory: " + ClassUtils.which(this.factory.getClass()));
  +        getLogger().debug("DocumentBuilderFactory: " + ClassUtils.which(this.docfactory.getClass()));
   
           try {
               parser = this.factory.newSAXParser();
  -            getLogger().debug("SAXParser: " + ClassUtils.which(parser.getClass().getName()));
  +            getLogger().debug("SAXParser: " + ClassUtils.which(parser.getClass()));
           } catch (Exception e) {
               getLogger().error("Cannot produce a valid parser", e);
               throw new SAXException("Could not get valid parser" + e.getMessage());
  @@ -80,7 +80,7 @@
   
           try {
               builder = this.docfactory.newDocumentBuilder();
  -            getLogger().debug("DocumentBuilder: " + ClassUtils.which(builder.getClass().getName()));
  +            getLogger().debug("DocumentBuilder: " + ClassUtils.which(builder.getClass()));
           } catch (ParserConfigurationException pce) {
               getLogger().error("Could not create DocumentBuilder", pce);
               return null;
  
  
  
  1.10      +4 -18     xml-cocoon2/src/org/apache/cocoon/util/ClassUtils.java
  
  Index: ClassUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/util/ClassUtils.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ClassUtils.java	2001/07/12 14:49:03	1.9
  +++ ClassUtils.java	2001/07/30 10:50:44	1.10
  @@ -18,7 +18,7 @@
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.9 $ $Date: 2001/07/12 14:49:03 $
  + * @version CVS $Revision: 1.10 $ $Date: 2001/07/30 10:50:44 $
    */
   public class ClassUtils {
   
  @@ -129,25 +129,11 @@
        *
        * @param className Name of the class.
        */
  -     public static String which(String className) {
  +     public static String which(Class aClass) {
           String path = null;
  -        String classPath = className;
  -
  -        if (classPath.startsWith("/")) {
  -            classPath = className.substring(1);
  -        }
  -
  -        classPath = classPath.replace('.', '/');
  -        classPath += ".class";
  -
           try {
  -            ClassUtils.loadClass(className);
  -            java.net.URL classUrl = ClassUtils.getResource(classPath);
  -
  -            if(classUrl != null) {
  -                path = classUrl.toExternalForm();
  -            }
  -        } catch (Exception e) {
  +            path = aClass.getProtectionDomain().getCodeSource().getLocation().toString();
  +        } catch (Throwable t){
           }
           return path;
       }
  
  
  

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