axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <d...@yahoo.com>
Subject RE: using log4j
Date Thu, 18 Oct 2001 14:52:23 GMT
Thanks Tom. Will do it next time.

-- dims

--- Tom Jordahl <tomj@macromedia.com> wrote:
> A real minor nit, not worth changing in this case but useful FYI.
> 
> You don't need to write this:
> 
>   if (category.isDebugEnabled()) {
>     category.debug("In ArraySerializer.startElement()");
>   }
> 
> When it could be this:
> 
>   category.debug("In ArraySerializer.startElement()");
> 
> Having just read the log4j docs, the only reason you would check the
> isDebugEnabled() function is when you have an expensive construction as an
> argument to the category call.  I would define "expensive" as more than 1 or
> 2 additions.
> 
> IMHO, having the if clause just clutters up the code.
> 
> See http://jakarta.apache.org/log4j/docs/FAQ.html  - The question "What is
> the fastest way of (not) logging?".
> 
> --
> Tom Jordahl
> 
> 
> -----Original Message-----
> From: dims@apache.org [mailto:dims@apache.org]
> Sent: Thursday, October 18, 2001 10:10 AM
> To: xml-axis-cvs@apache.org
> Subject: cvs commit: xml-axis/java/src/org/apache/axis/utils
> NSStack.java
> 
> 
> dims        01/10/18 07:10:29
> 
>   Modified:    java/src/org/apache/axis SimpleTargetedChain.java
>                java/src/org/apache/axis/encoding ArraySerializer.java
>                         DeserializationContext.java
>                         SerializationContext.java VectorDeserializer.java
>                java/src/org/apache/axis/message BodyBuilder.java
>                         MessageElement.java RPCHandler.java RPCParam.java
>                         SAXOutputter.java SOAPEnvelope.java
>                java/src/org/apache/axis/providers/java JavaProvider.java
>                         RPCProvider.java
>                java/src/org/apache/axis/registries SupplierRegistry.java
>                java/src/org/apache/axis/utils NSStack.java
>   Log:
>   Eliminating DEBUG_LOG+System.out/err.println with log4j's category.
>   
>   Revision  Changes    Path
>   1.23      +1 -1
> xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java
>   
>   Index: SimpleTargetedChain.java
>   ===================================================================
>   RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java,v
>   retrieving revision 1.22
>   retrieving revision 1.23
>   diff -u -r1.22 -r1.23
>   --- SimpleTargetedChain.java	2001/10/16 19:00:02	1.22
>   +++ SimpleTargetedChain.java	2001/10/18 14:10:28	1.23
>   @@ -69,7 +69,7 @@
>     */
>    public class SimpleTargetedChain extends BasicHandler implements
> TargetedChain
>    {
>   -    static Category category =
>   +   static Category category =
>                Category.getInstance(SimpleTargetedChain.class.getName());
>    
>        protected Handler    requestHandler ;
>   
>   
>   
>   1.18      +13 -11
> xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java
>   
>   Index: ArraySerializer.java
>   ===================================================================
>   RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java,v
>   retrieving revision 1.17
>   retrieving revision 1.18
>   diff -u -r1.17 -r1.18
>   --- ArraySerializer.java	2001/10/03 15:30:04	1.17
>   +++ ArraySerializer.java	2001/10/18 14:10:28	1.18
>   @@ -58,6 +58,7 @@
>    import org.apache.axis.Constants;
>    import org.apache.axis.message.SOAPHandler;
>    import org.apache.axis.utils.QName;
>   +import org.apache.log4j.Category;
>    import org.xml.sax.Attributes;
>    import org.xml.sax.SAXException;
>    import org.xml.sax.helpers.AttributesImpl;
>   @@ -79,7 +80,8 @@
>    public class ArraySerializer extends Deserializer
>        implements ValueReceiver, Serializer
>    {
>   -    private final static boolean DEBUG_LOG = false;
>   +    static Category category =
>   +            Category.getInstance(ArraySerializer.class.getName());
>    
>        static Hashtable primitives = new Hashtable();
>        static {
>   @@ -109,8 +111,8 @@
>                                 DeserializationContext context)
>            throws SAXException
>        {
>   -        if (DEBUG_LOG) {
>   -            System.err.println("In ArraySerializer.startElement()");
>   +        if (category.isDebugEnabled()) {
>   +            category.debug("In ArraySerializer.startElement()");
>            }
>    
>            if (attributes.getValue(Constants.URI_CURRENT_SCHEMA_XSI,  "nil")
> != null) {
>   @@ -206,8 +208,8 @@
>  
> rightBracketIndex));
>            }
>            
>   -        if (DEBUG_LOG) {
>   -            System.err.println("Out ArraySerializer.startElement()");
>   +        if (category.isDebugEnabled()) {
>   +            category.debug("Out ArraySerializer.startElement()");
>            }
>        }
>        
>   @@ -218,8 +220,8 @@
>                                        DeserializationContext context)
>            throws SAXException
>        {
>   -        if (DEBUG_LOG) {
>   -            System.err.println("In ArraySerializer.onStartChild()");
>   +        if (category.isDebugEnabled()) {
>   +            category.debug("In ArraySerializer.onStartChild()");
>            }
>            
>            if (attributes != null) {
>   @@ -253,16 +255,16 @@
>                                            getDeserializer(itemType);
>            dSer.registerCallback(this, new Integer(curIndex++));
>            
>   -        if (DEBUG_LOG) {
>   -            System.err.println("Out ArraySerializer.onStartChild()");
>   +        if (category.isDebugEnabled()) {
>   +            category.debug("Out ArraySerializer.onStartChild()");
>            }
>            return dSer;
>        }
>        
>        public void valueReady(Object value, Object hint)
>        {
>   -        if (DEBUG_LOG) {
>   -            System.err.println("ArraySerializer got value [" + hint +
>   +        if (category.isDebugEnabled()) {
>   +            category.debug("ArraySerializer got value [" + hint +
>                                   "] = " + value);
>            }
>            ((ArrayList)this.value).set(((Integer)hint).intValue(), value);
>   
>   
>   
>   1.28      +21 -19
> xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java
>   
>   Index: DeserializationContext.java
>   ===================================================================
>   RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.
> java,v
>   retrieving revision 1.27
>   retrieving revision 1.28
>   diff -u -r1.27 -r1.28
>   --- DeserializationContext.java	2001/10/17 14:01:06	1.27
>   +++ DeserializationContext.java	2001/10/18 14:10:28	1.28
>   @@ -68,6 +68,7 @@
>    import org.apache.axis.utils.NSStack;
>    import org.apache.axis.utils.QName;
>    import org.apache.axis.utils.XMLUtils;
>   +import org.apache.log4j.Category;
>    import org.xml.sax.Attributes;
>    import org.xml.sax.InputSource;
>    import org.xml.sax.Locator;
>   @@ -86,7 +87,8 @@
>    
>    public class DeserializationContext extends DefaultHandler
>    {
>   -    private static final boolean DEBUG_LOG = false;
>   +    static Category category =
>   +            Category.getInstance(DeserializationContext.class.getName());
>        
>        static class LocalIDResolver implements IDResolver
>        {
>   @@ -393,8 +395,8 @@
>        
>        public void pushElementHandler(SOAPHandler handler)
>        {
>   -        if (DEBUG_LOG) {
> 
=== message truncated ===


=====
Davanum Srinivas - http://jguru.com/dims/

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

Mime
View raw message