garyp 01/05/21 14:21:42
Modified: java/src/org/apache/xalan/processor
TransformerFactoryImpl.java
java/src/org/apache/xalan/serialize CharInfo.java
java/src/org/apache/xpath/functions FuncSystemProperty.java
Log:
Modify getResourceAsStream calls to use the contextClassLoader, if available.
This is a temporary fix until we can centralize this function.
Revision Changes Path
1.32 +19 -2
xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java
Index: TransformerFactoryImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- TransformerFactoryImpl.java 2001/05/19 00:25:47 1.31
+++ TransformerFactoryImpl.java 2001/05/21 21:21:29 1.32
@@ -128,6 +128,12 @@
loadPropertyFileToSystem(XSLT_PROPERTIES);
}
+ /** a zero length Class array used in loadPropertyFileToSystem() */
+ private static final Class[] NO_CLASSES = new Class[0];
+
+ /** a zero length Object array used in loadPropertyFileToSystem() */
+ private static final Object[] NO_OBJS = new Object[0];
+
/**
* Retrieve a propery bundle from a specified file and load it
* int the System properties.
@@ -141,13 +147,24 @@
{
try
{
- InputStream is;
+ InputStream is = null;
try
{
Properties props = new Properties();
+
+ try {
+ java.lang.reflect.Method getCCL =
Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
+ if (getCCL != null) {
+ ClassLoader contextClassLoader = (ClassLoader)
getCCL.invoke(Thread.currentThread(), NO_OBJS);
+ is =
contextClassLoader.getResourceAsStream("org/apache/xalan/processor/" + file);
+ }
+ }
+ catch (Exception e) {}
- is = TransformerFactoryImpl.class.getResourceAsStream(file);
+ if (is == null) {
+ is = TransformerFactoryImpl.class.getResourceAsStream(file);
+ }
// get a buffered version
BufferedInputStream bis = new BufferedInputStream(is);
1.5 +19 -1
xml-xalan/java/src/org/apache/xalan/serialize/CharInfo.java
Index: CharInfo.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/CharInfo.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CharInfo.java 2001/01/07 03:39:19 1.4
+++ CharInfo.java 2001/05/21 21:21:36 1.5
@@ -101,6 +101,13 @@
/** The carriage return character, which the parser should always
normalize. */
public static char S_CARRIAGERETURN = 0x0D;
+ /** a zero length Class array used in the constructor */
+ private static final Class[] NO_CLASSES = new Class[0];
+
+ /** a zero length Object array used in the constructor */
+ private static final Object[] NO_OBJS = new Object[0];
+
+
/**
* Constructor that reads in a resource file that describes the mapping of
* characters to entity references.
@@ -121,7 +128,18 @@
try
{
- is = CharInfo.class.getResourceAsStream(entitiesResource);
+
+ try {
+ java.lang.reflect.Method getCCL =
Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
+ if (getCCL != null) {
+ ClassLoader contextClassLoader = (ClassLoader)
getCCL.invoke(Thread.currentThread(), NO_OBJS);
+ is =
contextClassLoader.getResourceAsStream("org/apache/xalan/serialize/" +
entitiesResource);
+ }
+ }
+ catch (Exception e) {}
+
+ if (is == null)
+ is = CharInfo.class.getResourceAsStream(entitiesResource);
if (is == null)
{
1.9 +19 -2
xml-xalan/java/src/org/apache/xpath/functions/FuncSystemProperty.java
Index: FuncSystemProperty.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncSystemProperty.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FuncSystemProperty.java 2001/01/02 03:47:16 1.8
+++ FuncSystemProperty.java 2001/05/21 21:21:40 1.9
@@ -86,6 +86,13 @@
/** The name of the property file where the name will be stored. */
static String XSLT_PROPERTIES =
"/org/apache/xalan/res/XSLTInfo.properties";
+ /** a zero length Class array used in loadPropertyFile() */
+ private static final Class[] NO_CLASSES = new Class[0];
+
+ /** a zero length Object array used in loadPropertyFile() */
+ private static final Object[] NO_OBJS = new Object[0];
+
+
/**
* Execute the function. The function must return
* a valid object.
@@ -205,11 +212,21 @@
public void loadPropertyFile(String file, Properties target)
{
- InputStream is;
+ InputStream is = null;
try
{
- is = getClass().getResourceAsStream(file);
+ try {
+ java.lang.reflect.Method getCCL =
Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
+ if (getCCL != null) {
+ ClassLoader contextClassLoader = (ClassLoader)
getCCL.invoke(Thread.currentThread(), NO_OBJS);
+ is =
contextClassLoader.getResourceAsStream("org/apache/xpath/functions/" + file);
+ }
+ }
+ catch (Exception e) {}
+
+ if (is == null);
+ is = FuncSystemProperty.class.getResourceAsStream(file);
// get a buffered version
BufferedInputStream bis = new BufferedInputStream(is);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]