cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/4] cxf git commit: Add ability to configure in specific providers to use
Date Fri, 20 Mar 2015 18:17:33 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 9de88cce8 -> cc9222b45


Add ability to configure in specific providers to use


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/cc9222b4
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/cc9222b4
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/cc9222b4

Branch: refs/heads/master
Commit: cc9222b453b92f1115d5fc5df2cc11ccb3600940
Parents: fd5abbd
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Mar 20 13:55:03 2015 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Mar 20 14:17:27 2015 -0400

----------------------------------------------------------------------
 .gitignore                                      |  1 +
 .../org/apache/cxf/metrics/MetricsFeature.java  | 18 ++++++-----
 .../AbstractMetricsInterceptor.java             | 32 ++++++++++++--------
 .../MetricsMessageInInterceptor.java            |  5 +--
 .../MetricsMessageInOneWayInterceptor.java      |  5 +--
 .../MetricsMessageInPreInvokeInterceptor.java   |  5 +--
 .../MetricsMessageOutInterceptor.java           |  5 +--
 7 files changed, 43 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/cc9222b4/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 9810ca4..9329527 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 .idea/
+.mvn/
 *.iml
 *.ipr
 *.iws

http://git-wip-us.apache.org/repos/asf/cxf/blob/cc9222b4/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java
----------------------------------------------------------------------
diff --git a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java
b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java
index 9e8b363..79e9fa3 100644
--- a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java
+++ b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java
@@ -34,21 +34,23 @@ import org.apache.cxf.metrics.interceptors.MetricsMessageOutInterceptor;
  */
 @NoJSR250Annotations
 public class MetricsFeature extends AbstractFeature {
-
-    /**
-     * 
-     */
+    final MetricsProvider[] providers;
+    
     public MetricsFeature() {
+        this.providers = null;
+    }
+    public MetricsFeature(MetricsProvider ... providers) {
+        this.providers = providers.length > 0 ? providers : null;
     }
     
     @Override
     protected void initializeProvider(InterceptorProvider provider, Bus bus) {
-        MetricsMessageOutInterceptor out = new MetricsMessageOutInterceptor();
+        MetricsMessageOutInterceptor out = new MetricsMessageOutInterceptor(providers);
         CountingOutInterceptor countingOut = new CountingOutInterceptor();
         
-        provider.getInInterceptors().add(new MetricsMessageInInterceptor());
-        provider.getInInterceptors().add(new MetricsMessageInOneWayInterceptor());
-        provider.getInInterceptors().add(new MetricsMessageInPreInvokeInterceptor());
+        provider.getInInterceptors().add(new MetricsMessageInInterceptor(providers));
+        provider.getInInterceptors().add(new MetricsMessageInOneWayInterceptor(providers));
+        provider.getInInterceptors().add(new MetricsMessageInPreInvokeInterceptor(providers));
         provider.getOutInterceptors().add(countingOut);
         provider.getOutInterceptors().add(out);
         provider.getOutFaultInterceptors().add(countingOut);

http://git-wip-us.apache.org/repos/asf/cxf/blob/cc9222b4/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/AbstractMetricsInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/AbstractMetricsInterceptor.java
b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/AbstractMetricsInterceptor.java
index 97eeb2d..dd9cc62 100644
--- a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/AbstractMetricsInterceptor.java
+++ b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/AbstractMetricsInterceptor.java
@@ -21,8 +21,12 @@ package org.apache.cxf.metrics.interceptors;
 
 import java.io.Closeable;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.configuration.ConfiguredBeanLocator;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
@@ -37,9 +41,21 @@ import org.apache.cxf.service.model.BindingOperationInfo;
 
 
 public abstract class AbstractMetricsInterceptor extends AbstractPhaseInterceptor<Message>
{
-
-    public AbstractMetricsInterceptor(String phase) {
+    MetricsProvider providers[];
+    public AbstractMetricsInterceptor(String phase, MetricsProvider p[]) {
         super(phase);
+        providers = p;
+    }
+    
+    protected Collection<? extends MetricsProvider> getMetricProviders(Bus bus) {
+        if (providers != null) {
+            return Arrays.asList(providers);
+        }
+        ConfiguredBeanLocator b = bus.getExtension(ConfiguredBeanLocator.class);
+        if (b == null) {
+            return Collections.emptyList();
+        }
+        return b.getBeansOfType(MetricsProvider.class);
     }
     
     protected ExchangeMetrics getExchangeMetrics(Message m, boolean create) {
@@ -75,12 +91,8 @@ public abstract class AbstractMetricsInterceptor extends AbstractPhaseIntercepto
         final Endpoint ep = m.getExchange().getEndpoint();
         Object o = ep.get(MetricsContext.class.getName());
         if (o == null) {
-            ConfiguredBeanLocator b = m.getExchange().getBus().getExtension(ConfiguredBeanLocator.class);
-            if (b == null) {
-                return null;
-            }
             List<MetricsContext> contexts = new ArrayList<MetricsContext>();
-            for (MetricsProvider p : b.getBeansOfType(MetricsProvider.class)) {
+            for (MetricsProvider p : getMetricProviders(m.getExchange().getBus())) {
                 MetricsContext c = p.createEndpointContext(ep, MessageUtils.isRequestor(m));
                 if (c != null) {
                     contexts.add(c);
@@ -122,12 +134,8 @@ public abstract class AbstractMetricsInterceptor extends AbstractPhaseIntercepto
     private Object createMetricsContextForOperation(Message message, BindingOperationInfo
boi) {
         Object o = boi.getProperty(MetricsContext.class.getName());
         if (o == null) {
-            ConfiguredBeanLocator b = message.getExchange().getBus().getExtension(ConfiguredBeanLocator.class);
-            if (b == null) {
-                return null;
-            }
             List<MetricsContext> contexts = new ArrayList<MetricsContext>();
-            for (MetricsProvider p : b.getBeansOfType(MetricsProvider.class)) {
+            for (MetricsProvider p : getMetricProviders(message.getExchange().getBus()))
{
                 MetricsContext c = p.createOperationContext(message.getExchange().getEndpoint(),
                                                             boi, MessageUtils.isRequestor(message));
                 if (c != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/cc9222b4/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInInterceptor.java
b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInInterceptor.java
index 75d6f5c..6afc5c8 100644
--- a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInInterceptor.java
+++ b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInInterceptor.java
@@ -24,11 +24,12 @@ import org.apache.cxf.interceptor.AttachmentInInterceptor;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.metrics.ExchangeMetrics;
+import org.apache.cxf.metrics.MetricsProvider;
 import org.apache.cxf.phase.Phase;
 
 public class MetricsMessageInInterceptor extends AbstractMetricsInterceptor {
-    public MetricsMessageInInterceptor() {
-        super(Phase.RECEIVE);
+    public MetricsMessageInInterceptor(MetricsProvider p[]) {
+        super(Phase.RECEIVE, p);
         addBefore(AttachmentInInterceptor.class.getName());
     }
     public void handleMessage(Message message) throws Fault {

http://git-wip-us.apache.org/repos/asf/cxf/blob/cc9222b4/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInOneWayInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInOneWayInterceptor.java
b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInOneWayInterceptor.java
index 9f99954..1ded851 100644
--- a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInOneWayInterceptor.java
+++ b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInOneWayInterceptor.java
@@ -22,11 +22,12 @@ import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.ServiceInvokerInterceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.metrics.MetricsProvider;
 import org.apache.cxf.phase.Phase;
 
 public class MetricsMessageInOneWayInterceptor extends AbstractMetricsInterceptor {
-    public MetricsMessageInOneWayInterceptor() {
-        super(Phase.INVOKE);
+    public MetricsMessageInOneWayInterceptor(MetricsProvider p[]) {
+        super(Phase.INVOKE, p);
         addAfter(ServiceInvokerInterceptor.class.getName());
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/cc9222b4/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInPreInvokeInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInPreInvokeInterceptor.java
b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInPreInvokeInterceptor.java
index f614ffb..926a492 100644
--- a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInPreInvokeInterceptor.java
+++ b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageInPreInvokeInterceptor.java
@@ -22,12 +22,13 @@ import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.metrics.ExchangeMetrics;
+import org.apache.cxf.metrics.MetricsProvider;
 import org.apache.cxf.phase.Phase;
 
 public class MetricsMessageInPreInvokeInterceptor extends AbstractMetricsInterceptor {
 
-    public MetricsMessageInPreInvokeInterceptor() {
-        super(Phase.PRE_INVOKE);
+    public MetricsMessageInPreInvokeInterceptor(MetricsProvider p[]) {
+        super(Phase.PRE_INVOKE, p);
     }
 
     public void handleMessage(Message message) throws Fault {

http://git-wip-us.apache.org/repos/asf/cxf/blob/cc9222b4/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageOutInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageOutInterceptor.java
b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageOutInterceptor.java
index c993a2a..29186ba 100644
--- a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageOutInterceptor.java
+++ b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/interceptors/MetricsMessageOutInterceptor.java
@@ -21,11 +21,12 @@ package org.apache.cxf.metrics.interceptors;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.MessageSenderInterceptor;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.metrics.MetricsProvider;
 import org.apache.cxf.phase.Phase;
 
 public class MetricsMessageOutInterceptor extends AbstractMetricsInterceptor {
-    public MetricsMessageOutInterceptor() {
-        super(Phase.PREPARE_SEND_ENDING);
+    public MetricsMessageOutInterceptor(MetricsProvider p[]) {
+        super(Phase.PREPARE_SEND_ENDING, p);
         addBefore(MessageSenderInterceptor.MessageSenderEndingInterceptor.class.getName());
     }
     public void handleMessage(Message message) throws Fault {


Mime
View raw message