chrisg      02/03/21 09:18:05

  Modified:    docs/examples/embedding Tag: fop-0_20_2-maintain
                        FopPrintServlet.java FopServlet.java
               src/org/apache/fop/apps Tag: fop-0_20_2-maintain
                        CommandLineOptions.java
               src/org/apache/fop/datatypes Tag: fop-0_20_2-maintain
                        ToBeImplementedProperty.java
               src/org/apache/fop/messaging Tag: fop-0_20_2-maintain
                        MessageHandler.java
               src/org/apache/fop/tools Tag: fop-0_20_2-maintain
                        TestConverter.java
               src/org/apache/fop/tools/anttasks Tag: fop-0_20_2-maintain
                        Fop.java
  Log:
  changed MessageHandler and servlet examples to use
  org.apache.avalon.framework.logger.Logger
  
  Submitted by: Michael Gratton <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +8 -8      xml-fop/docs/examples/embedding/Attic/FopPrintServlet.java
  
  Index: FopPrintServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/docs/examples/embedding/Attic/FopPrintServlet.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- FopPrintServlet.java      1 Mar 2002 12:44:39 -0000       1.1.2.2
  +++ FopPrintServlet.java      21 Mar 2002 17:18:05 -0000      1.1.2.3
  @@ -1,5 +1,5 @@
   /*
  - * $Id: FopPrintServlet.java,v 1.1.2.2 2002/03/01 12:44:39 chrisg Exp $
  + * $Id: FopPrintServlet.java,v 1.1.2.3 2002/03/21 17:18:05 chrisg Exp $
    * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -21,10 +21,12 @@
   import org.apache.fop.layout.Page;
   import org.apache.fop.apps.Version;
   import org.apache.fop.apps.XSLTInputHandler;
  +import org.apache.fop.messaging.MessageHandler;
   
   import org.apache.fop.render.awt.AWTRenderer ;
   
  -import org.apache.log.*;
  +import org.apache.avalon.framework.logger.ConsoleLogger;
  +import org.apache.avalon.framework.logger.Logger;
   
   /**
    * Example servlet to generate a fop printout from a servlet.
  @@ -40,13 +42,12 @@
    * - servlet_2_2.jar
    * - fop.jar
    * - sax api
  - * - logkit jar
  + * - avalon-framework-x.jar (where x is the version found the FOP lib dir)
    *
    * Running: you will need in the WEB-INF/lib/ directory:
    * - fop.jar
    * - batik.jar
  - * - avalon-framework-4.0.jar
  - * - logkit-1.0.jar
  + * - avalon-framework-x.jar (where x is the version found the FOP lib dir)
    * - xalan-2.0.0.jar
    */
    
  @@ -62,9 +63,8 @@
     {
       if (log == null) 
         {
  -        Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
  -        log = hierarchy.getLoggerFor("fop");
  -        log.setPriority(Priority.WARN);
  +      log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
  +      MessageHandler.setScreenLogger(log);
         }
           
       try  
  
  
  
  1.4.2.2   +8 -8      xml-fop/docs/examples/embedding/FopServlet.java
  
  Index: FopServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/docs/examples/embedding/FopServlet.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- FopServlet.java   1 Mar 2002 12:44:39 -0000       1.4.2.1
  +++ FopServlet.java   21 Mar 2002 17:18:05 -0000      1.4.2.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: FopServlet.java,v 1.4.2.1 2002/03/01 12:44:39 chrisg Exp $
  + * $Id: FopServlet.java,v 1.4.2.2 2002/03/21 17:18:05 chrisg 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.
  @@ -16,8 +16,10 @@
   import org.apache.fop.apps.Driver;
   import org.apache.fop.apps.Version;
   import org.apache.fop.apps.XSLTInputHandler;
  +import org.apache.fop.messaging.MessageHandler;
   
  -import org.apache.log.*;
  +import org.apache.avalon.framework.logger.ConsoleLogger;
  +import org.apache.avalon.framework.logger.Logger;
   
   /**
    * Example servlet to generate a PDF from a servlet.
  @@ -32,14 +34,13 @@
    * - servlet_2_2.jar
    * - fop.jar
    * - sax api
  - * - logkit jar
  + * - avalon-framework-x.jar (where x is the version found the FOP lib dir)
    *
    * Running: you will need in the WEB-INF/lib/ directory:
    * - fop.jar
    * - batik.jar
  - * - avalon-framework-4.0.jar
  - * - logkit-1.0.jar
    * - xalan-2.0.0.jar
  + * - avalon-framework-x.jar (where x is the version found the FOP lib dir)
    */
   public class FopServlet extends HttpServlet {
       public static final String FO_REQUEST_PARAM = "fo";
  @@ -50,9 +51,8 @@
       public void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException {
           if(log == null) {
  -            Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
  -            log = hierarchy.getLoggerFor("fop");
  -            log.setPriority(Priority.WARN);
  +          log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
  +          MessageHandler.setScreenLogger(log);
           }
           try {
               String foParam = request.getParameter(FO_REQUEST_PARAM);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.2  +10 -4     xml-fop/src/org/apache/fop/apps/CommandLineOptions.java
  
  Index: CommandLineOptions.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/CommandLineOptions.java,v
  retrieving revision 1.14.2.1
  retrieving revision 1.14.2.2
  diff -u -r1.14.2.1 -r1.14.2.2
  --- CommandLineOptions.java   17 Mar 2002 23:37:06 -0000      1.14.2.1
  +++ CommandLineOptions.java   21 Mar 2002 17:18:05 -0000      1.14.2.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: CommandLineOptions.java,v 1.14.2.1 2002/03/17 23:37:06 chrisg Exp $
  + * $Id: CommandLineOptions.java,v 1.14.2.2 2002/03/21 17:18:05 chrisg 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.
  @@ -15,6 +15,7 @@
   // FOP
   import org.apache.fop.configuration.Configuration;
   import org.apache.fop.apps.FOPException;
  +import org.apache.fop.messaging.MessageHandler;
   
   // Avalon
   import org.apache.avalon.framework.logger.ConsoleLogger;
  @@ -92,7 +93,7 @@
       public CommandLineOptions(String[] args)
               throws FOPException, FileNotFoundException {
   
  -        log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
  +        setLogger(new ConsoleLogger(ConsoleLogger.LEVEL_INFO));
   
           boolean optionsParsed = true;
           rendererOptions = new java.util.Hashtable();
  @@ -123,13 +124,13 @@
           for (int i = 0; i < args.length; i++) {
               if (args[i].equals("-d") || args[i].equals("--full-error-dump")) {
                   errorDump = new Boolean(true);
  -                log = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
  +                setLogger(new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG));
               } else if (args[i].equals("-x")
                          || args[i].equals("--dump-config")) {
                   dumpConfiguration = new Boolean(true);
               } else if (args[i].equals("-q") || args[i].equals("--quiet")) {
                   quiet = new Boolean(true);
  -                log = new ConsoleLogger(ConsoleLogger.LEVEL_ERROR);
  +                setLogger(new ConsoleLogger(ConsoleLogger.LEVEL_ERROR));
               } else if (args[i].equals("-c")) {
                   if ((i + 1 == args.length)
                           || (args[i + 1].charAt(0) == '-')) {
  @@ -346,6 +347,11 @@
   
           }
       }    // end checkSettings
  +
  +    private void setLogger(Logger newLogger) {
  +     this.log = newLogger;
  +     MessageHandler.setScreenLogger(newLogger);
  +    }
   
       /**
        * returns the chosen renderer, throws FOPException
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.2   +4 -9      
xml-fop/src/org/apache/fop/datatypes/ToBeImplementedProperty.java
  
  Index: ToBeImplementedProperty.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/org/apache/fop/datatypes/ToBeImplementedProperty.java,v
  retrieving revision 1.3.2.1
  retrieving revision 1.3.2.2
  diff -u -r1.3.2.1 -r1.3.2.2
  --- ToBeImplementedProperty.java      17 Mar 2002 23:37:07 -0000      1.3.2.1
  +++ ToBeImplementedProperty.java      21 Mar 2002 17:18:05 -0000      1.3.2.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: ToBeImplementedProperty.java,v 1.3.2.1 2002/03/17 23:37:07 chrisg Exp $ --
  + * $Id: ToBeImplementedProperty.java,v 1.3.2.2 2002/03/21 17:18:05 chrisg 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.
  @@ -8,6 +8,7 @@
   package org.apache.fop.datatypes;
   
   import org.apache.fop.fo.*;
  +import org.apache.fop.messaging.MessageHandler;
   
   public class ToBeImplementedProperty extends Property {
   
  @@ -29,14 +30,8 @@
       }
   
       public ToBeImplementedProperty(String propName) {
  -
  -     // XXX (mjg) This is a bit of a kluge, perhaps an
  -     // UnimplementedPropertyException or similar should
  -     // get thrown here instead.
  -
  -//         Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor("fop");
  -//         log.warn("property - \"" + propName
  -//                                + "\" is not implemented yet.");
  +     MessageHandler.errorln("property - \"" + propName
  +                          + "\" is not implemented yet.");
       }
   
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.2   +52 -39    xml-fop/src/org/apache/fop/messaging/Attic/MessageHandler.java
  
  Index: MessageHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/messaging/Attic/MessageHandler.java,v
  retrieving revision 1.6.2.1
  retrieving revision 1.6.2.2
  diff -u -r1.6.2.1 -r1.6.2.2
  --- MessageHandler.java       17 Mar 2002 23:37:07 -0000      1.6.2.1
  +++ MessageHandler.java       21 Mar 2002 17:18:05 -0000      1.6.2.2
  @@ -48,6 +48,7 @@
       public static final int EVENT = 2;
       public static final int NONE = 3;    // this should always be the last method
   
  +    private static Logger logger = null;
       private static String logfileName = "fop.log";
       private static PrintWriter writer;
       private static int outputMethod = SCREEN;
  @@ -81,47 +82,47 @@
           }
       }
   
  -    // temp workaround
  -    private static Logger logger = null;
  -
       /**
        * informs the user of the message
        * @param message the message for the user
        */
       public static void log(String message) {
  -        if (!quiet) {
  -            if(logger == null) {
  -                logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
  -            }
  -            setMessage(message);
  -            switch (outputMethod) {
  -            case SCREEN:
  -                logger.debug(getMessage());
  -                break;
  -            case FILE:
  -                if (fileOpened) {
  -                    writer.print(getMessage());
  -                    writer.flush();
  -                } else {
  -                    openFile();
  -                    writer.print(getMessage());
  -                    writer.flush();
  -                }
  -                break;
  -            case EVENT:
  -                setMessage(message);
  -                Enumeration enum = listeners.elements();
  -                while (enum.hasMoreElements()) {
  -                    ((MessageListener)enum.nextElement()).processMessage(new 
MessageEvent(getMessage()));
  -                }
  -                break;
  -            case NONE:
  -                // do nothing
  -                break;
  -            default:
  -                logger.debug(message);
  -            }
  -        }
  +        if (quiet)
  +         return;
  +
  +     if (logger == null) {
  +         logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
  +         logger.warn("Screen logger not set.");
  +     }
  +     
  +     setMessage(message);
  +     switch (outputMethod) {
  +     case SCREEN:
  +         logger.debug(getMessage());
  +         break;
  +     case FILE:
  +         if (fileOpened) {
  +             writer.print(getMessage());
  +             writer.flush();
  +         } else {
  +             openFile();
  +             writer.print(getMessage());
  +             writer.flush();
  +         }
  +         break;
  +     case EVENT:
  +         setMessage(message);
  +         Enumeration enum = listeners.elements();
  +         while (enum.hasMoreElements()) {
  +             ((MessageListener)enum.nextElement()).processMessage(new 
MessageEvent(getMessage()));
  +         }
  +         break;
  +     case NONE:
  +         // do nothing
  +         break;
  +     default:
  +         logger.debug(message);
  +     }
       }
   
       /**
  @@ -138,9 +139,11 @@
        */
   
       public static void error(String errorMessage) {
  -        if(logger == null) {
  -            logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
  -        }
  +     if (logger == null) {
  +         logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
  +         logger.warn("Screen logger not set.");
  +     }
  +
           setMessage(errorMessage);
           switch (outputMethod) {
           case SCREEN:
  @@ -195,6 +198,16 @@
        */
       public static void removeListener(MessageListener listener) {
           listeners.removeElement(listener);
  +    }
  +
  +    /**
  +     * Sets the Logger used for the screen output method.
  +     * @param newLogger a logger for screen output. This may not be null.
  +     */
  +    public static void setScreenLogger(Logger newLogger) {
  +     if (newLogger == null)
  +         throw new NullPointerException();
  +     logger = newLogger;
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.15.2.2  +3 -1      xml-fop/src/org/apache/fop/tools/TestConverter.java
  
  Index: TestConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/TestConverter.java,v
  retrieving revision 1.15.2.1
  retrieving revision 1.15.2.2
  diff -u -r1.15.2.1 -r1.15.2.2
  --- TestConverter.java        17 Mar 2002 23:37:08 -0000      1.15.2.1
  +++ TestConverter.java        21 Mar 2002 17:18:05 -0000      1.15.2.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: TestConverter.java,v 1.15.2.1 2002/03/17 23:37:08 chrisg Exp $
  + * $Id: TestConverter.java,v 1.15.2.2 2002/03/21 17:18:05 chrisg 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.
  @@ -9,6 +9,7 @@
   
   import org.apache.fop.apps.*;
   import org.apache.fop.configuration.*;
  +import org.apache.fop.messaging.MessageHandler;
   
   import org.apache.avalon.framework.logger.ConsoleLogger;
   import org.apache.avalon.framework.logger.Logger;
  @@ -87,6 +88,7 @@
   
       private void setupLogging() {
        log = new ConsoleLogger(ConsoleLogger.LEVEL_ERROR);
  +     MessageHandler.setScreenLogger(log);    
       }
   
       public void setOutputPDF(boolean pdf) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.2  +2 -1      xml-fop/src/org/apache/fop/tools/anttasks/Fop.java
  
  Index: Fop.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/anttasks/Fop.java,v
  retrieving revision 1.14.2.1
  retrieving revision 1.14.2.2
  diff -u -r1.14.2.1 -r1.14.2.2
  --- Fop.java  17 Mar 2002 23:37:08 -0000      1.14.2.1
  +++ Fop.java  21 Mar 2002 17:18:05 -0000      1.14.2.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: Fop.java,v 1.14.2.1 2002/03/17 23:37:08 chrisg Exp $
  + * $Id: Fop.java,v 1.14.2.2 2002/03/21 17:18:05 chrisg 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.
  @@ -195,6 +195,7 @@
           this.task = task;
   
        log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
  +     MessageHandler.setScreenLogger(log);
       }
   
       private int determineRenderer(String format) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to