struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: cvs commit: jakarta-struts/src/share/org/apache/struts/util MessageResources.java MessageResourcesFactory.java
Date Thu, 18 Jan 2001 06:43:06 GMT
Johan Compagner wrote:

> What about the GenericDataSource printwriter?
>
> Isn't it possible to have somewhere a static method that returns the printwriter
> like this:
>
> public static PrintWriter getLogWriter()
> {
>     if(logWriter == null)
>     {
>         // Create the LogWriter
>     }
>     return logWriter;
> }
>
> Then you can call to that methods from all the locations you want and
> don't need to worry about serialization.
>

For GenericDataSource itself, I was not planning on changing anything -- the
remainder of the class cannot be serialized because of the
Connections themselves cannot be serialized.

For MessageResources this approach would work OK, but I'm not sure it is enough
of a "value add" to really worry about for debugging
messages.

>
> johan
>

Craig


>
> ----- Original Message -----
> From: <craigmcc@apache.org>
> To: <jakarta-struts-cvs@apache.org>
> Sent: Tuesday, January 16, 2001 4:52 AM
> Subject: cvs commit: jakarta-struts/src/share/org/apache/struts/util MessageResources.java
MessageResourcesFactory.java
>
> > craigmcc    01/01/15 19:52:58
> >
> >   Modified:    src/share/org/apache/struts/action ActionServlet.java
> >                src/share/org/apache/struts/util MessageResources.java
> >                         MessageResourcesFactory.java
> >   Log:
> >   Desupport the concept of a configurable PrintWriter for logging messages
> >   from a MessageResources implementation.  This is the short term fix for
> >   the problem of MessageResources not being Serializable.
> >
> >   Revision  Changes    Path
> >   1.55      +4 -7      jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
> >
> >   Index: ActionServlet.java
> >   ===================================================================
> >   RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
> >   retrieving revision 1.54
> >   retrieving revision 1.55
> >   diff -u -r1.54 -r1.55
> >   --- ActionServlet.java 2001/01/07 22:39:06 1.54
> >   +++ ActionServlet.java 2001/01/16 03:52:57 1.55
> >   @@ -1,7 +1,7 @@
> >    /*
> >   - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
1.54 2001/01/07 22:39:06 craigmcc
> Exp $
> >   - * $Revision: 1.54 $
> >   - * $Date: 2001/01/07 22:39:06 $
> >   + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
1.55 2001/01/16 03:52:57 craigmcc
> Exp $
> >   + * $Revision: 1.55 $
> >   + * $Date: 2001/01/16 03:52:57 $
> >     *
> >     * ====================================================================
> >     *
> >   @@ -90,7 +90,6 @@
> >    import org.apache.struts.util.MessageResources;
> >    import org.apache.struts.util.MessageResourcesFactory;
> >    import org.apache.struts.util.RequestUtils;
> >   -import org.apache.struts.util.ServletContextWriter;
> >    import org.xml.sax.AttributeList;
> >    import org.xml.sax.SAXException;
> >
> >   @@ -229,7 +228,7 @@
> >     * </ul>
> >     *
> >     * @author Craig R. McClanahan
> >   - * @version $Revision: 1.54 $ $Date: 2001/01/07 22:39:06 $
> >   + * @version $Revision: 1.55 $ $Date: 2001/01/16 03:52:57 $
> >     */
> >
> >    public class ActionServlet
> >   @@ -955,8 +954,6 @@
> >    if (debug >= 1)
> >        log(internal.getMessage("applicationLoading", value));
> >    try {
> >   -            MessageResourcesFactory.setDefaultWriter
> >   -                (new ServletContextWriter(getServletContext()));
> >                String oldFactory =
> >                    MessageResourcesFactory.getFactoryClass();
> >                if (factory != null)
> >
> >
> >
> >   1.8       +10 -18    jakarta-struts/src/share/org/apache/struts/util/MessageResources.java
> >
> >   Index: MessageResources.java
> >   ===================================================================
> >   RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResources.java,v
> >   retrieving revision 1.7
> >   retrieving revision 1.8
> >   diff -u -r1.7 -r1.8
> >   --- MessageResources.java 2001/01/10 22:06:55 1.7
> >   +++ MessageResources.java 2001/01/16 03:52:57 1.8
> >   @@ -1,7 +1,7 @@
> >    /*
> >   - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResources.java,v
1.7 2001/01/10 22:06:55 craigmcc
> Exp $
> >   - * $Revision: 1.7 $
> >   - * $Date: 2001/01/10 22:06:55 $
> >   + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResources.java,v
1.8 2001/01/16 03:52:57 craigmcc
> Exp $
> >   + * $Revision: 1.8 $
> >   + * $Date: 2001/01/16 03:52:57 $
> >     *
> >     * ====================================================================
> >     *
> >   @@ -63,7 +63,6 @@
> >    package org.apache.struts.util;
> >
> >
> >   -import java.io.PrintWriter;
> >    import java.io.Serializable;
> >    import java.text.MessageFormat;
> >    import java.util.HashMap;
> >   @@ -90,7 +89,7 @@
> >     * application server environments.
> >     *
> >     * @author Craig R. McClanahan
> >   - * @version $Revision: 1.7 $ $Date: 2001/01/10 22:06:55 $
> >   + * @version $Revision: 1.8 $ $Date: 2001/01/16 03:52:57 $
> >     */
> >
> >    public abstract class MessageResources implements Serializable {
> >   @@ -504,12 +503,9 @@
> >         */
> >        public void log(String message) {
> >
> >   -        PrintWriter writer = factory.getWriter();
> >   -        if (writer != null) {
> >   -            writer.print("MessageResources: ");
> >   -            writer.println(message);
> >   -            writer.flush();
> >   -        }
> >   +        System.out.print("MessageResources: ");
> >   +        System.out.println(message);
> >   +        System.out.flush();
> >
> >        }
> >
> >   @@ -523,13 +519,9 @@
> >         */
> >        public void log(String message, Throwable throwable) {
> >
> >   -        PrintWriter writer = factory.getWriter();
> >   -        if (writer != null) {
> >   -            writer.print("MessageResources: ");
> >   -            writer.println(message);
> >   -            throwable.printStackTrace(writer);
> >   -            writer.flush();
> >   -        }
> >   +        System.out.print("MessageResources: ");
> >   +        System.out.println(message);
> >   +        throwable.printStackTrace(System.out);
> >
> >        }
> >
> >
> >
> >
> >   1.2       +6 -43     jakarta-struts/src/share/org/apache/struts/util/MessageResourcesFactory.java
> >
> >   Index: MessageResourcesFactory.java
> >   ===================================================================
> >   RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResourcesFactory.java,v
> >   retrieving revision 1.1
> >   retrieving revision 1.2
> >   diff -u -r1.1 -r1.2
> >   --- MessageResourcesFactory.java 2000/12/15 03:08:11 1.1
> >   +++ MessageResourcesFactory.java 2001/01/16 03:52:57 1.2
> >   @@ -1,7 +1,7 @@
> >    /*
> >   - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResourcesFactory.java,v
1.1 2000/12/15 03:08:11
> craigmcc Exp $
> >   - * $Revision: 1.1 $
> >   - * $Date: 2000/12/15 03:08:11 $
> >   + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResourcesFactory.java,v
1.2 2001/01/16 03:52:57
> craigmcc Exp $
> >   + * $Revision: 1.2 $
> >   + * $Date: 2001/01/16 03:52:57 $
> >     *
> >     * ====================================================================
> >     *
> >   @@ -63,9 +63,6 @@
> >    package org.apache.struts.util;
> >
> >
> >   -import java.io.PrintWriter;
> >   -
> >   -
> >    /**
> >     * Factory for <code>MessageResources</code> instances.  The general
usage
> >     * pattern for this class is:
> >   @@ -81,7 +78,7 @@
> >     * </ul>
> >     *
> >     * @author Craig R. McClanahan
> >   - * @version $Revision: 1.1 $ $Date: 2000/12/15 03:08:11 $
> >   + * @version $Revision: 1.2 $ $Date: 2001/01/16 03:52:57 $
> >     */
> >
> >    public abstract class MessageResourcesFactory {
> >   @@ -105,21 +102,6 @@
> >        }
> >
> >
> >   -    /**
> >   -     * The PrintWriter to which we can log debugging and error information,
> >   -     * if any.
> >   -     */
> >   -    protected PrintWriter writer = null;
> >   -
> >   -    public PrintWriter getWriter() {
> >   -        return (this.writer);
> >   -    }
> >   -
> >   -    public void setWriter(PrintWriter writer) {
> >   -        this.writer = writer;
> >   -    }
> >   -
> >   -
> >        // --------------------------------------------------------- Public Methods
> >
> >
> >   @@ -159,21 +141,6 @@
> >        }
> >
> >
> >   -    /**
> >   -     * The PrintWriter to which we can log error and debugging information,
> >   -     * if any.
> >   -     */
> >   -    protected static PrintWriter defaultWriter = null;
> >   -
> >   -    public static PrintWriter getDefaultWriter() {
> >   -        return (MessageResourcesFactory.defaultWriter);
> >   -    }
> >   -
> >   -    public static void setDefaultWriter(PrintWriter writer) {
> >   -        MessageResourcesFactory.defaultWriter = writer;
> >   -    }
> >   -
> >   -
> >        // --------------------------------------------------------- Static Methods
> >
> >
> >   @@ -191,14 +158,10 @@
> >                    clazz = Class.forName(factoryClass);
> >                MessageResourcesFactory factory =
> >                    (MessageResourcesFactory) clazz.newInstance();
> >   -            factory.setWriter(defaultWriter);
> >                return (factory);
> >            } catch (Throwable t) {
> >   -            if (defaultWriter != null) {
> >   -                defaultWriter.println("MessageResourcesFactory.createFactory");
> >   -                t.printStackTrace(defaultWriter);
> >   -                defaultWriter.flush();
> >   -            }
> >   +            System.out.println("MessageResourcesFactory.createFactory");
> >   +            t.printStackTrace(System.out);
> >                return (null);
> >            }
> >
> >
> >
> >
> >

Mime
View raw message