aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/layout/hyphenation/Hyphenator.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/apache/fop/layout/hyphenation/Hyphenator.java')
-rw-r--r--src/org/apache/fop/layout/hyphenation/Hyphenator.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/org/apache/fop/layout/hyphenation/Hyphenator.java b/src/org/apache/fop/layout/hyphenation/Hyphenator.java
index 2a8ee5fcb..9981a32bf 100644
--- a/src/org/apache/fop/layout/hyphenation/Hyphenator.java
+++ b/src/org/apache/fop/layout/hyphenation/Hyphenator.java
@@ -60,16 +60,36 @@ public class Hyphenator {
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