kellyc 01/06/21 11:05:10
Modified: src/org/apache/fop/apps Options.java
src/org/apache/fop/layout/hyphenation Hyphenator.java
Log:
Added patch for loading config via Thread ContextClassLoader
PR: 2255
Submitted by: Davanum Srinivas
Revision Changes Path
1.5 +15 -2 xml-fop/src/org/apache/fop/apps/Options.java
Index: Options.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Options.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Options.java 2001/06/05 12:55:18 1.4
+++ Options.java 2001/06/21 18:05:07 1.5
@@ -116,10 +116,23 @@
throws FOPException
{
String file = "config.xml";
+ InputStream configfile = null;
+ // Try to use Context Class Loader to load the properties file.
+ try {
+ java.lang.reflect.Method getCCL =
+ Thread.class.getMethod("getContextClassLoader", new Class[0]);
+ if (getCCL != null) {
+ ClassLoader contextClassLoader =
+ (ClassLoader) getCCL.invoke(Thread.currentThread(), new Object[0]);
+ configfile = contextClassLoader.getResourceAsStream("conf/" + file);
+ }
+ }
+ catch (Exception e) {}
+
// the entry /conf/config.xml refers to a directory conf which is a sibling
of org
- InputStream configfile =
- ConfigurationReader.class.getResourceAsStream("/conf/"+
+ if(configfile == null)
+ ConfigurationReader.class.getResourceAsStream("/conf/"+
file);
if (configfile == null) {
throw new FOPException("can't find default configuration file");
1.4 +24 -4 xml-fop/src/org/apache/fop/layout/hyphenation/Hyphenator.java
Index: Hyphenator.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/hyphenation/Hyphenator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Hyphenator.java 2001/06/12 11:37:57 1.3
+++ Hyphenator.java 2001/06/21 18:05:09 1.4
@@ -1,4 +1,4 @@
-/* $Id: Hyphenator.java,v 1.3 2001/06/12 11:37:57 keiron Exp $
+/* $Id: Hyphenator.java,v 1.4 2001/06/21 18:05:09 kellyc Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -60,16 +60,36 @@
return hTree;
}
+ private static InputStream getResourceStream (String key) {
+ InputStream is = null;
+ // Try to use Context Class Loader to load the properties file.
+ try {
+ java.lang.reflect.Method getCCL =
+ Thread.class.getMethod("getContextClassLoader", new Class[0]);
+ if (getCCL != null) {
+ ClassLoader contextClassLoader =
+ (ClassLoader) getCCL.invoke(Thread.currentThread(), new Object[0]);
+ is = contextClassLoader.getResourceAsStream("hyph/" + key + ".hyp");
+ }
+ }
+ catch (Exception e) {}
+
+ if(is==null) {
+ is = Hyphenator.class.getResourceAsStream("/hyph/" + key + ".hyp");
+ }
+
+ return is;
+ }
+
public static HyphenationTree getFopHyphenationTree (String key) {
HyphenationTree hTree = null;
ObjectInputStream ois = null;
InputStream is = null;
try {
- is = Hyphenator.class.getResourceAsStream("/hyph/" + key + ".hyp");
+ is = getResourceStream(key);
if (is == null) {
if (key.length() == 5) {
- is = Hyphenator.class.getResourceAsStream("/hyph/" +
- key.substring(0,2) + ".hyp");
+ is = getResourceStream(key.substring(0,2));
if (is != null) {
MessageHandler.errorln(
"Couldn't find hyphenation pattern " + key
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]