Author: veithen
Date: Fri Dec 16 21:25:26 2011
New Revision: 1215284

URL: http://svn.apache.org/viewvc?rev=1215284&view=rev
Log:
Ensure that log levels can be changed at runtime.

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OptimizationPolicyImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXUtils.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java?rev=1215284&r1=1215283&r2=1215284&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java
 Fri Dec 16 21:25:26 2011
@@ -53,7 +53,6 @@ import org.apache.commons.logging.LogFac
 public class MIMEOutputUtils {
     
     private static final Log log = LogFactory.getLog(MIMEOutputUtils.class);
-    private static boolean isDebugEnabled = log.isDebugEnabled();
 
     private static byte[] CRLF = { 13, 10 };
 
@@ -83,9 +82,7 @@ public class MIMEOutputUtils {
                                 String SOAPContentType, 
                                 OMOutputFormat omOutputFormat) {
         try {
-            if (isDebugEnabled) {
-                log.debug("Start: write the SOAPPart and the attachments");
-            }
+            log.debug("Start: write the SOAPPart and the attachments");
             
             // Write out the mime boundary
             startWritingMime(outStream, boundary);
@@ -116,9 +113,7 @@ public class MIMEOutputUtils {
             }
             finishWritingMime(outStream);
             outStream.flush();
-            if (isDebugEnabled) {
-                log.debug("End: write the SOAPPart and the attachments");
-            }
+            log.debug("End: write the SOAPPart and the attachments");
         } catch (IOException e) {
             throw new OMException("Error while writing to the OutputStream.", 
e);
         } catch (MessagingException e) {
@@ -153,7 +148,7 @@ public class MIMEOutputUtils {
             contentTransferEncoding = 
configurableDataHandler.getTransferEncoding();
         }
         
-        if (isDebugEnabled) {
+        if (log.isDebugEnabled()) {
             log.debug("Create MimeBodyPart");
             log.debug("  Content-ID = " + contentID);
             log.debug("  Content-Type = " + contentType);
@@ -167,7 +162,7 @@ public class MIMEOutputUtils {
         if (useCTEBase64) {
             if (!CommonUtils.isTextualPart(contentType) && 
                 "binary".equals(contentTransferEncoding)) {
-                if (isDebugEnabled) {
+                if (log.isDebugEnabled()) {
                     log.debug(" changing Content-Transfer-Encoding from " + 
                               contentTransferEncoding + " to base-64");
                 }
@@ -215,7 +210,7 @@ public class MIMEOutputUtils {
                                      MimeBodyPart part,
                                      String boundary) throws IOException,
             MessagingException {
-        if (isDebugEnabled) {
+        if (log.isDebugEnabled()) {
             log.debug("Start writeMimeBodyPart for " + part.getContentID());
         }
         outStream.write(CRLF);
@@ -223,9 +218,7 @@ public class MIMEOutputUtils {
         outStream.write(CRLF);
         writeMimeBoundary(outStream, boundary);
         outStream.flush();
-        if (isDebugEnabled) {
-            log.debug("End writeMimeBodyPart");
-        }
+        log.debug("End writeMimeBodyPart");
     }
 
     /**
@@ -233,9 +226,7 @@ public class MIMEOutputUtils {
      */
     public static void finishWritingMime(OutputStream outStream)
             throws IOException {
-        if (isDebugEnabled) {
-            log.debug("Write --, which indicates the end of the last 
boundary");
-        }
+        log.debug("Write --, which indicates the end of the last boundary");
         outStream.write(new byte[] { 45, 45 });
     }
 

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java?rev=1215284&r1=1215283&r2=1215284&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java
 Fri Dec 16 21:25:26 2011
@@ -80,8 +80,6 @@ public class MTOMXMLStreamWriter impleme
     }
     
     private static final Log log = 
LogFactory.getLog(MTOMXMLStreamWriter.class);
-    private static boolean isDebugEnabled = log.isDebugEnabled();
-    private static boolean isTraceEnabled = log.isTraceEnabled();
     private XMLStreamWriter xmlWriter;
     private OutputStream outStream;
     private List/*<Part>*/ otherParts = new LinkedList();
@@ -101,7 +99,7 @@ public class MTOMXMLStreamWriter impleme
 
     public MTOMXMLStreamWriter(XMLStreamWriter xmlWriter) {
         this.xmlWriter = xmlWriter;
-        if (isTraceEnabled) {
+        if (log.isTraceEnabled()) {
             log.trace("Call Stack =" + CommonUtils.callStackToString());
         }
         optimizationPolicy = new OptimizationPolicyImpl(format);
@@ -129,13 +127,13 @@ public class MTOMXMLStreamWriter impleme
      */
     public MTOMXMLStreamWriter(OutputStream outStream, OMOutputFormat format, 
boolean preserveAttachments)
             throws XMLStreamException, FactoryConfigurationError {
-        if (isDebugEnabled) {
+        if (log.isDebugEnabled()) {
             log.debug("Creating MTOMXMLStreamWriter");
             log.debug("OutputStream =" + outStream.getClass());
             log.debug("OMFormat = " + format.toString());
             log.debug("preserveAttachments = " + preserveAttachments);
         }
-        if (isTraceEnabled) {
+        if (log.isTraceEnabled()) {
             log.trace("Call Stack =" + CommonUtils.callStackToString());
         }
         this.format = format;
@@ -213,18 +211,14 @@ public class MTOMXMLStreamWriter impleme
     }
 
     public void writeEndDocument() throws XMLStreamException {
-        if (isDebugEnabled) {
-            log.debug("writeEndDocument");
-        }
+        log.debug("writeEndDocument");
         xmlWriter.writeEndDocument();
         isEndDocument = true; 
     }
 
     public void close() throws XMLStreamException {
         // TODO: we should probably call flush if the attachments have not 
been written yet
-        if (isDebugEnabled) {
-            log.debug("close");
-        }
+        log.debug("close");
         xmlWriter.close();
     }
 
@@ -232,17 +226,13 @@ public class MTOMXMLStreamWriter impleme
      * Flush is overridden to trigger the attachment serialization
      */
     public void flush() throws XMLStreamException {
-        if (isDebugEnabled) {
-            log.debug("Calling MTOMXMLStreamWriter.flush");
-        }
+        log.debug("Calling MTOMXMLStreamWriter.flush");
         xmlWriter.flush();
         // flush() triggers the optimized attachment writing.
         // If the optimized attachments are specified, and the xml
         // document is completed, then write out the attachments.
         if (format.isOptimized() && !isComplete & (isEndDocument || depth == 
0)) {
-            if (isDebugEnabled) {
-                log.debug("The XML writing is completed.  Now the attachments 
are written");
-            }
+            log.debug("The XML writing is completed.  Now the attachments are 
written");
             isComplete = true;
             try {
                 rootPartOutputStream.close();
@@ -391,13 +381,9 @@ public class MTOMXMLStreamWriter impleme
      * possible, then {@link #prepareDataHandler(DataHandler)} should be used.
      */
     public void writeOptimized(OMText node) {
-        if(isDebugEnabled){
-            log.debug("Start MTOMXMLStreamWriter.writeOptimized()");
-        }
+        log.debug("Start MTOMXMLStreamWriter.writeOptimized()");
         otherParts.add(new Part(node.getContentID(), 
(DataHandler)node.getDataHandler()));    
-        if(isDebugEnabled){
-            log.debug("Exit MTOMXMLStreamWriter.writeOptimized()");
-        }
+        log.debug("Exit MTOMXMLStreamWriter.writeOptimized()");
     }
 
     /**
@@ -571,7 +557,7 @@ public class MTOMXMLStreamWriter impleme
             os = outStream;
         }
         
-        if (isDebugEnabled) {
+        if (log.isDebugEnabled()) {
             if (os == null) {
                 log.debug("Direct access to the output stream is not 
available.");
             } else if (rootPartOutputStream != null) {

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OptimizationPolicyImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OptimizationPolicyImpl.java?rev=1215284&r1=1215283&r2=1215284&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OptimizationPolicyImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OptimizationPolicyImpl.java
 Fri Dec 16 21:25:26 2011
@@ -38,7 +38,6 @@ import org.apache.commons.logging.LogFac
  */
 class OptimizationPolicyImpl implements OptimizationPolicy {
     private static final Log log = 
LogFactory.getLog(OptimizationPolicyImpl.class);
-    private static boolean isDebugEnabled = log.isDebugEnabled();
     
     private final OMOutputFormat format;
 
@@ -56,20 +55,14 @@ class OptimizationPolicyImpl implements 
         
         // TODO: this needs review and cleanup
         // ** START **  code from MTOMXMLStreamWriter#isOptimizedThreshold
-        if(isDebugEnabled){
-            log.debug("Start MTOMXMLStreamWriter.isOptimizedThreshold()");
-        }
+        log.debug("Start MTOMXMLStreamWriter.isOptimizedThreshold()");
         int optimized = UNSUPPORTED;
         if(dataHandler!=null){
-            if(isDebugEnabled){
-                log.debug("DataHandler fetched, starting optimized Threshold 
processing");
-            }
+            log.debug("DataHandler fetched, starting optimized Threshold 
processing");
             optimized= BufferUtils.doesDataHandlerExceedLimit(dataHandler, 
format.getOptimizedThreshold());
         }
         if(optimized == UNSUPPORTED || optimized == EXCEED_LIMIT){
-            if(log.isDebugEnabled()){
-                log.debug("node should be added to binart NodeList for 
optimization");
-            }
+            log.debug("node should be added to binart NodeList for 
optimization");
             return true;
         }
         return false;

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXUtils.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXUtils.java?rev=1215284&r1=1215283&r2=1215284&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXUtils.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXUtils.java
 Fri Dec 16 21:25:26 2011
@@ -89,7 +89,6 @@ import java.util.WeakHashMap;
  */
 public class StAXUtils {
     private static final Log log = LogFactory.getLog(StAXUtils.class);
-    private static boolean isDebugEnabled = log.isDebugEnabled();
     
     // If isFactoryPerClassLoader is true (default), then 
     // a separate singleton XMLInputFactory and XMLOutputFactory is maintained
@@ -203,7 +202,7 @@ public class StAXUtils {
                     }
                 }
                 );
-            if (isDebugEnabled) {
+            if (log.isDebugEnabled()) {
                 log.debug("XMLStreamReader is " + reader.getClass().getName());
             }
             return reader;
@@ -232,7 +231,7 @@ public class StAXUtils {
                 }
                 );
             
-            if (isDebugEnabled) {
+            if (log.isDebugEnabled()) {
                 log.debug("XMLStreamReader is " + reader.getClass().getName());
             }
             return reader;
@@ -260,7 +259,7 @@ public class StAXUtils {
                     }
                 }
                 );
-            if (isDebugEnabled) {
+            if (log.isDebugEnabled()) {
                 log.debug("XMLStreamReader is " + reader.getClass().getName());
             }
             return reader;
@@ -366,7 +365,7 @@ public class StAXUtils {
                 }
                 );
                 
-            if (isDebugEnabled) {
+            if (log.isDebugEnabled()) {
                 log.debug("XMLStreamWriter is " + writer.getClass().getName());
             }
             return writer;
@@ -394,7 +393,7 @@ public class StAXUtils {
                 }
                 );
             
-            if (isDebugEnabled) {
+            if (log.isDebugEnabled()) {
                 log.debug("XMLStreamWriter is " + writer.getClass().getName());
             }
             return writer;
@@ -421,7 +420,7 @@ public class StAXUtils {
                     }
                 }
                 );
-            if (isDebugEnabled) {
+            if (log.isDebugEnabled()) {
                 log.debug("XMLStreamWriter is " + writer.getClass().getName());
             }
             return writer;

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java?rev=1215284&r1=1215283&r2=1215284&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
 Fri Dec 16 21:25:26 2011
@@ -102,7 +102,6 @@ public class StAXSOAPModelBuilder extend
     private SOAPBuilderHelper builderHelper;
 
     private String parserVersion = null;
-    private static final boolean isDebugEnabled = log.isDebugEnabled();
     
     /**
      * Constructor.
@@ -269,7 +268,7 @@ public class StAXSOAPModelBuilder extend
             e.setFirstChild(node);
         }
 
-        if (isDebugEnabled) {
+        if (log.isDebugEnabled()) {
             log.debug("Build the OMElement " + node.getLocalName() +
                     " by the StaxSOAPModelBuilder");
         }
@@ -307,14 +306,10 @@ public class StAXSOAPModelBuilder extend
                 namespaceURI = this.parser.getNamespaceURI();
                 if 
(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
                     soapFactory = metaFactory.getSOAP12Factory();
-                    if (isDebugEnabled) {
-                        log.debug("Starting to process SOAP 1.2 message");
-                    }
+                    log.debug("Starting to process SOAP 1.2 message");
                 } else if 
(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
                     soapFactory = metaFactory.getSOAP11Factory();
-                    if (isDebugEnabled) {
-                        log.debug("Starting to process SOAP 1.1 message");
-                    }
+                    log.debug("Starting to process SOAP 1.1 message");
                 } else {
                     throw new SOAPProcessingException(
                             "Only SOAP 1.1 or SOAP 1.2 messages are supported 
in the" +

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java?rev=1215284&r1=1215283&r2=1215284&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
 Fri Dec 16 21:25:26 2011
@@ -51,7 +51,6 @@ import javax.xml.stream.XMLStreamWriter;
 public class SOAPEnvelopeImpl extends SOAPElement
         implements SOAPEnvelope, OMConstants {
     private static final Log log = LogFactory.getLog(SOAPEnvelopeImpl.class);
-    private static final boolean isDebugEnabled = log.isDebugEnabled();
 
     /**
      * Constructor
@@ -253,18 +252,18 @@ public class SOAPEnvelopeImpl extends SO
             // TODO: should use 'instance of OMXMLParserWrapper' instead?  
StAXBuilder is more generic
             if ((builder != null) && (builder instanceof StAXBuilder)) {
                 try {
-                    if (isDebugEnabled) {
+                    if (log.isDebugEnabled()) {
                         log.debug("closing builder: " + builder);
                     }
                     StAXBuilder staxBuilder = (StAXBuilder) builder;
                     staxBuilder.close();
                 } catch (Exception e) {
-                    if (isDebugEnabled) {
+                    if (log.isDebugEnabled()) {
                         log.error("Could not close builder or parser due to: 
", e);
                     }
                 }
             } else {
-                if (isDebugEnabled) {
+                if (log.isDebugEnabled()) {
                     log.debug("Could not close builder or parser due to:");
                     if (builder == null) {
                         log.debug("builder is null");


Reply via email to