cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r931259 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/ main/java/org/apache/cxf/dosgi/dsw/handlers/ test/java/org/apache/cxf/dosgi/dsw/handlers/
Date Tue, 06 Apr 2010 18:22:21 GMT
Author: davidb
Date: Tue Apr  6 18:22:20 2010
New Revision: 931259

URL: http://svn.apache.org/viewvc?rev=931259&view=rev
Log:
Added a configuration property to specify the port of a particular endpoint without having
to specify the actual URL. This can be useful when you want to use the default contexts, but
change the standard default port of 9000 to something else. The property is called org.apache.cxf.ws.port
and can be set to desired default port number such as "12345".

New tests included too.

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
    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/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/Constants.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java?rev=931259&r1=931258&r2=931259&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java Tue
Apr  6 18:22:20 2010
@@ -46,6 +46,7 @@ public class Constants {
     // WS
     public static final String WS_CONFIG_TYPE = PROVIDER_PREFIX + ".ws";
     public static final String WS_ADDRESS_PROPERTY = WS_CONFIG_TYPE + ".address";
+    public static final String WS_PORT_PROPERTY = WS_CONFIG_TYPE + ".port";
     public static final String WS_HTTP_SERVICE_CONTEXT = WS_CONFIG_TYPE + ".httpservice.context";
     public static final String WS_FRONTEND_PROP_KEY = WS_CONFIG_TYPE + ".frontend";
     public static final String WS_DATABINDING_PROP_KEY = WS_CONFIG_TYPE + ".databinding";

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=931259&r1=931258&r2=931259&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
Tue Apr  6 18:22:20 2010
@@ -43,17 +43,23 @@ public abstract class AbstractConfigurat
     }
 
     protected String getDefaultAddress(Class<?> type) {
+        return getDefaultAddress(type, null);
+    }
+    
+    protected String getDefaultAddress(Class<?> type, String port) {
         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();
+        if (port == null) {
+            Object p = handlerProps.get(Constants.DEFAULT_PORT_CONFIG);
+            if (p == null) {
+                p = "9000";
+            }
+            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/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=931259&r1=931258&r2=931259&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
Tue Apr  6 18:22:20 2010
@@ -18,14 +18,7 @@
  */
 package org.apache.cxf.dosgi.dsw.handlers;
 
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -34,16 +27,12 @@ import org.apache.cxf.databinding.DataBi
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.service.ExportRegistrationImpl;
-import org.apache.cxf.dosgi.dsw.service.Utils;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.jaxb.JAXBDataBinding;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
@@ -186,7 +175,13 @@ public class PojoConfigurationTypeHandle
         
         
         if (address == null) {
-            address = getDefaultAddress(iClass);
+            String port = null;
+            Object p = sd.get(Constants.WS_PORT_PROPERTY);
+            if (p instanceof String) {
+                port = (String) p;
+            }
+            
+            address = getDefaultAddress(iClass, port);
             if (address != null) {
                 LOG.info("Using a default address : " + address);
             }

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=931259&r1=931258&r2=931259&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
Tue Apr  6 18:22:20 2010
@@ -78,6 +78,15 @@ public class PojoConfigurationTypeHandle
         sd.put("osgi.remote.configuration.pojo.address", url);
         assertEquals(url, handler.getPojoAddress(sd, String.class));
     }
+    
+    public void testGetPojoAddressDefaultWithAlternatePort() {
+        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://localhost:1234/java/lang/String";
+        sd.put("org.apache.cxf.ws.port", "1234");
+        assertEquals(url, handler.getPojoAddress(sd, String.class));        
+    }
 
     public void testGetDefaultPojoAddress() {
         Map<String, Object> hp = new HashMap<String, Object>();



Mime
View raw message