Author: tony mancill <tmancill@debian.org>
Description: make jpf work with newer jxp

--- a/source-tools/org/java/plugin/tools/docgen/ClassPathPageSource.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.java.plugin.tools.docgen;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.onemind.commons.java.util.FileUtils;
-import org.onemind.jxp.CachedJxpPage;
-import org.onemind.jxp.CachingPageSource;
-import org.onemind.jxp.JxpPage;
-import org.onemind.jxp.JxpPageNotFoundException;
-import org.onemind.jxp.JxpPageParseException;
-import org.onemind.jxp.parser.AstJxpDocument;
-import org.onemind.jxp.parser.JxpParser;
-import org.onemind.jxp.parser.ParseException;
-
-/**
- * JXP page source configured to load templates from the classpath.
- * @version $Id$
- */
-final class ClassPathPageSource extends CachingPageSource {
-    private final String base;
-    private final ClassLoader cl;
-    private final String encoding;
-
-    ClassPathPageSource(final String aBase, final String anEncoding) {
-        super();
-        base = aBase;
-        encoding = anEncoding;
-        cl = getClass().getClassLoader();
-    }
-
-    /**
-     * @see org.onemind.jxp.CachingPageSource#loadJxpPage(java.lang.String)
-     */
-    @Override
-    protected CachedJxpPage loadJxpPage(final String id)
-            throws JxpPageNotFoundException {
-        if (!hasJxpPage(id)) {
-            throw new JxpPageNotFoundException("page " + id + " not found"); //$NON-NLS-1$ //$NON-NLS-2$
-        }
-        return new CachedJxpPage(this, id);
-    }
-
-    /**
-     * @see org.onemind.jxp.CachingPageSource#parseJxpDocument(
-     *      org.onemind.jxp.JxpPage)
-     */
-    @Override
-    protected AstJxpDocument parseJxpDocument(final JxpPage page)
-            throws JxpPageParseException {
-        try {
-            JxpParser parser;
-            if (encoding == null) {
-                parser = new JxpParser(cl.getResourceAsStream(
-                        getStreamName(page.getName())));
-            } else {
-                parser = new JxpParser(new InputStreamReader(
-                        cl.getResourceAsStream(getStreamName(page.getName())),
-                        encoding));
-            }
-            return parser.JxpDocument();
-        } catch (IOException ioe) {
-            throw new JxpPageParseException("problem parsing page " //$NON-NLS-1$
-                    + page.getName() + ": " + ioe.getMessage(), ioe); //$NON-NLS-1$
-        } catch (ParseException pe) {
-            throw new JxpPageParseException("problem parsing page " //$NON-NLS-1$
-                    + page.getName() + ": " + pe.getMessage(), pe); //$NON-NLS-1$
-        }
-    }
-
-    /**
-     * @see org.onemind.jxp.JxpPageSource#hasJxpPage(java.lang.String)
-     */
-    @Override
-    public boolean hasJxpPage(final String id) {
-        if (isJxpPageCached(id)) {
-            return true;
-        }
-        return cl.getResource(getStreamName(id)) != null;
-    }
-    
-    private String getStreamName(final String pageName) {
-        return FileUtils.concatFilePath(base, pageName);
-    }
-}
--- a/source-tools/org/java/plugin/tools/docgen/DocGenerator.java
+++ b/source-tools/org/java/plugin/tools/docgen/DocGenerator.java
@@ -45,8 +45,11 @@
 import org.java.plugin.registry.PluginRegistry;
 import org.java.plugin.util.IoUtil;
 import org.onemind.jxp.FilePageSource;
-import org.onemind.jxp.JxpProcessingContext;
+import org.onemind.jxp.CachingPageSource;
+import org.onemind.jxp.JxpPageSource;
 import org.onemind.jxp.JxpProcessor;
+import org.onemind.jxp.JxpContext;
+import org.onemind.jxp.ResourceStreamPageSource;
 
 /**
  * Tool class to generate documentation for plug-ins using <a
@@ -128,7 +131,7 @@
             final PathResolver aPathResolver, final String templatesPath,
             final String templatesEncoding) throws Exception {
         this(aRegistry, aPathResolver, new JxpProcessor(
-                new ClassPathPageSource(templatesPath, templatesEncoding)));
+        		new JxpContext(new FilePageSource(templatesPath, templatesEncoding))));
     }
 
     /**
@@ -152,8 +155,8 @@
             final String templatesEncoding) throws Exception {
         // TODO: use character encoding when that will be possible in JXP
         // library
-        this(aRegistry, aPathResolver, new JxpProcessor(new FilePageSource(
-                templatesFolder.getCanonicalPath())));
+        this(aRegistry, aPathResolver, new JxpProcessor(
+        		new JxpContext(new FilePageSource(templatesFolder.getCanonicalPath()))));
     }
 
     private DocGenerator(final PluginRegistry aRegistry,
@@ -217,7 +220,7 @@
         Writer out = new OutputStreamWriter(new BufferedOutputStream(
                 new FileOutputStream(outFile, false)), outputEncoding);
         try {
-            processor.process(template, new JxpProcessingContext(out, ctx));
+            processor.process(template, out);
         } finally {
             out.close();
         }
@@ -237,11 +240,11 @@
         Writer out = new OutputStreamWriter(new BufferedOutputStream(
                 new FileOutputStream(outFile, false)), outputEncoding);
         try {
-            JxpProcessor proc = new JxpProcessor(new FilePageSource(tmpFile
-                    .getParentFile().getCanonicalPath()));
+            JxpProcessor proc = new JxpProcessor(
+            		new JxpContext(new FilePageSource(tmpFile.getParentFile().getCanonicalPath())));
             // TODO: use character encoding when that will be possible in JXP
             // library (UTF-8 in this case)
-            proc.process(tmpFile.getName(), new JxpProcessingContext(out, ctx));
+            proc.process(tmpFile.getName(), out);
         } finally {
             tmpFile.delete();
             out.close();
