cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r892222 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/handlers/ test/java/org/apache/cxf/dosgi/dsw/handlers/
Date Fri, 18 Dec 2009 11:16:42 GMT
Author: davidb
Date: Fri Dec 18 11:16:42 2009
New Revision: 892222

URL: http://svn.apache.org/viewvc?rev=892222&view=rev
Log:
Added support for old way of configuring endpoint location back in. The following properties
on the exposed services are now equivalents and can be set to a value such as http://localhost:9876/myService
  endpoint.uri
  org.apache.cxf.ws.address
  osgi.remote.configuration.pojo.address
The endpoint.uri is a new property that's introduced in the OSGi Remote Service Admin spec.
This is now the standard way to configure the endpoint URI. The old properties are still supported
for backward compatibility.

New tests included.

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java?rev=892222&r1=892221&r2=892222&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
Fri Dec 18 11:16:42 2009
@@ -30,17 +30,25 @@
     final Map<String, Object> handlerProps;
     protected BundleContext bundleContext;
     
-    protected AbstractConfigurationHandler(BundleContext dswBC,
-                                           
+    protected AbstractConfigurationHandler(BundleContext dswBC,                         
                
                                            Map<String, Object> handlerProps) {
-        this.bundleContext = dswBC;
-     
+        this.bundleContext = dswBC;     
         this.handlerProps = handlerProps;
     }
     
     protected String getDefaultAddress(Class<?> type) {        
-        String host = handlerProps.get(Constants.DEFAULT_HOST_CONFIG).toString();
-        String port = handlerProps.get(Constants.DEFAULT_PORT_CONFIG).toString();
+        Object h = handlerProps.get(Constants.DEFAULT_HOST_CONFIG);
+        if (h == null) {
+            h = "localhost";
+        }
+        String host = h.toString();
+        
+        Object p = handlerProps.get(Constants.DEFAULT_PORT_CONFIG);
+        if (p == null) {
+            p = "9000";
+        }
+        String port = p.toString();
+        
         return getAddress("http", host, port, "/" + type.getName().replace('.', '/'));  
     
     }
 

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java?rev=892222&r1=892221&r2=892222&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
Fri Dec 18 11:16:42 2009
@@ -52,8 +52,7 @@
     
     private IntentMap masterMap;
     
-    public AbstractPojoConfigurationTypeHandler(BundleContext dswBC, 
-                                                
+    public AbstractPojoConfigurationTypeHandler(BundleContext dswBC,                    
                           
                                                 Map<String, Object> handlerProps) {
         super(dswBC,  handlerProps);
     }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java?rev=892222&r1=892221&r2=892222&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
Fri Dec 18 11:16:42 2009
@@ -44,9 +44,7 @@
 public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
     private static final Logger LOG = Logger.getLogger(PojoConfigurationTypeHandler.class.getName());
 
-    public PojoConfigurationTypeHandler(BundleContext dswBC,
-
-    Map<String, Object> handlerProps) {
+    public PojoConfigurationTypeHandler(BundleContext dswBC, Map<String, Object> handlerProps)
{
         super(dswBC, handlerProps);
     }
 
@@ -201,10 +199,12 @@
 
     protected String getPojoAddress(Map sd, Class<?> iClass) {
         String address = OsgiUtils.getProperty(sd, RemoteConstants.ENDPOINT_URI);
-        // if (address == null) {
-        // address = OsgiUtils.getProperty(sd, Constants.WS_ADDRESS_PROPERTY_OLD);
-        // }
-
+        if (address == null) {
+            address = OsgiUtils.getProperty(sd, Constants.WS_ADDRESS_PROPERTY);
+        }
+        if (address == null) {
+            address = OsgiUtils.getProperty(sd, Constants.WS_ADDRESS_PROPERTY_OLD);
+        }
         if (address == null) {
             address = getDefaultAddress(iClass);
             if (address != null) {

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java?rev=892222&r1=892221&r2=892222&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
Fri Dec 18 11:16:42 2009
@@ -52,15 +52,44 @@
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventAdmin;
 import org.osgi.service.event.EventConstants;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
 
 public class PojoConfigurationTypeHandlerTest extends TestCase {
-    
-    
-    public void testDUMMY(){
-        assertTrue(true);
+    public void testGetPojoAddressEndpointURI() {
+        Map<String, Object> hp = new HashMap<String, Object>();
+        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null, hp);
+        Map<String, Object> sd = new HashMap<String, Object>();
+        String url = "http://somewhere:1234/blah";
+        sd.put(RemoteConstants.ENDPOINT_URI, url);
+        assertEquals(url, handler.getPojoAddress(sd, String.class));
     }
     
+    public void testGetPojoAddressEndpointCxf() {
+        Map<String, Object> hp = new HashMap<String, Object>();
+        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null, hp);
+        Map<String, Object> sd = new HashMap<String, Object>();
+        String url = "http://somewhere:29/boo";
+        sd.put("org.apache.cxf.ws.address", url);
+        assertEquals(url, handler.getPojoAddress(sd, String.class));
+    }
+
+    public void testGetPojoAddressEndpointPojo() {
+        Map<String, Object> hp = new HashMap<String, Object>();
+        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null, hp);
+        Map<String, Object> sd = new HashMap<String, Object>();
+        String url = "http://somewhere:32768/foo";
+        sd.put("osgi.remote.configuration.pojo.address", url);
+        assertEquals(url, handler.getPojoAddress(sd, String.class));
+    }
+
+    public void testGetDefaultPojoAddress() {
+        Map<String, Object> hp = new HashMap<String, Object>();
+        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null, hp);
+        Map<String, Object> sd = new HashMap<String, Object>(); 
+        assertEquals("http://localhost:9000/java/lang/String", handler.getPojoAddress(sd,
String.class));
+    }
+
 //    private Map<String, Object> handlerProps;
 //    
 //    @Override



Mime
View raw message