aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2004-06-20 12:35:17 +0000
committerGlen Mazza <gmazza@apache.org>2004-06-20 12:35:17 +0000
commitd6fc7d07d23209f2416a674e5208ae53f070ae26 (patch)
treeffd46f9672c76e5b581fed77338ec0d1d8632366
parentb638342ab96a6d344aab5fd9653ca24e29d90424 (diff)
downloadxmlgraphics-fop-d6fc7d07d23209f2416a674e5208ae53f070ae26.tar.gz
xmlgraphics-fop-d6fc7d07d23209f2416a674e5208ae53f070ae26.zip
1.) Removed the get/setLogger methods from Driver, obsolete with Commons-Logging.
2.) Updated examples and documentation. 3.) Added a -v option to show version of FOP being used. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197740 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--examples/embedding/java/embedding/ExampleDOM2PDF.java14
-rw-r--r--examples/embedding/java/embedding/ExampleFO2PDF.java14
-rw-r--r--examples/embedding/java/embedding/ExampleObj2PDF.java15
-rw-r--r--examples/embedding/java/embedding/ExampleXML2PDF.java6
-rw-r--r--src/documentation/content/xdocs/embedding.xml25
-rw-r--r--src/java/org/apache/fop/apps/CommandLineOptions.java8
-rw-r--r--src/java/org/apache/fop/apps/Driver.java61
-rw-r--r--src/java/org/apache/fop/apps/Fop.java5
-rw-r--r--src/java/org/apache/fop/render/AbstractRenderer.java2
-rw-r--r--src/java/org/apache/fop/servlet/FopPrintServlet.java2
-rw-r--r--src/java/org/apache/fop/servlet/FopServlet.java1
-rw-r--r--src/java/org/apache/fop/tools/anttasks/Fop.java1
12 files changed, 36 insertions, 118 deletions
diff --git a/examples/embedding/java/embedding/ExampleDOM2PDF.java b/examples/embedding/java/embedding/ExampleDOM2PDF.java
index ab02e6607..5531cc252 100644
--- a/examples/embedding/java/embedding/ExampleDOM2PDF.java
+++ b/examples/embedding/java/embedding/ExampleDOM2PDF.java
@@ -18,12 +18,10 @@
package embedding;
-//Java
+// Java
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
-
-//JAXP
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
@@ -33,10 +31,7 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
-//FOP
+// FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
@@ -61,10 +56,7 @@ public class ExampleDOM2PDF {
// Construct driver
Driver driver = new Driver();
- // Setup logger
- SimpleLog logger = new SimpleLog("log");
- logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
- driver.setLogger(logger);
+ // Setup driver
driver.initialize();
// Setup Renderer (output format)
diff --git a/examples/embedding/java/embedding/ExampleFO2PDF.java b/examples/embedding/java/embedding/ExampleFO2PDF.java
index be8cd7822..6d7a7c564 100644
--- a/examples/embedding/java/embedding/ExampleFO2PDF.java
+++ b/examples/embedding/java/embedding/ExampleFO2PDF.java
@@ -18,19 +18,16 @@
package embedding;
-//Java
+// Java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-//SAX
+// SAX
import org.xml.sax.InputSource;
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
-//FOP
+// FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
@@ -51,10 +48,7 @@ public class ExampleFO2PDF {
// Construct driver
Driver driver = new Driver();
- // Setup logger
- SimpleLog logger = new SimpleLog("log");
- logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
- driver.setLogger(logger);
+ // Setup driver
driver.initialize();
// Setup Renderer (output format)
diff --git a/examples/embedding/java/embedding/ExampleObj2PDF.java b/examples/embedding/java/embedding/ExampleObj2PDF.java
index 313faee43..ff2419ff3 100644
--- a/examples/embedding/java/embedding/ExampleObj2PDF.java
+++ b/examples/embedding/java/embedding/ExampleObj2PDF.java
@@ -18,12 +18,12 @@
package embedding;
-//Java
+// Java
import java.io.File;
import java.io.OutputStream;
import java.io.IOException;
-//JAXP
+// JAXP
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
@@ -32,13 +32,9 @@ import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXResult;
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
-//FOP
+// FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
-
import embedding.model.ProjectTeam;
/**
@@ -62,10 +58,7 @@ public class ExampleObj2PDF {
// Construct driver
Driver driver = new Driver();
- // Setup logger
- SimpleLog logger = new SimpleLog("log");
- logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
- driver.setLogger(logger);
+ // Setup driver
driver.initialize();
// Setup Renderer (output format)
diff --git a/examples/embedding/java/embedding/ExampleXML2PDF.java b/examples/embedding/java/embedding/ExampleXML2PDF.java
index 60cdd12ef..bb16b6528 100644
--- a/examples/embedding/java/embedding/ExampleXML2PDF.java
+++ b/examples/embedding/java/embedding/ExampleXML2PDF.java
@@ -32,9 +32,6 @@ import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXResult;
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
//FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
@@ -74,9 +71,6 @@ public class ExampleXML2PDF {
Driver driver = new Driver();
// Setup logger
- SimpleLog logger = new SimpleLog("log");
- logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
- driver.setLogger(logger);
driver.initialize();
// Setup Renderer (output format)
diff --git a/src/documentation/content/xdocs/embedding.xml b/src/documentation/content/xdocs/embedding.xml
index ac707fa73..3c729558a 100644
--- a/src/documentation/content/xdocs/embedding.xml
+++ b/src/documentation/content/xdocs/embedding.xml
@@ -93,26 +93,13 @@ driver.setLogger(logger);]]></source>
<section id="basic-logging-new-version">
<title>Logging (Upcoming FOP 1.0 Version only)</title>
<p>
- You also need to set up logging. Global logging for all FOP
- processes is managed by MessageHandler. Per-instance logging
- is handled by Driver. You want to set both using an implementation
- of org.apache.commons.logging.Log. See
- <jump href="#logging">below</jump> for more information.
- </p>
- <p>
- Call <code>setLogger(Logger)</code> always immediately after
- instantiating the Driver object. See here:
+ Logging is handled automatically via Jakarta Commons-Logging, which uses
+ JDK logging by default. No special driver configuration is needed.
+ For specialized configuration of Commons-Logging (e.g. to use a
+ different logger or to change logging levels), please see the
+ <fork href="http://jakarta.apache.org/commons/logging/">Jakarta Commons-Logging</fork>
+ site.
</p>
- <source><![CDATA[
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.impl.SimpleLog;
-
-/*..*/
-
-Driver driver = new Driver();
-Log logger = new SimpleLog(SimpleLog.LOG_LEVEL_INFO);
-MessageHandler.setScreenLogger(logger);
-driver.setLogger(logger);]]></source>
</section>
<section id="render">
diff --git a/src/java/org/apache/fop/apps/CommandLineOptions.java b/src/java/org/apache/fop/apps/CommandLineOptions.java
index 930a557a1..b6116c7bc 100644
--- a/src/java/org/apache/fop/apps/CommandLineOptions.java
+++ b/src/java/org/apache/fop/apps/CommandLineOptions.java
@@ -174,6 +174,8 @@ public class CommandLineOptions {
i = i + parseUnknownOption(args, i);
} else if (args[i].equals("-at")) {
i = i + parseAreaTreeOption(args, i);
+ } else if (args[i].equals("-v")) {
+ System.out.println("FOP Version " + Version.getVersion());
} else if (args[i].equals("-param")) {
if (i + 2 < args.length) {
if (xsltParams == null) {
@@ -575,7 +577,8 @@ public class CommandLineOptions {
+ " -x dump configuration settings \n"
+ " -c cfg.xml use additional configuration file cfg.xml\n"
+ " -l lang the language to use for user information \n"
- + " -s for area tree XML, down to block areas only\n\n"
+ + " -s for area tree XML, down to block areas only\n"
+ + " -v to show FOP version being used\n\n"
+ " [INPUT] \n"
+ " infile xsl:fo input file (the same as the next) \n"
+ " -fo infile xsl:fo input file \n"
@@ -608,14 +611,13 @@ public class CommandLineOptions {
/**
* shows the options for print output
*/
- public void printUsagePrintOutput() {
+ private void printUsagePrintOutput() {
System.err.println("USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] "
+ " org.apache.fop.apps.Fop (..) -print \n"
+ "Example:\n"
+ "java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print ");
}
-
/**
* Outputs all commandline settings
*/
diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java
index cf4395a94..edf138ee6 100644
--- a/src/java/org/apache/fop/apps/Driver.java
+++ b/src/java/org/apache/fop/apps/Driver.java
@@ -18,10 +18,20 @@
package org.apache.fop.apps;
+// Java
+import java.io.IOException;
+import java.io.OutputStream;
+
+// XML
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.w3c.dom.Document;
+
// FOP
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FOTreeBuilder;
-
import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.fo.FOTreeHandler;
import org.apache.fop.render.Renderer;
@@ -31,20 +41,6 @@ import org.apache.fop.render.rtf.RTFHandler;
import org.apache.fop.tools.DocumentInputSource;
import org.apache.fop.tools.DocumentReader;
-import org.apache.commons.logging.impl.SimpleLog;
-import org.apache.commons.logging.Log;
-
-// XML
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.w3c.dom.Document;
-
-// Java
-import java.io.IOException;
-import java.io.OutputStream;
-
/**
* Primary class that drives overall FOP process.
* <P>
@@ -57,7 +53,6 @@ import java.io.OutputStream;
* <PRE>
* Driver driver = new Driver(new InputSource (args[0]),
* new FileOutputStream(args[1]));
- * driver.setLogger(myLogger); //optional
* driver.setRenderer(RENDER_PDF);
* driver.run();
* </PRE>
@@ -87,7 +82,6 @@ import java.io.OutputStream;
*
* <PRE>
* Driver driver = new Driver();
- * driver.setLogger(myLogger); //optional
* driver.setRenderer(new org.apache.fop.render.awt.AWTRenderer(translator));
* driver.render(parser, fileInputSource(args[0]));
* </PRE>
@@ -185,9 +179,8 @@ public class Driver {
private XMLReader reader;
/**
- * the system resources that FOP will use
+ * The system resources that FOP will use
*/
- private Log log = null;
private FOUserAgent userAgent = null;
/**
@@ -239,33 +232,6 @@ public class Driver {
}
/**
- * Provide the Driver instance with a logger.
- * @param log the logger. Must not be <code>null</code>.
- */
- public void setLogger(Log log) {
- if (this.log == null) {
- this.log = log;
- } else {
- getLogger().warn("Logger is already set! Won't use the new logger.");
- }
- }
-
-
- /**
- * Returns the logger for use by FOP.
- * @return the logger
- */
- public Log getLogger() {
- if (this.log == null) {
- // use SimpleLog as default when logger not explicitly set
- log = new SimpleLog("FOP");
- ((SimpleLog) log).setLevel(SimpleLog.LOG_LEVEL_INFO);
- }
-
- return this.log;
- }
-
- /**
* Resets the Driver so it can be reused. Property and element
* mappings are reset to defaults.
* The output stream is cleared. The renderer is cleared.
@@ -377,7 +343,7 @@ public class Driver {
/**
* Set the Renderer to use.
- * @param renderer the renderer instance to use (Note: Logger must be set at this point)
+ * @param renderer the renderer instance to use
*/
public void setRenderer(Renderer renderer) {
// AWTStarter calls this function directly
@@ -584,5 +550,4 @@ public class Driver {
render(reader, source);
}
}
-
}
diff --git a/src/java/org/apache/fop/apps/Fop.java b/src/java/org/apache/fop/apps/Fop.java
index 39d1d6c9c..362739c22 100644
--- a/src/java/org/apache/fop/apps/Fop.java
+++ b/src/java/org/apache/fop/apps/Fop.java
@@ -22,8 +22,6 @@ package org.apache.fop.apps;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
-import org.apache.commons.logging.impl.SimpleLog;
-
// FOP
import org.apache.fop.render.awt.AWTRenderer;
@@ -47,9 +45,6 @@ public class Fop {
Driver driver = new Driver();
options = new CommandLineOptions(args);
- driver.setLogger(options.getLogger());
- driver.getLogger().info(version);
-
inputHandler = options.getInputHandler();
try {
diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java
index 53a6f3b0a..96c10d0ac 100644
--- a/src/java/org/apache/fop/render/AbstractRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractRenderer.java
@@ -87,7 +87,7 @@ public abstract class AbstractRenderer
/**
* logging instance
*/
- protected static Log logger = LogFactory.getLog("Renderer");
+ protected static Log logger = LogFactory.getLog("FOP");
/**
* producer (usually "FOP")
diff --git a/src/java/org/apache/fop/servlet/FopPrintServlet.java b/src/java/org/apache/fop/servlet/FopPrintServlet.java
index 0320a706e..f873812aa 100644
--- a/src/java/org/apache/fop/servlet/FopPrintServlet.java
+++ b/src/java/org/apache/fop/servlet/FopPrintServlet.java
@@ -134,7 +134,6 @@ public class FopPrintServlet extends HttpServlet {
Driver driver = new Driver(foFile, null);
AWTPrintRenderer renderer = new AWTPrintRenderer();
- driver.setLogger(log);
driver.setRenderer(renderer);
driver.run();
@@ -156,7 +155,6 @@ public class FopPrintServlet extends HttpServlet {
Driver driver = new Driver();
AWTPrintRenderer renderer = new AWTPrintRenderer();
- driver.setLogger(log);
driver.setRenderer(renderer);
driver.render(input.getParser(), input.getInputSource());
diff --git a/src/java/org/apache/fop/servlet/FopServlet.java b/src/java/org/apache/fop/servlet/FopServlet.java
index 497d4b64f..566b17f4c 100644
--- a/src/java/org/apache/fop/servlet/FopServlet.java
+++ b/src/java/org/apache/fop/servlet/FopServlet.java
@@ -202,7 +202,6 @@ public class FopServlet extends HttpServlet {
//Setup FOP
Driver driver = new Driver();
- driver.setLogger(this.log);
driver.setRenderer(Driver.RENDER_PDF);
driver.initialize();
diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java
index d82b922ed..6093c9fd1 100644
--- a/src/java/org/apache/fop/tools/anttasks/Fop.java
+++ b/src/java/org/apache/fop/tools/anttasks/Fop.java
@@ -532,7 +532,6 @@ class FOPTaskStarter {
try {
Driver driver = new Driver();
- driver.setLogger(getLogger());
FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(this.baseURL);
driver.setUserAgent(userAgent);