cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject git commit: [CXF-6028] Add a new optional "Metrics" stuff in rt-management based on codahale metrics library.
Date Fri, 26 Sep 2014 18:28:07 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 47b57d723 -> 99963f9a0


[CXF-6028] Add a new optional "Metrics" stuff in rt-management based on codahale metrics library.


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

Branch: refs/heads/master
Commit: 99963f9a08c9782b7c661f2b5ff8e9ce95ab3dbe
Parents: 47b57d7
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Sep 26 14:27:08 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Sep 26 14:27:57 2014 -0400

----------------------------------------------------------------------
 .../src/main/release/samples/wsdl_first/pom.xml |  41 +++
 .../resources/server-applicationContext.xml     |  23 +-
 rt/management/pom.xml                           |   7 +
 .../apache/cxf/management/codahale/Metrics.java | 338 +++++++++++++++++++
 .../apache/cxf/management/counters/Counter.java |   2 +
 .../AbstractMessageResponseTimeInterceptor.java |   3 +-
 .../jmx/InstrumentationManagerImpl.java         |  17 +-
 .../jmx/JMXManagedComponentManagerTest.java     |   2 -
 8 files changed, 420 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/99963f9a/distribution/src/main/release/samples/wsdl_first/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/wsdl_first/pom.xml b/distribution/src/main/release/samples/wsdl_first/pom.xml
index a69d99f..ce78ec4 100644
--- a/distribution/src/main/release/samples/wsdl_first/pom.xml
+++ b/distribution/src/main/release/samples/wsdl_first/pom.xml
@@ -126,6 +126,36 @@
             </dependencies>
         </profile>
         <profile>
+            <id>server-spring</id>
+            <build>
+                <defaultGoal>test</defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>exec-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>java</goal>
+                                </goals>
+                                <configuration>
+                                    <mainClass>com.example.customerservice.server.CustomerServiceSpringServer</mainClass>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-rt-transports-http-jetty</artifactId>
+                    <version>${project.version}</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
             <id>server-netty</id>
             <build>
                 <defaultGoal>test</defaultGoal>
@@ -227,6 +257,11 @@
             <version>3.1.0-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-management</artifactId>
+            <version>3.1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.cxf.xjc-utils</groupId>
             <artifactId>cxf-xjc-runtime</artifactId>
             <version>${cxf.xjc-utils.version}</version>
@@ -240,5 +275,11 @@
             <artifactId>junit</artifactId>
             <scope>compile</scope>
         </dependency>
+        
+        <dependency>
+           <groupId>io.dropwizard.metrics</groupId>
+           <artifactId>metrics-core</artifactId>
+           <version>3.1.0</version>
+        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/99963f9a/distribution/src/main/release/samples/wsdl_first/src/main/resources/server-applicationContext.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/wsdl_first/src/main/resources/server-applicationContext.xml
b/distribution/src/main/release/samples/wsdl_first/src/main/resources/server-applicationContext.xml
index cac855a..59b247d 100644
--- a/distribution/src/main/release/samples/wsdl_first/src/main/resources/server-applicationContext.xml
+++ b/distribution/src/main/release/samples/wsdl_first/src/main/resources/server-applicationContext.xml
@@ -14,7 +14,28 @@
                 the specific language governing permissions and limitations under the
                 License.
         -->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd                 http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd                 http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd                 http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
">
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
+    xmlns:cxf="http://cxf.apache.org/core"
+    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd        
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd ">
+    
+    <cxf:bus name="cxf"/>
+    
+    <bean id="org.apache.cxf.management.InstrumentationManager" class="org.apache.cxf.management.jmx.InstrumentationManagerImpl"
+        init-method="init">
+        <property name="enabled" value="true"/>
+        <property name="usePlatformMBeanServer" value="true"/>
+        <property name="bus" ref="cxf"/>
+    </bean>
+    <bean id="org.apache.cxf.management.counters.CounterRepository" class="org.apache.cxf.management.counters.CounterRepository">
+        <property name="bus" ref="cxf"/>
+        
+    </bean>
+    <bean id="org.apache.cxf.management.codahale.Metrics" class="org.apache.cxf.management.codahale.Metrics">
+        <property name="bus" ref="cxf"/>
+        
+    </bean>
+    
+    
     <!-- HTTP Endpoint -->
     <jaxws:endpoint xmlns:customer="http://customerservice.example.com/" id="CustomerServiceHTTP"
address="http://localhost:9090/CustomerServicePort" serviceName="customer:CustomerServiceService"
endpointName="customer:CustomerServiceEndpoint" implementor="com.example.customerservice.server.CustomerServiceImpl">
         <jaxws:features>

http://git-wip-us.apache.org/repos/asf/cxf/blob/99963f9a/rt/management/pom.xml
----------------------------------------------------------------------
diff --git a/rt/management/pom.xml b/rt/management/pom.xml
index 17a88c2..b6f5362 100644
--- a/rt/management/pom.xml
+++ b/rt/management/pom.xml
@@ -42,6 +42,12 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
+            <groupId>io.dropwizard.metrics</groupId>
+            <artifactId>metrics-core</artifactId>
+            <version>3.1.0</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>jcl-over-slf4j</artifactId>
             <scope>test</scope>
@@ -72,6 +78,7 @@
             <artifactId>easymock</artifactId>
             <scope>test</scope>
         </dependency>
+        
     </dependencies>
     <build>
         <plugins>

http://git-wip-us.apache.org/repos/asf/cxf/blob/99963f9a/rt/management/src/main/java/org/apache/cxf/management/codahale/Metrics.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/codahale/Metrics.java b/rt/management/src/main/java/org/apache/cxf/management/codahale/Metrics.java
new file mode 100644
index 0000000..7bb5517
--- /dev/null
+++ b/rt/management/src/main/java/org/apache/cxf/management/codahale/Metrics.java
@@ -0,0 +1,338 @@
+/**
+ * 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.cxf.management.codahale;
+
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.JmxReporter;
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.ObjectNameFactory;
+import com.codahale.metrics.Timer;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.AttachmentInInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.MessageSenderInterceptor;
+import org.apache.cxf.interceptor.ServiceInvokerInterceptor;
+import org.apache.cxf.management.InstrumentationManager;
+import org.apache.cxf.management.ManagementConstants;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.FaultMode;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingOperationInfo;
+
+public class Metrics {
+    private static final String QUESTION_MARK = "?";
+    private static final String ESCAPED_QUESTION_MARK = "\\?";
+    
+    private MetricRegistry registry;
+    private Bus bus;
+    
+    public Metrics() {
+        registry = new MetricRegistry();
+    }
+    public Metrics(MetricRegistry reg) {
+        registry = reg;
+    }
+    
+    public void setBus(Bus b) {
+        bus = b;
+        if (bus != null) {
+            registerInterceptorsToBus();
+        }
+        InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
+        if (im != null) {
+            JmxReporter reporter = JmxReporter.forRegistry(registry).registerWith(im.getMBeanServer())
+                .inDomain("org.apache.cxf")
+                .createsObjectNamesWith(new ObjectNameFactory() {
+                    public ObjectName createName(String type, String domain, String name)
{
+                        try {
+                            return new ObjectName(name);
+                        } catch (MalformedObjectNameException e) {
+                            throw new RuntimeException(e);
+                        }
+                    }
+                })
+                .build();
+            reporter.start();
+        }
+    }
+
+    public Bus getBus() {
+        return bus;
+    }
+            
+    void registerInterceptorsToBus() {
+        ResponseTimeMessageInInterceptor in = new ResponseTimeMessageInInterceptor();
+        ResponseTimeMessageInOneWayInterceptor oneway = new ResponseTimeMessageInOneWayInterceptor();
+        ResponseTimeMessageOutInterceptor out = new ResponseTimeMessageOutInterceptor();
+        //ResponseTimeMessageInvokerInterceptor invoker = new ResponseTimeMessageInvokerInterceptor();
+        
+        bus.getInInterceptors().add(in);
+        bus.getInInterceptors().add(oneway);
+        bus.getOutInterceptors().add(out);
+        bus.getOutFaultInterceptors().add(out);
+        //bus.setExtension(this, CounterRepository.class); 
+        
+        //create CounterRepositroyMoniter to writer the counter log
+        
+        //if the service is stopped or removed, the counters should remove itself
+    }
+    
+    static class TimerInfo {
+        Counter inFlight;
+        Timer totals;
+        Timer uncheckedApplicationFaults;
+        Timer checkedApplicationFaults;
+        Timer runtimeFaults;
+        Timer logicalRuntimeFaults;
+     
+        Context start() {
+            inFlight.inc();
+            Context ctx = new Context();
+            ctx.info = this;
+            ctx.t = totals.time();
+            return ctx;
+        }
+        static class Context {
+            TimerInfo info;
+            Timer.Context t;
+        }
+    }
+    
+    TimerInfo getTimerInfo(Message message) {
+        TimerInfo ti = (TimerInfo)message.getExchange().getEndpoint().get(TimerInfo.class.getName());
+        if (ti == null) {
+            synchronized (message.getExchange().getEndpoint()) {
+                return createTimerInfo(message);
+            }
+        }
+        return ti;
+    }
+    TimerInfo getTimerInfo(Message message, BindingOperationInfo boi) {
+        if (boi.isUnwrapped()) {
+            boi = boi.getWrappedOperation();
+        }
+        TimerInfo ti = (TimerInfo)boi.getProperty(TimerInfo.class.getName());
+        if (ti == null) {
+            synchronized (boi) {
+                return createTimerInfo(message, boi);
+            }
+        }
+        return ti;
+    }
+    private TimerInfo createTimerInfo(Message message, BindingOperationInfo boi) {
+        TimerInfo ti = (TimerInfo)boi.getProperty(TimerInfo.class.getName());
+        if (ti == null) {
+            ti = new TimerInfo();
+            StringBuilder buffer = getBaseServiceName(message);
+            buffer.append("Operation=").append(boi.getName().getLocalPart()).append(',');
+            ti.totals = registry.timer(buffer.toString() + "Attribute=Totals");
+            ti.uncheckedApplicationFaults = registry.timer(buffer.toString() 
+                                                           + "Attribute=Unchecked Application
Faults");
+            ti.checkedApplicationFaults = registry.timer(buffer.toString() + "Attribute=Checked
Application Faults");
+            ti.runtimeFaults = registry.timer(buffer.toString() + "Attribute=Runtime Faults");
+            ti.logicalRuntimeFaults = registry.timer(buffer.toString() + "Attribute=Logical
Runtime Faults");
+            
+            boi.setProperty(TimerInfo.class.getName(), ti);
+        }
+        return ti;
+    }
+    StringBuilder getBaseServiceName(Message message) {
+        Exchange ex = message.getExchange();
+        StringBuilder buffer = new StringBuilder();
+        if (ex.get("org.apache.cxf.management.service.counter.name") != null) {
+            buffer.append((String)ex.get("org.apache.cxf.management.service.counter.name"));
+        } else {
+            Service service = ex.getService();
+            Endpoint endpoint = ex.getEndpoint();
+            Bus b = ex.getBus();
+
+            String serviceName = "\"" + escapePatternChars(service.getName().toString())
+ "\"";
+            String portName = "\"" + endpoint.getEndpointInfo().getName().getLocalPart()
+ "\"";
+
+            buffer.append(ManagementConstants.DEFAULT_DOMAIN_NAME + ":");
+            buffer.append(ManagementConstants.BUS_ID_PROP + "=" + b.getId() + ",");
+            buffer.append(ManagementConstants.TYPE_PROP).append("=Metrics");
+            if (MessageUtils.isRequestor(message)) {
+                buffer.append(".Client,");
+            } else {
+                buffer.append(".Server,");
+            }
+            buffer.append(ManagementConstants.SERVICE_NAME_PROP + "=" + serviceName + ",");
+
+            buffer.append(ManagementConstants.PORT_NAME_PROP + "=" + portName + ",");
+        }
+        return buffer;
+    }
+    private TimerInfo createTimerInfo(Message message) {
+        Exchange ex = message.getExchange();
+        final Endpoint endpoint = ex.get(Endpoint.class);
+        TimerInfo ti = (TimerInfo)endpoint.get(TimerInfo.class.getName());
+        if (ti == null) {
+            ti = new TimerInfo();
+            StringBuilder buffer = getBaseServiceName(message);
+            final String baseName = buffer.toString();
+            ti.totals = registry.timer(baseName + "Attribute=Totals");
+            ti.uncheckedApplicationFaults = registry.timer(baseName 
+                                                           + "Attribute=Unchecked Application
Faults");
+            ti.checkedApplicationFaults = registry.timer(baseName + "Attribute=Checked Application
Faults");
+            ti.runtimeFaults = registry.timer(baseName + "Attribute=Runtime Faults");
+            ti.logicalRuntimeFaults = registry.timer(baseName + "Attribute=Logical Runtime
Faults");
+            ti.inFlight = registry.counter(baseName + "Attribute=In Flight");
+            endpoint.put(TimerInfo.class.getName(), ti);
+            endpoint.addCleanupHook(new Closeable() {
+                public void close() throws IOException {
+                    try {
+                        registry.remove(baseName + "Attribute=Totals");
+                        registry.remove(baseName + "Attribute=Unchecked Application Faults");
+                        registry.remove(baseName + "Attribute=Checked Application Faults");
+                        registry.remove(baseName + "Attribute=Runtime Faults");
+                        registry.remove(baseName + "Attribute=Logical Runtime Faults");
+                        registry.remove(baseName + "Attribute=In Flight");
+                        endpoint.remove(TimerInfo.class.getName());
+                        System.out.println(endpoint.getBinding().getBindingInfo().getOperations());
+                        for (BindingOperationInfo boi : endpoint.getBinding().getBindingInfo().getOperations())
{
+                            TimerInfo ti = (TimerInfo)boi.removeProperty(TimerInfo.class.getName());
+                            if (ti != null) {
+                                String name = baseName + "Operation=" + boi.getName().getLocalPart()
+ ",";
+                                System.out.println("Removing beans for " + boi.getName().getLocalPart());
+                                registry.remove(name + "Attribute=Totals");
+                                registry.remove(name + "Attribute=Unchecked Application Faults");
+                                registry.remove(name + "Attribute=Checked Application Faults");
+                                registry.remove(name + "Attribute=Runtime Faults");
+                                registry.remove(name + "Attribute=Logical Runtime Faults");
                           
+                            }
+                        }
+                    } catch (Throwable t) {
+                        t.printStackTrace();
+                    }
+                }
+            });
+        }
+        return ti;
+    }
+    protected String escapePatternChars(String value) {
+        // This can be replaced if really needed with pattern-based matching
+        if (value.lastIndexOf(QUESTION_MARK) != -1) {
+            value = value.replace(QUESTION_MARK, ESCAPED_QUESTION_MARK);
+        }
+        return value;
+    }
+
+    static void update(Timer t1, Timer t2, long t) {
+        if (t1 != null) {
+            t1.update(t,  TimeUnit.NANOSECONDS);
+        }
+        if (t2 != null) {
+            t2.update(t,  TimeUnit.NANOSECONDS);
+        }
+    }
+    public void stopTimers(Message m) {
+        TimerInfo.Context ctx = m.getExchange().get(TimerInfo.Context.class);
+        long l = ctx.t.stop();
+        ctx.info.inFlight.dec();
+        BindingOperationInfo bi = m.getExchange().getBindingOperationInfo();
+        FaultMode fm = m.getExchange().get(FaultMode.class);
+        TimerInfo op = null;
+        if (bi != null) {
+            op = getTimerInfo(m, bi);
+            op.totals.update(l, TimeUnit.NANOSECONDS);
+        }
+        if (fm != null) {
+            switch (fm) {
+            case CHECKED_APPLICATION_FAULT:
+                update(ctx.info.checkedApplicationFaults, op != null ? op.checkedApplicationFaults
: null, l);
+                break;
+            case UNCHECKED_APPLICATION_FAULT:
+                update(ctx.info.uncheckedApplicationFaults, op != null ? op.uncheckedApplicationFaults
: null, l);
+                break;
+            case RUNTIME_FAULT:
+                update(ctx.info.runtimeFaults, op != null ? op.runtimeFaults : null, l);
+                break;
+            case LOGICAL_RUNTIME_FAULT:
+                update(ctx.info.logicalRuntimeFaults, op != null ? op.logicalRuntimeFaults
: null, l);
+                break;
+            default:
+            }
+        }
+    }
+    
+
+    class ResponseTimeMessageInInterceptor extends AbstractPhaseInterceptor<Message>
{
+        public ResponseTimeMessageInInterceptor() {
+            super(Phase.RECEIVE);
+            addBefore(AttachmentInInterceptor.class.getName());
+        }
+        public void handleMessage(Message message) throws Fault {
+            TimerInfo ti = getTimerInfo(message);
+            if (isRequestor(message)) {
+                //
+            } else {
+                TimerInfo.Context ctx = ti.start();
+                message.getExchange().put(TimerInfo.Context.class, ctx);
+            }
+        }
+        public void handleFault(Message message) {
+            if (message.getExchange().isOneWay()) {
+                stopTimers(message);
+            }
+        }
+    };
+
+    class ResponseTimeMessageOutInterceptor extends AbstractPhaseInterceptor<Message>
{
+        public ResponseTimeMessageOutInterceptor() {
+            super(Phase.PREPARE_SEND_ENDING);
+            addBefore(MessageSenderInterceptor.MessageSenderEndingInterceptor.class.getName());
+        }
+        public void handleMessage(Message message) throws Fault {
+            if (isRequestor(message)) {
+                //
+            } else {
+                stopTimers(message);
+            }
+        }    
+    };
+    class ResponseTimeMessageInOneWayInterceptor extends AbstractPhaseInterceptor<Message>
{
+        public ResponseTimeMessageInOneWayInterceptor() {
+            super(Phase.INVOKE);
+            addAfter(ServiceInvokerInterceptor.class.getName());
+        }
+
+        public void handleMessage(Message message) throws Fault {
+            Exchange ex = message.getExchange();
+            if (ex.isOneWay() && !isRequestor(message)) {
+                stopTimers(message);
+            }
+        }               
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/99963f9a/rt/management/src/main/java/org/apache/cxf/management/counters/Counter.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/counters/Counter.java b/rt/management/src/main/java/org/apache/cxf/management/counters/Counter.java
index af4fc73..37f4d96 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/counters/Counter.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/counters/Counter.java
@@ -28,4 +28,6 @@ public interface Counter extends ManagedComponent {
     void increase(MessageHandlingTimeRecorder mhtr);  
         
     Number getNumInvocations();
+    
+    boolean isEnabled();
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/99963f9a/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
b/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
index 92f9dc4..c6e7c13 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
@@ -32,7 +32,6 @@ import org.apache.cxf.management.ManagementConstants;
 import org.apache.cxf.management.counters.Counter;
 import org.apache.cxf.management.counters.CounterRepository;
 import org.apache.cxf.management.counters.MessageHandlingTimeRecorder;
-import org.apache.cxf.management.counters.ResponseTimeCounter;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.FaultMode;
 import org.apache.cxf.message.Message;
@@ -153,7 +152,7 @@ public abstract class AbstractMessageResponseTimeInterceptor extends AbstractPha
             return false;
         }
         ObjectName serviceCounterName = getServiceCounterName(ex);
-        ResponseTimeCounter serviceCounter = (ResponseTimeCounter)counterRepo.getCounter(serviceCounterName);
+        Counter serviceCounter = counterRepo.getCounter(serviceCounterName);
         //If serviceCounter is null, we need to wait ResponseTimeOutInterceptor to create
it , hence set to true
         if (serviceCounter == null || serviceCounter.isEnabled()) {
             return true;

http://git-wip-us.apache.org/repos/asf/cxf/blob/99963f9a/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
b/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
index 42d7d15..166379b 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
@@ -127,15 +127,8 @@ public class InstrumentationManagerImpl extends JMXConnectorPolicyType
         usePlatformMBeanServer = flag;
     }
 
-    @PostConstruct     
+    @Deprecated
     public void register() {    
-        if (null != bus) {
-            bus.setExtension(this, InstrumentationManager.class);
-            BusLifeCycleManager blcm = bus.getExtension(BusLifeCycleManager.class);
-            if (null != blcm) {
-                blcm.registerLifeCycleListener(this);
-            }    
-        }
     }
     
     @PostConstruct     
@@ -199,6 +192,14 @@ public class InstrumentationManagerImpl extends JMXConnectorPolicyType
                 }
             }
         }
+
+        if (null != bus) {
+            bus.setExtension(this, InstrumentationManager.class);
+            BusLifeCycleManager blcm = bus.getExtension(BusLifeCycleManager.class);
+            if (null != blcm) {
+                blcm.registerLifeCycleListener(this);
+            }    
+        }        
     }
     
     private ObjectName getDelegateName() throws JMException {

http://git-wip-us.apache.org/repos/asf/cxf/blob/99963f9a/rt/management/src/test/java/org/apache/cxf/management/jmx/JMXManagedComponentManagerTest.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/jmx/JMXManagedComponentManagerTest.java
b/rt/management/src/test/java/org/apache/cxf/management/jmx/JMXManagedComponentManagerTest.java
index da0879a..2c40c45 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/jmx/JMXManagedComponentManagerTest.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/jmx/JMXManagedComponentManagerTest.java
@@ -134,7 +134,6 @@ public class JMXManagedComponentManagerTest extends Assert {
         this.manager.setEnabled(true);
         this.manager.setJMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + PORT +
"/jmxrmi");
         this.manager.setServer(server);
-        this.manager.register();
         this.manager.init();
         
         ObjectName name = this.registerStandardMBean("yo!");
@@ -168,7 +167,6 @@ public class JMXManagedComponentManagerTest extends Assert {
         this.manager.setEnabled(true);
         this.manager.setJMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + PORT +
"/jmxrmi");
         this.manager.setServer(server);
-        this.manager.register();
         this.manager.init();
         
         name = this.registerStandardMBean("yoyo!");


Mime
View raw message