cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1208497 - in /cxf/trunk/rt/management/src: main/java/org/apache/cxf/management/counters/ main/java/org/apache/cxf/management/jmx/ test/java/org/apache/cxf/management/ test/resources/
Date Wed, 30 Nov 2011 16:37:46 GMT
Author: ay
Date: Wed Nov 30 16:37:45 2011
New Revision: 1208497

URL: http://svn.apache.org/viewvc?rev=1208497&view=rev
Log:
[CXF-3942] CounterRepository cannot be assigned to a named bus

Added:
    cxf/trunk/rt/management/src/test/resources/managed-spring-twobuses.xml   (with props)
Modified:
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
    cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java?rev=1208497&r1=1208496&r2=1208497&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
Wed Nov 30 16:37:45 2011
@@ -27,7 +27,6 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
 import javax.management.JMException;
 import javax.management.ObjectName;
 
@@ -55,7 +54,6 @@ public class CounterRepository {
         counters = new ConcurrentHashMap<ObjectName, Counter>();
     }
     
-    @Resource(name = "cxf")
     public void setBus(Bus b) {
         bus = b;
     }

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java?rev=1208497&r1=1208496&r2=1208497&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
Wed Nov 30 16:37:45 2011
@@ -87,7 +87,7 @@ public class InstrumentationManagerImpl 
     public Bus getBus() {
         return bus;
     }
-    
+
     @Resource(name = "cxf")
     public void setBus(Bus bus) {        
         this.bus = bus;
@@ -300,6 +300,9 @@ public class InstrumentationManagerImpl 
         throws JMException {
         ObjectInstance instance = null;
         try {
+            if (LOG.isLoggable(Level.INFO)) {
+                LOG.info("registering MBean " + name + ": " + obj);
+            }
             instance = mbs.registerMBean(obj, name);           
         } catch (InstanceAlreadyExistsException e) {            
             if (forceRegistration) {

Modified: cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java?rev=1208497&r1=1208496&r2=1208497&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java
(original)
+++ cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java
Wed Nov 30 16:37:45 2011
@@ -26,12 +26,16 @@ import javax.management.ObjectName;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.management.counters.CounterRepository;
 import org.apache.cxf.workqueue.WorkQueueManagerImpl;
+
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
 public class InstrumentationManagerTest extends Assert {
     InstrumentationManager im;
     Bus bus;
@@ -44,7 +48,9 @@ public class InstrumentationManagerTest 
     @After
     public void tearDown() throws Exception {
         //test case had done the bus.shutdown
-        bus.shutdown(true);
+        if (bus != null) {
+            bus.shutdown(true);
+        }
     }
     
     @Test
@@ -92,4 +98,40 @@ public class InstrumentationManagerTest 
         bus.shutdown(true);
     }
 
+    @Test
+    public void testInstrumentTwoBuses() {
+        ClassPathXmlApplicationContext context = null;
+        Bus cxf1 = null;
+        Bus cxf2 = null;
+        try {
+            context = new ClassPathXmlApplicationContext("managed-spring-twobuses.xml");
+
+            cxf1 = (Bus)context.getBean("cxf1");
+            InstrumentationManager im1 = cxf1.getExtension(InstrumentationManager.class);
+            assertNotNull("Instrumentation Manager of cxf1 should not be null", im1);
+            CounterRepository cr1 = cxf1.getExtension(CounterRepository.class);
+            assertNotNull("CounterRepository of cxf1 should not be null", cr1);
+            assertEquals("CounterRepository of cxf1 has the wrong bus", cxf1, cr1.getBus());
+            
+            cxf2 = (Bus)context.getBean("cxf2");
+            InstrumentationManager im2 = cxf2.getExtension(InstrumentationManager.class);
+            assertNotNull("Instrumentation Manager of cxf2 should not be null", im2);
+            CounterRepository cr2 = cxf2.getExtension(CounterRepository.class);
+            assertNotNull("CounterRepository of cxf2 should not be null", cr2);
+            assertEquals("CounterRepository of cxf2 has the wrong bus", cxf2, cr2.getBus());
+
+        } finally {
+            if (cxf1 != null) {
+                cxf1.shutdown(true);
+            }
+            if (cxf2 != null) {
+                cxf2.shutdown(true);
+            }
+            if (context != null) {
+                context.close();
+            }
+        }
+    }
+    
+
 }

Added: cxf/trunk/rt/management/src/test/resources/managed-spring-twobuses.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/test/resources/managed-spring-twobuses.xml?rev=1208497&view=auto
==============================================================================
--- cxf/trunk/rt/management/src/test/resources/managed-spring-twobuses.xml (added)
+++ cxf/trunk/rt/management/src/test/resources/managed-spring-twobuses.xml Wed Nov 30 16:37:45
2011
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:im="http://cxf.apache.org/management"
+       xmlns:cxf="http://cxf.apache.org/core"
+       xsi:schemaLocation="
+       http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <import resource="classpath:META-INF/cxf/cxf.xml" />
+
+    <cxf:bus bus="cxf1"/>
+    <cxf:bus bus="cxf2"/>
+
+    <bean id="CounterRepository1" class="org.apache.cxf.management.counters.CounterRepository">
+        <property name="bus" ref="cxf1" />
+    </bean>
+    <bean id="CounterRepository2" class="org.apache.cxf.management.counters.CounterRepository">
+        <property name="bus" ref="cxf2" />
+    </bean>
+
+</beans>
\ No newline at end of file

Propchange: cxf/trunk/rt/management/src/test/resources/managed-spring-twobuses.xml
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message