Author: davidillsley
Date: Thu May 29 06:12:23 2008
New Revision: 661327
URL: http://svn.apache.org/viewvc?rev=661327&view=rev
Log:
*Experimental* LoggingControl for Sandesha2
Added:
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/LoggingControl.java
Modified:
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaOutHandler.java
Modified:
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaOutHandler.java
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaOutHandler.java?rev=661327&r1=661326&r2=661327&view=diff
==============================================================================
---
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaOutHandler.java
(original)
+++
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaOutHandler.java
Thu May 29 06:12:23 2008
@@ -38,6 +38,7 @@
import org.apache.sandesha2.msgprocessors.MsgProcessorFactory;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.util.LoggingControl;
import org.apache.sandesha2.util.MsgInitializer;
import org.apache.sandesha2.util.SandeshaUtil;
@@ -52,7 +53,7 @@
private static final Log log =
LogFactory.getLog(SandeshaOutHandler.class.getName());
public InvocationResponse invoke(MessageContext msgCtx) throws
AxisFault {
- if (log.isDebugEnabled())
+ if (LoggingControl.isAnyTracingEnabled() &&
log.isDebugEnabled())
log.debug("Enter: SandeshaOutHandler::invoke, " +
msgCtx.getEnvelope().getHeader());
InvocationResponse returnValue = InvocationResponse.CONTINUE;
@@ -73,7 +74,7 @@
//see if this message is unreliable i.e. WSRM not requried
if(SandeshaUtil.isMessageUnreliable(msgCtx)) {
- if (log.isDebugEnabled())
+ if (LoggingControl.isAnyTracingEnabled() &&
log.isDebugEnabled())
log.debug("Exit: SandeshaOutHandler::invoke,
Skipping sandesha processing for unreliable message " + returnValue);
return returnValue;
}
@@ -81,7 +82,7 @@
// Also do not apply RM to fault messages
{
if(msgCtx.isProcessingFault()) {
- if(log.isDebugEnabled())
+ if(LoggingControl.isAnyTracingEnabled() &&
log.isDebugEnabled())
log.debug("Exit:
SandeshaOutHandler::invoke, Skipping sandesha processing for fault message " +
returnValue);
return returnValue ;
}
@@ -94,7 +95,7 @@
String DONE = (String)
msgCtx.getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE);
if (null != DONE && "true".equals(DONE)) {
- if (log.isDebugEnabled())
+ if (LoggingControl.isAnyTracingEnabled() &&
log.isDebugEnabled())
log.debug("Exit: SandeshaOutHandler::invoke,
Application processing done " + returnValue);
return returnValue;
}
@@ -111,7 +112,7 @@
MsgProcessor msgProcessor = null;
int messageType = rmMsgCtx.getMessageType();
- if(log.isDebugEnabled()) log.debug("Message Type: " +
messageType);
+ if(LoggingControl.isAnyTracingEnabled() &&
log.isDebugEnabled()) log.debug("Message Type: " + messageType);
if (messageType ==
Sandesha2Constants.MessageTypes.UNKNOWN) {
if (msgCtx.isServerSide()) {
String inboundSequence = (String)
msgCtx.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID);
@@ -145,7 +146,7 @@
//Should be done only to the server side
OperationContext opCtx = msgCtx.getOperationContext();
if(msgCtx.isServerSide() && opCtx != null &&
returnValue == InvocationResponse.SUSPEND) {
- if(log.isDebugEnabled()) log.debug("Setting
HOLD_RESPONSE property");
+ if(LoggingControl.isAnyTracingEnabled() &&
log.isDebugEnabled()) log.debug("Setting HOLD_RESPONSE property");
opCtx.setProperty(RequestResponseTransport.HOLD_RESPONSE, Boolean.TRUE);
}
@@ -176,7 +177,7 @@
}
}
- if (log.isDebugEnabled())
+ if (LoggingControl.isAnyTracingEnabled() &&
log.isDebugEnabled())
log.debug("Exit: SandeshaOutHandler::invoke " +
returnValue);
return returnValue;
}
Added:
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/LoggingControl.java
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/LoggingControl.java?rev=661327&view=auto
==============================================================================
---
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/LoggingControl.java
(added)
+++
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/LoggingControl.java
Thu May 29 06:12:23 2008
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sandesha2.util;
+
+/**
+ * log.isDebugEnabled() can be expensive. This class allows
+ * for another, cheaper call to check if ANY trace or debug
+ * logging is enabled for Sandesha2.
+ *
+ * This is pluggable to allow integration with whatever trace
+ * mechanism is provided by the environment Sandesha2 is
+ * deployed into.
+ *
+ * There is a default controller which simply returns false
+ * which can be engaged by setting the
Sandesha2.LoggingControl.ProhibitDebugLogging
+ * system property.
+ */
+public class LoggingControl {
+
+ public interface LoggingController{
+ public boolean isAnyTracingEnabled();
+ }
+
+ private static class OffController implements LoggingController{
+ public boolean isAnyTracingEnabled() {
+ return false;
+ }
+ }
+
+ private static LoggingController controller;
+
+ static{
+ String prop = null;
+ try {
+ prop =
System.getProperty("Sandesha2.LoggingControl.ProhibitDebugLogging");
+ } catch (SecurityException SE) {
+ //do nothing
+ }
+ if(prop!=null){
+ controller = new OffController();
+ }
+ }
+
+ public static void setController(LoggingController lc){
+ controller = lc;
+ }
+
+ public static boolean isAnyTracingEnabled(){
+ return (controller==null)?true:controller.isAnyTracingEnabled();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]