cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1082039 - in /cxf/branches/2.3.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/endpoint/ systests/uncategorized/src/test/java/org/apache/cxf/systest/management/
Date Wed, 16 Mar 2011 03:38:25 GMT
Author: dkulp
Date: Wed Mar 16 03:38:24 2011
New Revision: 1082039

URL: http://svn.apache.org/viewvc?rev=1082039&view=rev
Log:
Merged revisions 1082031 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1082031 | dkulp | 2011-03-15 22:34:27 -0400 (Tue, 15 Mar 2011) | 2 lines
  
  [CXF-3398] Allow the user to set the servicename and portname that the
  management stuff uses for the JMS ObjectName.
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
    cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java

Propchange: cxf/branches/2.3.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java?rev=1082039&r1=1082038&r2=1082039&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
Wed Mar 16 03:38:24 2011
@@ -19,6 +19,7 @@
 package org.apache.cxf.endpoint;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -151,6 +152,12 @@ public abstract class AbstractEndpointFa
     public Map<String, Object> getProperties() {
         return properties;
     }
+    public Map<String, Object> getProperties(boolean create) {
+        if (create && properties == null) {
+            properties = new HashMap<String, Object>();
+        }
+        return properties;
+    }
 
     public void setProperties(Map<String, Object> properties) {
         this.properties = properties;

Modified: cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java?rev=1082039&r1=1082038&r2=1082039&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
Wed Mar 16 03:38:24 2011
@@ -23,6 +23,7 @@ import javax.management.JMException;
 import javax.management.ObjectName;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.management.ManagedComponent;
 import org.apache.cxf.management.ManagementConstants;
 import org.apache.cxf.management.annotation.ManagedAttribute;
@@ -33,6 +34,8 @@ import org.apache.cxf.management.annotat
                  description = "Responsible for managing server instances.")
 
 public class ManagedEndpoint implements ManagedComponent, ServerLifeCycleListener {
+    public static final String ENDPOINT_NAME = "managed.endpoint.name";
+    public static final String SERVICE_NAME = "managed.service.name";
 
     private Bus bus;
     private Endpoint endpoint;
@@ -91,9 +94,19 @@ public class ManagedEndpoint implements 
         buffer.append(ManagementConstants.TYPE_PROP + "=" + "Bus.Service.Endpoint,");
        
 
-        String serviceName = ObjectName.quote(endpoint.getService().getName().toString());
+        String serviceName = (String)endpoint.get(SERVICE_NAME);
+        if (StringUtils.isEmpty(serviceName)) {
+            serviceName = endpoint.getService().getName().toString();
+        }
+        serviceName = ObjectName.quote(serviceName);
         buffer.append(ManagementConstants.SERVICE_NAME_PROP + "=" + serviceName + ",");
-        String endpointName = ObjectName.quote(endpoint.getEndpointInfo().getName().getLocalPart());
+        
+        
+        String endpointName = (String)endpoint.get(ENDPOINT_NAME);
+        if (StringUtils.isEmpty(endpointName)) {
+            endpointName = endpoint.getEndpointInfo().getName().getLocalPart();
+        }
+        endpointName = ObjectName.quote(endpointName);
         buffer.append(ManagementConstants.PORT_NAME_PROP + "=" + endpointName);
         
         //Use default domain name of server

Modified: cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java?rev=1082039&r1=1082038&r2=1082039&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java
Wed Mar 16 03:38:24 2011
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.management;
 
+import java.lang.management.ManagementFactory;
 import java.util.Iterator;
 import java.util.Set;
 
@@ -28,19 +29,63 @@ import javax.management.ObjectName;
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.management.InstrumentationManager;
 import org.apache.cxf.management.ManagementConstants;
 import org.apache.cxf.management.jmx.InstrumentationManagerImpl;
 import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.workqueue.WorkQueueManager;
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.GreeterImpl;
+
 import org.junit.Assert;
 import org.junit.Test;
 
 public class ManagedBusTest extends Assert {
     public static final String JMX_PORT1 = TestUtil.getPortNumber("Server.1");
     public static final String JMX_PORT2 = TestUtil.getPortNumber(ManagedBusTest.class, 3);
+    public static final String SERVICE_PORT = TestUtil.getPortNumber(ManagedBusTest.class,
4);
 
     @Test
+    public void testTwoSameNamedEndpoint() throws Exception {
+        SpringBusFactory factory = new SpringBusFactory();
+        Bus bus = factory.createBus();
+        try {
+            InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
+            assertNotNull(im);
+            InstrumentationManagerImpl imi = (InstrumentationManagerImpl)im;
+            imi.setServer(ManagementFactory.getPlatformMBeanServer());
+            imi.setEnabled(true);
+            imi.init();
+
+            
+            Greeter greeter1 = new GreeterImpl();
+            JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
+            svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello");
+            svrFactory.setServiceBean(greeter1);
+            svrFactory.getProperties(true).put("managed.endpoint.name", "greeter1");
+            svrFactory.create();
+
+            Greeter greeter2 = new GreeterImpl();
+            svrFactory = new JaxWsServerFactoryBean();
+            svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello2");
+            svrFactory.setServiceBean(greeter2);
+            svrFactory.getProperties(true).put("managed.endpoint.name", "greeter2");
+            svrFactory.create();
+            
+            MBeanServer mbs = im.getMBeanServer(); 
+            
+            ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME 
+                                             + ":type=Bus.Service.Endpoint,*");
+            Set s = mbs.queryMBeans(name, null);
+            assertEquals(2, s.size());
+        } finally {
+            bus.shutdown(true);
+        }
+        
+    }
+    
+    @Test
     public void testManagedSpringBus() throws Exception {
         SpringBusFactory factory = new SpringBusFactory();
         Bus bus = factory.createBus();        



Mime
View raw message