commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nico...@apache.org
Subject svn commit: r742334 - in /commons/sandbox/monitoring/branches/modules/instrumentation: ./ src/main/java/org/apache/commons/monitoring/instrumentation/cxf/
Date Mon, 09 Feb 2009 08:52:21 GMT
Author: nicolas
Date: Mon Feb  9 08:52:21 2009
New Revision: 742334

URL: http://svn.apache.org/viewvc?rev=742334&view=rev
Log:
support for cxf as Servlet (use pathInfo as monitor name)

Added:
    commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/HttpMonitoringInInterceptor.java
Modified:
    commons/sandbox/monitoring/branches/modules/instrumentation/pom.xml
    commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringInInterceptor.java
    commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringOutInterceptor.java

Modified: commons/sandbox/monitoring/branches/modules/instrumentation/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/instrumentation/pom.xml?rev=742334&r1=742333&r2=742334&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/instrumentation/pom.xml (original)
+++ commons/sandbox/monitoring/branches/modules/instrumentation/pom.xml Mon Feb  9 08:52:21
2009
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
     <artifactId>commons-monitoring-parent</artifactId>
     <groupId>org.apache.commons.monitoring</groupId>
@@ -10,9 +11,9 @@
   <version>1.0-SNAPSHOT</version>
   <dependencies>
     <dependency>
-        <groupId>org.apache.commons.monitoring</groupId>
-        <artifactId>commons-monitoring-core</artifactId>
-        <version>${project.version}</version>
+      <groupId>org.apache.commons.monitoring</groupId>
+      <artifactId>commons-monitoring-core</artifactId>
+      <version>${project.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
@@ -34,10 +35,16 @@
       <optional>true</optional>
     </dependency>
     <dependency>
-    	<groupId>org.apache.cxf</groupId>
-    	<artifactId>cxf-rt-bindings-soap</artifactId>
-    	<version>2.1.3</version>
-    	<optional>true</optional>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-bindings-soap</artifactId>
+      <version>2.1.3</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-transports-http</artifactId>
+      <version>2.1.3</version>
+      <optional>true</optional>
     </dependency>
   </dependencies>
 </project>
\ No newline at end of file

Added: commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/HttpMonitoringInInterceptor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/HttpMonitoringInInterceptor.java?rev=742334&view=auto
==============================================================================
--- commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/HttpMonitoringInInterceptor.java
(added)
+++ commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/HttpMonitoringInInterceptor.java
Mon Feb  9 08:52:21 2009
@@ -0,0 +1,62 @@
+/*
+ * 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.commons.monitoring.instrumentation.cxf;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+
+/**
+ * A variant of MonitoringInInterceptor dedicated to web service endpoint based on HttpServlet
- most commonly used, but
+ * not required.
+ * <p>
+ * When no SOAPAction Header is set, the monitor name is extracted from servlet PathInfo
+ * 
+ * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
+ */
+public class HttpMonitoringInInterceptor
+    extends MonitoringInInterceptor
+{
+    public HttpMonitoringInInterceptor()
+    {
+        super();
+    }
+
+    public HttpMonitoringInInterceptor( String phase )
+    {
+        super( phase );
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.apache.commons.monitoring.instrumentation.cxf.MonitoringInInterceptor#getMonitorName(org.apache.cxf.binding.soap.SoapMessage)
+     */
+    @Override
+    protected String getMonitorName( SoapMessage message )
+    {
+        String soapAction = getSoapAction( message );
+        if ( soapAction != null )
+        {
+            return soapAction;
+        }
+        HttpServletRequest request = (HttpServletRequest) message.get( AbstractHTTPDestination.HTTP_REQUEST
);
+        return request.getPathInfo();
+    }
+}

Modified: commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringInInterceptor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringInInterceptor.java?rev=742334&r1=742333&r2=742334&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringInInterceptor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringInInterceptor.java
Mon Feb  9 08:52:21 2009
@@ -35,6 +35,10 @@
 import org.apache.cxf.phase.Phase;
 
 /**
+ * A CXF Interceptor to apply monitoring on incoming messages.
+ * <p>
+ * The monitor name is set based on message SOAPAction header (if set).
+ * 
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
 public class MonitoringInInterceptor
@@ -51,25 +55,58 @@
         super( Phase.READ );
     }
 
+    public MonitoringInInterceptor( String phase )
+    {
+        super( phase );
+    }
+
     public void handleMessage( SoapMessage message )
         throws Fault
     {
-        Monitor monitor = getMonitor( message );
+        Monitor monitor =
+            repository.getMonitor( getMonitorName( message ), getMonitorCategory( message
), getMonitorDomain( message ) );
         StopWatch stopWatch = repository.start( monitor );
         message.getExchange().put( StopWatch.class, stopWatch );
     }
 
     /**
-     * Select a Monitor for the incoming message.
+     * Detect the monitor name from incoming message
+     * <p>
+     * May be overriden to use another Strategy to attach a Monitor to a SoapMessage
+     * 
+     * @param message
+     * @return
+     */
+    protected String getMonitorName( SoapMessage message )
+    {
+        String soapAction = getSoapAction( message );
+        return soapAction != null ? soapAction : "unknown";
+    }
+
+    /**
+     * Detect the monitor domain from incoming message
+     * <p>
+     * May be overriden to use another Strategy to attach a Monitor to a SoapMessage
+     * 
+     * @param message
+     * @return
+     */
+    protected String getMonitorDomain( SoapMessage message )
+    {
+        return domain;
+    }
+
+    /**
+     * Detect the monitor category from incoming message
      * <p>
      * May be overriden to use another Strategy to attach a Monitor to a SoapMessage
      * 
-     * @param message Soap IN message
-     * @return Monitor
+     * @param message
+     * @return
      */
-    protected Monitor getMonitor( SoapMessage message )
+    protected String getMonitorCategory( SoapMessage message )
     {
-        return repository.getMonitor( getSoapAction( message ), category, domain );
+        return category;
     }
 
     /**
@@ -126,7 +163,7 @@
                 }
             }
         }
-        return "unknown";
+        return null;
     }
 
     public void handleFault( SoapMessage message )

Modified: commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringOutInterceptor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringOutInterceptor.java?rev=742334&r1=742333&r2=742334&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringOutInterceptor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/cxf/MonitoringOutInterceptor.java
Mon Feb  9 08:52:21 2009
@@ -35,6 +35,12 @@
         super( Phase.SEND );
     }
 
+
+    public MonitoringOutInterceptor( String phase )
+    {
+        super( phase );
+    }
+
     public void handleMessage( SoapMessage message )
         throws Fault
     {
@@ -49,7 +55,7 @@
 
     protected final long stop( SoapMessage message )
     {
-        StopWatch stopWatch = (StopWatch) message.getExchange().get( StopWatch.class );
+        StopWatch stopWatch = message.getExchange().get( StopWatch.class );
         if ( stopWatch != null )
         {
             stopWatch.stop();



Mime
View raw message