dims 01/07/30 03:50:37
Modified: src/org/apache/cocoon/components/parser Tag:
cocoon_20_branch JaxpParser.java
src/org/apache/cocoon/util Tag: cocoon_20_branch
ClassUtils.java
Log:
Servlet Engine independent way to get which jar file a class was loaded from.
Revision Changes Path
No revision
No revision
1.3.2.1 +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.3.2.1
diff -u -r1.3 -r1.3.2.1
--- JaxpParser.java 2001/05/30 13:32:25 1.3
+++ JaxpParser.java 2001/07/30 10:50:37 1.3.2.1
@@ -30,7 +30,7 @@
* If only we can get rid of the need for the Document...
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.3 $ $Date: 2001/05/30 13:32:25 $
+ * @version CVS $Revision: 1.3.2.1 $ $Date: 2001/07/30 10:50:37 $
*/
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;
No revision
No revision
1.7.2.3 +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.7.2.2
retrieving revision 1.7.2.3
diff -u -r1.7.2.2 -r1.7.2.3
--- ClassUtils.java 2001/07/12 14:47:13 1.7.2.2
+++ ClassUtils.java 2001/07/30 10:50:37 1.7.2.3
@@ -18,7 +18,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.7.2.2 $ $Date: 2001/07/12 14:47:13 $
+ * @version CVS $Revision: 1.7.2.3 $ $Date: 2001/07/30 10:50:37 $
*/
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: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]