You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/12/01 20:55:04 UTC
svn commit: r1209213 - in /cxf/branches/2.4.x-fixes: ./
rt/management/src/main/java/org/apache/cxf/management/counters/
rt/management/src/main/java/org/apache/cxf/management/jmx/
rt/management/src/test/java/org/apache/cxf/management/ rt/management/src/...
Author: dkulp
Date: Thu Dec 1 19:55:03 2011
New Revision: 1209213
URL: http://svn.apache.org/viewvc?rev=1209213&view=rev
Log:
Merged revisions 1208497 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1208497 | ay | 2011-11-30 11:37:45 -0500 (Wed, 30 Nov 2011) | 1 line
[CXF-3942] CounterRepository cannot be assigned to a named bus
........
Added:
cxf/branches/2.4.x-fixes/rt/management/src/test/resources/managed-spring-twobuses.xml
- copied unchanged from r1208497, cxf/trunk/rt/management/src/test/resources/managed-spring-twobuses.xml
Modified:
cxf/branches/2.4.x-fixes/ (props changed)
cxf/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
cxf/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
cxf/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java?rev=1209213&r1=1209212&r2=1209213&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java (original)
+++ cxf/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java Thu Dec 1 19:55:03 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/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java?rev=1209213&r1=1209212&r2=1209213&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java (original)
+++ cxf/branches/2.4.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java Thu Dec 1 19:55:03 2011
@@ -87,7 +87,7 @@ public class InstrumentationManagerImpl
public Bus getBus() {
return bus;
}
-
+
@Resource(name = "cxf")
public void setBus(Bus bus) {
this.bus = bus;
@@ -296,6 +296,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/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java?rev=1209213&r1=1209212&r2=1209213&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java (original)
+++ cxf/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java Thu Dec 1 19:55:03 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
@@ -85,4 +91,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();
+ }
+ }
+ }
+
+
}