cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1414645 [1/2] - in /cxf/dosgi/trunk/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/ main/java/org/apache/cxf/dosgi/dsw/handlers/ main/java/org/apache/cxf/dosgi/dsw/qos/ main/java/org/apache/cxf/dosgi/dsw/service/ main/resources/OSGI-I...
Date Wed, 28 Nov 2012 12:24:07 GMT
Author: cschneider
Date: Wed Nov 28 12:24:01 2012
New Revision: 1414645

URL: http://svn.apache.org/viewvc?rev=1414645&view=rev
Log:
DOSGI-148 Refactoring of ConfigTypeHandlers

Added:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java   (with props)
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/InterceptorUtils.java   (with props)
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java
      - copied, changed from r1414579, cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java
Removed:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/OSGI-INF/
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java
Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.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/AbstractPojoConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.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/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManager.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImpl.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentMapTest.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java Wed Nov 28 12:24:01 2012
@@ -25,12 +25,15 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.dosgi.dsw.decorator.ServiceDecorator;
 import org.apache.cxf.dosgi.dsw.decorator.ServiceDecoratorImpl;
+import org.apache.cxf.dosgi.dsw.handlers.ConfigTypeHandlerFactory;
+import org.apache.cxf.dosgi.dsw.handlers.HttpServiceManager;
 import org.apache.cxf.dosgi.dsw.qos.DefaultIntentMapFactory;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
 import org.apache.cxf.dosgi.dsw.qos.IntentMap;
 import org.apache.cxf.dosgi.dsw.qos.IntentTracker;
 import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
+import org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore;
 import org.apache.cxf.dosgi.dsw.service.RemoteServiceadminFactory;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -68,7 +71,10 @@ public class Activator implements Manage
         intentTracker = new IntentTracker(bc, intentMap);
         intentTracker.open();
         IntentManager intentManager = new IntentManagerImpl(intentMap, DEFAULT_INTENT_TIMEOUT);
-        RemoteServiceadminFactory rsaf = new RemoteServiceadminFactory(bc, intentManager);
+        HttpServiceManager httpServiceManager = new HttpServiceManager(bc);
+        ConfigTypeHandlerFactory configTypeHandlerFactory = new ConfigTypeHandlerFactory(intentManager, httpServiceManager );
+        RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc, configTypeHandlerFactory );
+        RemoteServiceadminFactory rsaf = new RemoteServiceadminFactory(rsaCore);
         Hashtable<String, Object> props = new Hashtable<String, Object>();
 
         // TODO .... RemoteAdminService.XXX

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=1414645&r1=1414644&r2=1414645&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 Wed Nov 28 12:24:01 2012
@@ -19,6 +19,7 @@
 package org.apache.cxf.dosgi.dsw.handlers;
 
 import java.lang.reflect.Proxy;
+import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -52,15 +53,7 @@ public abstract class AbstractConfigurat
     protected String getDefaultAddress(Class<?> type, String port) {
         Object h = handlerProps.get(Constants.DEFAULT_HOST_CONFIG);
         if (h == null || h.toString().equals("localhost")) {
-            try {
-                h = LocalHostUtil.getLocalHost().getHostAddress();
-            } catch (Exception e) {
-                h = "localhost";
-            }
-            if (h == null) {
-                h = "localhost";
-            }
-
+            h = LocalHostUtil.getLocalHostAddress();
         }
         String host = h.toString();
 
@@ -71,7 +64,6 @@ public abstract class AbstractConfigurat
             }
             port = p.toString();
         } 
-
         return getAddress("http", host, port, "/" + type.getName().replace('.', '/'));
     }
 
@@ -80,6 +72,34 @@ public abstract class AbstractConfigurat
         buf.append(scheme).append("://").append(host).append(':').append(port).append(context);
         return buf.toString();
     }
+    
+    protected String constructAddress(BundleContext ctx, String contextRoot, String relativeEndpointAddress) {
+        if (relativeEndpointAddress.startsWith("http")) {
+            return relativeEndpointAddress;
+        }
+        boolean https = "true".equalsIgnoreCase(ctx.getProperty("org.osgi.service.http.secure.enabled"));
+        String port = ctx.getProperty(https ? "org.osgi.service.http.port.secure" : "org.osgi.service.http.port"); 
+        if (port == null) {
+            port = "8080";
+        }
+
+        String hostName = null;
+        try {
+            hostName = LocalHostUtil.getLocalHost().getHostAddress();
+        } catch (UnknownHostException e) {
+            hostName = "localhost";
+        }
+
+        String address = getAddress(https ? "https" : "http", hostName, port, contextRoot);
+        if (!isEmpty(relativeEndpointAddress) && !relativeEndpointAddress.equals("/")) {
+            address += relativeEndpointAddress;
+        }
+        return address;
+    }
+
+    private boolean isEmpty(String relativeEndpointAddress) {
+        return relativeEndpointAddress == null || "".equals(relativeEndpointAddress);
+    }
 
     protected Object getProxy(Object serviceProxy, Class<?> iType) {
         return Proxy.newProxyInstance(iType.getClassLoader(), new Class[] {
@@ -87,7 +107,7 @@ public abstract class AbstractConfigurat
         }, new ServiceInvocationHandler(serviceProxy, iType));
     }
 
-    protected Map<String, Object> createEndpointProps(Map sd, Class<?> iClass, String[] importedConfigs,
+    protected Map<String, Object> createEndpointProps(Map<String, Object> sd, Class<?> iClass, String[] importedConfigs,
                                                       String address, String[] intents) {
         Map<String, Object> props = new HashMap<String, Object>();
 
@@ -125,9 +145,9 @@ public abstract class AbstractConfigurat
 
     }
 
-    private void copyEndpointProperties(Map sd, Map<String, Object> endpointProps) {
-        Set<Map.Entry> keys = sd.entrySet();
-        for (Map.Entry entry : keys) {
+    private void copyEndpointProperties(Map<String, Object> sd, Map<String, Object> endpointProps) {
+        Set<Map.Entry<String, Object>> keys = sd.entrySet();
+        for (Map.Entry<String, Object> entry : keys) {
             try {
                 String skey = (String)entry.getKey();
                 if (!skey.startsWith("."))

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=1414645&r1=1414644&r2=1414645&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 Wed Nov 28 12:24:01 2012
@@ -19,7 +19,6 @@
 package org.apache.cxf.dosgi.dsw.handlers;
 
 import java.net.URL;
-import java.util.List;
 import java.util.Map;
 
 import javax.xml.namespace.QName;
@@ -29,15 +28,11 @@ import org.apache.cxf.common.util.Packag
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
-import org.apache.cxf.dosgi.dsw.util.ClassUtils;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ClientFactoryBean;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
@@ -50,11 +45,14 @@ import org.slf4j.LoggerFactory;
 public abstract class AbstractPojoConfigurationTypeHandler extends AbstractConfigurationHandler {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractPojoConfigurationTypeHandler.class);
     private static final String CONFIGURATION_TYPE = "org.apache.cxf.ws";
+    protected HttpServiceManager httpServiceManager;
     
     public AbstractPojoConfigurationTypeHandler(BundleContext dswBC,
                                                 IntentManager intentManager,
+                                                HttpServiceManager httpServiceManager,
                                                 Map<String, Object> handlerProps) {
         super(dswBC, intentManager, handlerProps);
+        this.httpServiceManager = httpServiceManager;
     }
 
     // Isolated so that it can be substituted for testing
@@ -79,7 +77,7 @@ public abstract class AbstractPojoConfig
 
     protected void setWsdlProperties(ServerFactoryBean factory,
                                      BundleContext callingContext,  
-                                     Map sd, boolean wsdlType) {
+                                     Map<String, Object> sd, boolean wsdlType) {
     	String location = OsgiUtils.getProperty(sd, wsdlType ? Constants.WSDL_LOCATION : Constants.WS_WSDL_LOCATION);
     	if (location != null) {
     		URL wsdlURL = callingContext.getBundle().getResource(location);
@@ -100,29 +98,8 @@ public abstract class AbstractPojoConfig
     	}
     }
     
-    protected void addWsInterceptorsFeaturesProps(
-    		AbstractEndpointFactory factory, BundleContext callingContext, Map sd) {
-    	addInterceptors(factory, callingContext, sd, Constants.WS_IN_INTERCEPTORS_PROP_KEY);
-        addInterceptors(factory, callingContext, sd, Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
-        addInterceptors(factory, callingContext, sd, Constants.WS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
-        addInterceptors(factory, callingContext, sd, Constants.WS_IN_FAULT_INTERCEPTORS_PROP_KEY);
-        addFeatures(factory, callingContext, sd, Constants.WS_FEATURES_PROP_KEY);
-        addContextProperties(factory, callingContext, sd, Constants.WS_CONTEXT_PROPS_PROP_KEY);
-    }
-    
-    protected void addRsInterceptorsFeaturesProps(
-    		AbstractEndpointFactory factory, BundleContext callingContext, Map sd) {
-    	addInterceptors(factory, callingContext, sd, Constants.RS_IN_INTERCEPTORS_PROP_KEY);
-        addInterceptors(factory, callingContext, sd, Constants.RS_OUT_INTERCEPTORS_PROP_KEY);
-        addInterceptors(factory, callingContext, sd, Constants.RS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
-        addInterceptors(factory, callingContext, sd, Constants.RS_IN_FAULT_INTERCEPTORS_PROP_KEY);
-        addFeatures(factory, callingContext, sd, Constants.RS_FEATURES_PROP_KEY);
-        addContextProperties(factory, callingContext, sd, Constants.RS_CONTEXT_PROPS_PROP_KEY);
-    }
-        
-    
     protected void setClientWsdlProperties(ClientFactoryBean factory, BundleContext dswContext, 
-    		Map sd, boolean wsdlType) {
+    		Map<String, Object> sd, boolean wsdlType) {
     	String location = OsgiUtils.getProperty(sd, wsdlType ? Constants.WSDL_LOCATION : Constants.WS_WSDL_LOCATION);
     	if (location != null) {
     		URL wsdlURL = dswContext.getBundle().getResource(location);
@@ -143,7 +120,7 @@ public abstract class AbstractPojoConfig
     	}
     }
     
-    protected static QName getServiceQName(Class<?> iClass, Map sd, String nsPropName, String namePropName) {
+    protected static QName getServiceQName(Class<?> iClass, Map<String, Object> sd, String nsPropName, String namePropName) {
     	String serviceNs = OsgiUtils.getProperty(sd, nsPropName);
     	String serviceName = OsgiUtils.getProperty(sd, namePropName);
     	if (iClass == null && (serviceNs == null || serviceName == null)) {
@@ -159,7 +136,7 @@ public abstract class AbstractPojoConfig
         return new QName(serviceNs, serviceName);
     }
     
-    protected static QName getPortQName(String ns, Map sd, String propName) {
+    protected static QName getPortQName(String ns, Map<String, Object> sd, String propName) {
     	String portName = OsgiUtils.getProperty(sd, propName);
         if (portName == null) {
         	return null;	
@@ -167,59 +144,23 @@ public abstract class AbstractPojoConfig
         return new QName(ns, portName);
     }
     
-    protected static void addInterceptors(AbstractEndpointFactory factory, BundleContext callingContext, 
-    		Map sd, String propName) {
-
-        List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName); 
-        boolean in = propName.contains("in.interceptors");
-        boolean out = propName.contains("out.interceptors");
-        boolean in_fault = propName.contains("in.fault.interceptors");
-        boolean out_fault = propName.contains("out.fault.interceptors");
-        for (int i = 0; i < providers.size(); i++) {
-        	Interceptor<?> interceptor = (Interceptor<?>)providers.get(i);  
-	        if (in) {
-	        	factory.getInInterceptors().add(interceptor);
-	        } else if (out) {
-	        	factory.getOutInterceptors().add(interceptor);
-	        } else if (in_fault) {
-	        	factory.getInFaultInterceptors().add(interceptor);
-	        } else if (out_fault) {
-	        	factory.getOutFaultInterceptors().add(interceptor);
-	        }
-        }
-    }
-    
-       
-    protected static void addFeatures(AbstractEndpointFactory factory, BundleContext callingContext, 
-    		Map sd, String propName) {
-
-        List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName); 
-        if (providers.size() > 0) {
-        	factory.getFeatures().addAll(CastUtils.cast(providers, AbstractFeature.class));
-        }
-    }
-    
-    protected static void addContextProperties(AbstractEndpointFactory factory, BundleContext callingContext, 
-    		Map sd, String propName) {
-    	Map<String, Object> props = (Map<String, Object>)sd.get(propName);
-        if (props != null) {
-        	factory.getProperties(true).putAll(props);
-        }
-    }
-
     public String getType() {
         return CONFIGURATION_TYPE;
     }
+    
+    protected String getClientAddress(Map<String, Object> sd, Class<?> iClass) {
+        return OsgiUtils.getFirstNonEmptyStringProperty(sd, 
+                RemoteConstants.ENDPOINT_ID,
+                Constants.WS_ADDRESS_PROPERTY,
+                Constants.WS_ADDRESS_PROPERTY,
+                Constants.WS_ADDRESS_PROPERTY_OLD,
+                Constants.RS_ADDRESS_PROPERTY);
+    }
 
-    protected String getPojoAddress(Map sd, Class<?> iClass) {
+    protected String getServerAddress(Map<String, Object> sd, Class<?> iClass) {
         String address = null;
         try {
-            address = OsgiUtils.getFirstNonEmptyStringProperty(sd, 
-                    RemoteConstants.ENDPOINT_ID,
-                    Constants.WS_ADDRESS_PROPERTY,
-                    Constants.WS_ADDRESS_PROPERTY,
-                    Constants.WS_ADDRESS_PROPERTY_OLD,
-                    Constants.RS_ADDRESS_PROPERTY);
+            address = getClientAddress(sd, iClass);
         } catch (RuntimeException e) {
             LOG.error(e.getMessage(), e);
             return null;
@@ -238,4 +179,18 @@ public abstract class AbstractPojoConfig
         }
         return address;
     }
+    
+    protected final ExportResult createServerFromFactory(ServerFactoryBean factory, Map<String, Object> endpointProps) {
+        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
+            Server server = factory.create();
+            return new ExportResult(endpointProps, server);
+        } catch (Exception e) {
+            return new ExportResult(endpointProps, e);
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldClassLoader);
+        }
+    }
+
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java Wed Nov 28 12:24:01 2012
@@ -18,7 +18,9 @@
  */
 package org.apache.cxf.dosgi.dsw.handlers;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -26,50 +28,65 @@ import org.apache.cxf.dosgi.dsw.Constant
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
+import org.apache.cxf.dosgi.dsw.util.Utils;
 import org.osgi.framework.BundleContext;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class ConfigTypeHandlerFactory {
-    private static final Logger LOG = LoggerFactory.getLogger(ConfigTypeHandlerFactory.class);
+public class ConfigTypeHandlerFactory {
+    private static Logger LOG = LoggerFactory.getLogger(ConfigTypeHandlerFactory.class);
+    // protected because of tests
+    protected static final List<String> supportedConfigurationTypes = new ArrayList<String>();
+
+    static {
+        supportedConfigurationTypes.add(Constants.WSDL_CONFIG_TYPE);
+        supportedConfigurationTypes.add(Constants.RS_CONFIG_TYPE);
+        supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE);
+        supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE_OLD);
+    }
+
+    protected final static String DEFAULT_CONFIGURATION_TYPE = Constants.WS_CONFIG_TYPE;
     private IntentManager intentManager;
+    private HttpServiceManager httpServiceManager;
 
-    public ConfigTypeHandlerFactory(IntentManager intentManager) {
+    public ConfigTypeHandlerFactory(IntentManager intentManager, HttpServiceManager httpServiceManager) {
         this.intentManager = intentManager;
-        
+        this.httpServiceManager = httpServiceManager;
+    }
+    
+    public ConfigurationTypeHandler getHandler(BundleContext dswBC,
+            Map<String, Object> serviceProperties, 
+            Map<String, Object> props) {
+        List<String> configurationTypes = determineConfigurationTypes(serviceProperties);
+        return getHandler(dswBC, configurationTypes, serviceProperties, props);
+    }
+    
+    public ConfigurationTypeHandler getHandler(BundleContext dswBC, EndpointDescription endpoint) {
+        List<String> configurationTypes = determineConfigTypesForImport(endpoint);
+        return getHandler(dswBC, configurationTypes, endpoint.getProperties(), Collections.<String, Object>emptyMap());
     }
 
-    public ConfigurationTypeHandler getHandler(BundleContext dswBC, List<String> configurationTypes,
-                                               Map serviceProperties, Map<String, Object> props) {
-
+    private ConfigurationTypeHandler getHandler(BundleContext dswBC,
+                                               List<String> configurationTypes,
+                                               Map<String, Object> serviceProperties, 
+                                               Map<String, Object> props) {
+        intentManager.assertAllIntentsSupported(serviceProperties);
         if (configurationTypes.contains(Constants.WS_CONFIG_TYPE)
             || configurationTypes.contains(Constants.WS_CONFIG_TYPE_OLD) || configurationTypes.contains(Constants.RS_CONFIG_TYPE)) {
 
             boolean jaxrs = isJaxrsRequested(configurationTypes, serviceProperties);
 
-            if (OsgiUtils.getProperty(serviceProperties, Constants.WS_HTTP_SERVICE_CONTEXT) != null
-                || OsgiUtils.getProperty(serviceProperties, Constants.RS_HTTP_SERVICE_CONTEXT) != null
-                || OsgiUtils.getProperty(serviceProperties, Constants.WS_HTTP_SERVICE_CONTEXT_OLD) != null) {
-                return jaxrs
-                    ? new JaxRSHttpServiceConfigurationTypeHandler(dswBC, intentManager, props)
-                    : new HttpServiceConfigurationTypeHandler(dswBC, intentManager, props);
-
-            } else {
-                return jaxrs
-                    ? new JaxRSPojoConfigurationTypeHandler(dswBC, intentManager, props)
-                    : new PojoConfigurationTypeHandler(dswBC, intentManager, props);
-            }
+            return jaxrs ? new JaxRSPojoConfigurationTypeHandler(dswBC, intentManager, httpServiceManager, props)
+                    : new PojoConfigurationTypeHandler(dswBC, intentManager, httpServiceManager, props);
         } else if (configurationTypes.contains(Constants.WSDL_CONFIG_TYPE)) {
-            return new WsdlConfigurationTypeHandler(dswBC, intentManager, props);
+            return new WsdlConfigurationTypeHandler(dswBC, intentManager, httpServiceManager, props);
         }
-
-        LOG.warn("None of the configuration types in " + configurationTypes + " is supported.");
-
-        return null;
+        throw new RuntimeException("None of the configuration types in " + configurationTypes + " is supported.");
     }
 
-    private boolean isJaxrsRequested(Collection<String> types,  Map serviceProperties) {
+    private boolean isJaxrsRequested(Collection<String> types,  Map<String, Object> serviceProperties) {
 
         if (types == null) {
             return false;
@@ -96,5 +113,52 @@ public final class ConfigTypeHandlerFact
         }
         return false;
     }
+    
+    /**
+     * determine which configuration types should be used / if the requested are
+     * supported
+     */
+    private List<String> determineConfigurationTypes(Map<String, Object> serviceProperties) {
+        String[] requestedConfigurationTypes = Utils.normalizeStringPlus(serviceProperties
+                .get(RemoteConstants.SERVICE_EXPORTED_CONFIGS));
+        if (requestedConfigurationTypes == null || requestedConfigurationTypes.length == 0) {
+            return Collections.singletonList(DEFAULT_CONFIGURATION_TYPE);
+        }
+
+        List<String> configurationTypes = new ArrayList<String>();
+        for (String rct : requestedConfigurationTypes) {
+            if (supportedConfigurationTypes.contains(rct)) {
+                configurationTypes.add(rct);
+            }
+        }
+        LOG.info("configuration types selected for export: " + configurationTypes);
+        if (configurationTypes.size() == 0) {
+            throw new RuntimeException("the requested configuration types are not supported");
+        }
+        return configurationTypes;
+    }
+    
+    private List<String> determineConfigTypesForImport(EndpointDescription endpoint) {
+        List<String> remoteConfigurationTypes = endpoint.getConfigurationTypes();
+
+        if (remoteConfigurationTypes == null) {
+            throw new RuntimeException("The supplied endpoint has no configuration type");
+        }
+
+        List<String> usableConfigurationTypes = new ArrayList<String>();
+        for (String ct : supportedConfigurationTypes) {
+            if (remoteConfigurationTypes.contains(ct)) {
+                usableConfigurationTypes.add(ct);
+            }
+        }
+
+        if (usableConfigurationTypes.size() == 0) {
+            throw new RuntimeException("The supplied endpoint has no compatible configuration type. Supported types are: "
+                        + supportedConfigurationTypes
+                        + "    Types needed by the endpoint: "
+                        + remoteConfigurationTypes);
+        }
+        return usableConfigurationTypes;
+    }
 
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java Wed Nov 28 12:24:01 2012
@@ -20,6 +20,7 @@ package org.apache.cxf.dosgi.dsw.handler
 
 import java.util.Map;
 
+import org.apache.cxf.dosgi.dsw.qos.IntentUnsatifiedException;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
@@ -30,12 +31,12 @@ public interface ConfigurationTypeHandle
     ExportResult createServer(ServiceReference serviceReference,
                         BundleContext dswContext,
                         BundleContext callingContext, 
-                        Map sd, 
+                        Map<String, Object> sd, 
                         Class<?> iClass, 
                         Object serviceBean);
 
     Object createProxy(ServiceReference serviceReference,
                        BundleContext dswContext,
                        BundleContext callingContext,
-                       Class<?> iClass, EndpointDescription sd);
+                       Class<?> iClass, EndpointDescription sd) throws IntentUnsatifiedException;
 }

Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java?rev=1414645&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java Wed Nov 28 12:24:01 2012
@@ -0,0 +1,155 @@
+/** 
+ * 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. 
+ */
+package org.apache.cxf.dosgi.dsw.handlers;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
+import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceException;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpContext;
+import org.osgi.service.http.HttpService;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HttpServiceManager {
+    private static final Logger LOG = LoggerFactory.getLogger(HttpServiceManager.class);
+    private ServiceTracker tracker;
+    private BundleContext bundleContext;
+    private Map<Long, String> exportedAliases = Collections.synchronizedMap(new HashMap<Long, String>());
+
+    public HttpServiceManager(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+        this.tracker = new ServiceTracker(bundleContext, HttpService.class.getName(), null);
+        this.tracker.open();
+    }
+    
+    public HttpServiceManager(BundleContext bundleContext, ServiceTracker tracker) {
+        this.bundleContext = bundleContext;
+        this.tracker = tracker;
+    }
+    
+    public Bus registerServletAndGetBus(String contextRoot, BundleContext dswContext,
+            ServiceReference sref) {
+        CXFNonSpringServlet cxf = new CXFNonSpringServlet();
+        try {
+            HttpService httpService = getHttpService();
+            httpService.registerServlet(contextRoot, cxf, new Hashtable<String, String>(), 
+                                       getHttpContext(dswContext, httpService));
+            registerUnexportHook(sref, contextRoot);
+            
+            LOG.info("Successfully registered CXF DOSGi servlet at " + contextRoot);
+        } catch (Exception e) {
+            throw new ServiceException("CXF DOSGi: problem registering CXF HTTP Servlet", e);
+        }
+        return cxf.getBus();
+    }
+
+    protected HttpService getHttpService() {
+        Object service = tracker.getService();
+        if (service == null) {
+            throw new RuntimeException("No HTTPService found");
+        }
+        return (HttpService) service;
+    }
+
+    public String getServletContextRoot(Map<?, ?> sd, Class<?> iClass) {
+        return OsgiUtils.getFirstNonEmptyStringProperty(sd, 
+                Constants.WS_HTTP_SERVICE_CONTEXT,
+                Constants.WS_HTTP_SERVICE_CONTEXT_OLD,
+                Constants.WSDL_HTTP_SERVICE_CONTEXT,
+                Constants.RS_HTTP_SERVICE_CONTEXT);
+    }
+
+    private HttpContext getHttpContext(BundleContext bundleContext, HttpService httpService) {
+        HttpContext httpContext = httpService.createDefaultHttpContext();
+        return new SecurityDelegatingHttpContext(bundleContext, httpContext);
+    }
+    
+    /**
+     * This listens for service removal events and "un-exports" the service
+     * from the HttpService.
+     * 
+     * @param reference The service reference to track
+     * @param alias The HTTP servlet context alias
+     */
+    private void registerUnexportHook(ServiceReference sref, String alias) {
+        final Long sid = (Long) sref.getProperty(org.osgi.framework.Constants.SERVICE_ID);
+        LOG.debug("Registering service listener for service with ID {}", sid);
+     
+        String previous = exportedAliases.put(sid, alias);
+        if(previous != null) {
+            LOG.warn("Overwriting service export for service with ID {}", sid);
+        }
+        
+        try {
+            Filter f = bundleContext.createFilter("(" + org.osgi.framework.Constants.SERVICE_ID + "=" + sid + ")");
+            
+            if(f != null) {
+                bundleContext.addServiceListener(new UnregisterListener(), f.toString());
+            } else {
+                LOG.warn("Service listener could not be started. The service will not be automatically unexported.");
+            }
+        } catch (InvalidSyntaxException e) {
+            LOG.warn("Service listener could not be started. The service will not be automatically unexported.", e);
+        }
+    }
+    
+    public void close() {
+        tracker.close();
+    }
+    
+    private final class UnregisterListener implements ServiceListener {
+        public void serviceChanged(ServiceEvent event) {
+
+            if (!(event.getType() == ServiceEvent.UNREGISTERING)) {
+                return;
+            }
+            final ServiceReference sref = event.getServiceReference();
+            final Long sid = (Long) sref.getProperty(org.osgi.framework.Constants.SERVICE_ID);
+            final String alias = exportedAliases.remove(sid);
+            if (alias == null) {
+                LOG.error(
+                        "Unable to unexport HTTP servlet for service class ''{0}'', service-id {1}: no servlet alias found",
+                        new Object[] { sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS), sid });
+                return;
+            }
+            LOG.debug("Unexporting HTTP servlet for alias '{}'", alias);
+            try {
+                HttpService http = getHttpService();
+                http.unregister(alias);
+            } catch (Exception e) {
+                LOG.warn("An exception occurred while unregistering service for HTTP servlet alias '" 
+                        + alias + "'", e);
+            }
+        }
+    }
+}

Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/InterceptorUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/InterceptorUtils.java?rev=1414645&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/InterceptorUtils.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/InterceptorUtils.java Wed Nov 28 12:24:01 2012
@@ -0,0 +1,93 @@
+/** 
+ * 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. 
+ */
+package org.apache.cxf.dosgi.dsw.handlers;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.util.ClassUtils;
+import org.apache.cxf.endpoint.AbstractEndpointFactory;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Interceptor;
+import org.osgi.framework.BundleContext;
+
+public class InterceptorUtils {
+
+    protected static void addWsInterceptorsFeaturesProps(
+            AbstractEndpointFactory factory, BundleContext callingContext, Map<String, Object> sd) {
+        addInterceptors(factory, callingContext, sd, Constants.WS_IN_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, Constants.WS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, Constants.WS_IN_FAULT_INTERCEPTORS_PROP_KEY);
+        addFeatures(factory, callingContext, sd, Constants.WS_FEATURES_PROP_KEY);
+        addContextProperties(factory, callingContext, sd, Constants.WS_CONTEXT_PROPS_PROP_KEY);
+    }
+    
+    static void addRsInterceptorsFeaturesProps(
+            AbstractEndpointFactory factory, BundleContext callingContext, Map<String, Object> sd) {
+        addInterceptors(factory, callingContext, sd, Constants.RS_IN_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, Constants.RS_OUT_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, Constants.RS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, Constants.RS_IN_FAULT_INTERCEPTORS_PROP_KEY);
+        addFeatures(factory, callingContext, sd, Constants.RS_FEATURES_PROP_KEY);
+        addContextProperties(factory, callingContext, sd, Constants.RS_CONTEXT_PROPS_PROP_KEY);
+    }
+
+    private static void addInterceptors(AbstractEndpointFactory factory, BundleContext callingContext, 
+            Map<String, Object> sd, String propName) {
+
+        List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName); 
+        boolean in = propName.contains("in.interceptors");
+        boolean out = propName.contains("out.interceptors");
+        boolean in_fault = propName.contains("in.fault.interceptors");
+        boolean out_fault = propName.contains("out.fault.interceptors");
+        for (int i = 0; i < providers.size(); i++) {
+            Interceptor<?> interceptor = (Interceptor<?>)providers.get(i);  
+            if (in) {
+                factory.getInInterceptors().add(interceptor);
+            } else if (out) {
+                factory.getOutInterceptors().add(interceptor);
+            } else if (in_fault) {
+                factory.getInFaultInterceptors().add(interceptor);
+            } else if (out_fault) {
+                factory.getOutFaultInterceptors().add(interceptor);
+            }
+        }
+    }
+       
+    private static void addFeatures(AbstractEndpointFactory factory, BundleContext callingContext, 
+            Map<String, Object> sd, String propName) {
+
+        List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName); 
+        if (providers.size() > 0) {
+            factory.getFeatures().addAll(CastUtils.cast(providers, AbstractFeature.class));
+        }
+    }
+    
+    private static void addContextProperties(AbstractEndpointFactory factory, BundleContext callingContext, 
+            Map<String, Object> sd, String propName) {
+        @SuppressWarnings("unchecked")
+        Map<String, Object> props = (Map<String, Object>)sd.get(propName);
+        if (props != null) {
+            factory.getProperties(true).putAll(props);
+        }
+    }
+}

Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/InterceptorUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java Wed Nov 28 12:24:01 2012
@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.qos.IntentUnsatifiedException;
@@ -41,19 +42,17 @@ import org.osgi.service.remoteserviceadm
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class JaxRSPojoConfigurationTypeHandler extends PojoConfigurationTypeHandler {
+public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
     private static final Logger LOG = LoggerFactory.getLogger(JaxRSPojoConfigurationTypeHandler.class);
 
     Set<ServiceReference> httpServiceReferences = new CopyOnWriteArraySet<ServiceReference>();
 
-    protected JaxRSPojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager, Map<String, Object> handlerProps) {
-        super(dswBC, intentManager, handlerProps);
+    protected JaxRSPojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager, HttpServiceManager httpServiceManager, Map<String, Object> handlerProps) {
+        super(dswBC, intentManager, httpServiceManager, handlerProps);
     }
 
-    @Override
     public Object createProxy(ServiceReference serviceReference, BundleContext dswContext,
-                              BundleContext callingContext, Class<?> iClass, EndpointDescription sd)
-        throws IntentUnsatifiedException {
+                              BundleContext callingContext, Class<?> iClass, EndpointDescription sd) throws IntentUnsatifiedException {
 
         String address = getPojoAddress(sd, iClass);
         if (address == null) {
@@ -93,7 +92,7 @@ public class JaxRSPojoConfigurationTypeH
         	bean.setClassLoader(loader);
         }
         
-        addRsInterceptorsFeaturesProps(bean, callingContext, sd.getProperties());
+        InterceptorUtils.addRsInterceptorsFeaturesProps(bean, callingContext, sd.getProperties());
         
         List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
         if (resources != null) {
@@ -110,21 +109,46 @@ public class JaxRSPojoConfigurationTypeH
         return proxy;
     }
     
-    @Override
     public ExportResult createServer(ServiceReference sref, BundleContext dswContext,
-                             BundleContext callingContext, Map sd, Class<?> iClass, Object serviceBean)
-        throws IntentUnsatifiedException {
+                             BundleContext callingContext, Map<String, Object> sd, Class<?> iClass, Object serviceBean) throws IntentUnsatifiedException {
 
-        String address = getPojoAddress(sd, iClass);
-        if (address == null) {
-            throw new RuntimeException("Remote address is unavailable");
-        }
+        String address = getServerAddress(sd, iClass);
+        String contextRoot = httpServiceManager.getServletContextRoot(sd, iClass);
+
+        Bus bus = contextRoot != null ? httpServiceManager.registerServletAndGetBus(contextRoot, dswContext, sref) : null;
 
         LOG.info("Creating a " + iClass.getName()
                  + " endpoint via JaxRSPojoConfigurationTypeHandler, address is " + address);
 
-        JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
+        JAXRSServerFactoryBean factory = createServerFactory(dswContext, callingContext, sd, iClass, serviceBean, address, bus);
+        String completeEndpointAddress = constructAddress(dswContext, contextRoot, address);
 
+        // The properties for the EndpointDescription
+        Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[] { Constants.RS_CONFIG_TYPE },
+                completeEndpointAddress, new String[] { "HTTP" });
+
+        return createServerFromFactory(factory, endpointProps);
+    }
+    
+    private final ExportResult createServerFromFactory(JAXRSServerFactoryBean factory, Map<String, Object> endpointProps) {
+        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
+            Server server = factory.create();
+            return new ExportResult(endpointProps, server);
+        } catch (Exception e) {
+            return new ExportResult(endpointProps, e);
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldClassLoader);
+        }
+    }
+    
+    private JAXRSServerFactoryBean createServerFactory(BundleContext dswContext, BundleContext callingContext, Map<String, Object> sd,
+            Class<?> iClass, Object serviceBean, String address, Bus bus) {
+        JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
+        if (bus !=null) {
+            factory.setBus(bus);
+        }
         List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
         if (resources != null) {
             factory.setModelBeansWithServiceClass(resources, iClass);
@@ -133,40 +157,20 @@ public class JaxRSPojoConfigurationTypeH
             factory.setServiceClass(iClass);
             factory.setResourceProvider(iClass, new SingletonResourceProvider(serviceBean));
         }
-
         factory.setAddress(address);
         List<Object> providers = JaxRSUtils.getProviders(callingContext, dswContext, sd);
         if (providers != null && providers.size() > 0) {
             factory.setProviders(providers);
         }
-
-        addRsInterceptorsFeaturesProps(factory, callingContext, sd);
-
+        InterceptorUtils.addRsInterceptorsFeaturesProps(factory, callingContext, sd);
         String location = OsgiUtils.getProperty(sd, Constants.RS_WADL_LOCATION);
-    	if (location != null) {
-    		URL wadlURL = callingContext.getBundle().getResource(location);
-                if (wadlURL != null) {
-	            factory.setDocLocation(wadlURL.toString());
-                }
-    	}
-        
-        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
-        String[] intents = new String[] { "HTTP" };
-
-        // The properties for the EndpointDescription
-        Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[] { Constants.RS_CONFIG_TYPE },
-                address, intents);
-
-        try {
-            Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
-            Server server = factory.create();
-            return new ExportResult(endpointProps, server);
-        } catch (Exception e) {
-            return new ExportResult(endpointProps, e);
-        } finally {
-            Thread.currentThread().setContextClassLoader(oldClassLoader);
+        if (location != null) {
+            URL wadlURL = callingContext.getBundle().getResource(location);
+            if (wadlURL != null) {
+                factory.setDocLocation(wadlURL.toString());
+            }
         }
-
+        return factory;
     }
 
     protected String getPojoAddress(EndpointDescription sd, Class<?> iClass) {

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java Wed Nov 28 12:24:01 2012
@@ -31,7 +31,6 @@ import org.apache.cxf.jaxrs.model.UserRe
 import org.apache.cxf.jaxrs.provider.aegis.AegisElementProvider;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,22 +41,18 @@ public class JaxRSUtils {
 
     public final static String MODEL_FOLDER = "/OSGI-INF/cxf/jaxrs/";
     public final static String DEFAULT_MODEL = "/OSGI-INF/cxf/jaxrs/model.xml";
-    public final static String PROVIDERS_FILTER = "(|" + "(" + Constants.OBJECTCLASS
-                                                  + "=javax.ws.rs.ext.MessageBodyReader" + ")" + "("
-                                                  + Constants.OBJECTCLASS
-                                                  + "=javax.ws.rs.ext.MessageBodyWriter" + ")" + "("
-                                                  + Constants.OBJECTCLASS
-                                                  + "=javax.ws.rs.ext.ExceptionMapper" + ")" + "("
-                                                  + Constants.OBJECTCLASS
-                                                  + "=org.apache.cxf.jaxrs.ext.RequestHandler" + ")" + "("
-                                                  + Constants.OBJECTCLASS
-                                                  + "=org.apache.cxf.jaxrs.ext.ResponseHandler" + ")" + "("
-                                                  + Constants.OBJECTCLASS
-                                                  + "=org.apache.cxf.jaxrs.ext.ParameterHandler" + ")" + "("
-                                                  + Constants.OBJECTCLASS
-                                                  + "=org.apache.cxf.jaxrs.ext.ResponseExceptionMapper" + ")" + ")";
+    public final static String PROVIDERS_FILTER = "(|" 
+            + "(objectClass=javax.ws.rs.ext.MessageBodyReader)"
+            + "(objectClass=javax.ws.rs.ext.MessageBodyWriter)" 
+            + "(objectClass=javax.ws.rs.ext.ExceptionMapper)" 
+            + "(objectClass=org.apache.cxf.jaxrs.ext.RequestHandler)" 
+            + "(objectClass=org.apache.cxf.jaxrs.ext.ResponseHandler)" 
+            + "(objectClass=org.apache.cxf.jaxrs.ext.ParameterHandler)" 
+            + "(objectClass=org.apache.cxf.jaxrs.ext.ResponseExceptionMapper)" 
+            + ")";
 
-    public static List<Object> getProviders(BundleContext callingContext, BundleContext dswBC, Map sd) {
+    @SuppressWarnings("rawtypes")
+    static List<Object> getProviders(BundleContext callingContext, BundleContext dswBC, Map sd) {
 
         List<Object> providers = new ArrayList<Object>();
         if ("aegis".equals(sd.get(org.apache.cxf.dosgi.dsw.Constants.RS_DATABINDING_PROP_KEY))) {
@@ -96,15 +91,13 @@ public class JaxRSUtils {
         return providers;
     }
 
-    
-
-    public static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass) {
+    static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass) {
         String classModel = MODEL_FOLDER + iClass.getSimpleName() + "-model.xml";
         List<UserResource> list = getModel(callingContext, iClass, classModel);
         return list != null ? list : getModel(callingContext, iClass, DEFAULT_MODEL);
     }
 
-    public static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass, String name) {
+    private static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass, String name) {
         InputStream r = iClass.getClassLoader().getResourceAsStream(name);
         if (r == null) {
             URL u = callingContext.getBundle().getResource(name);

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java Wed Nov 28 12:24:01 2012
@@ -79,4 +79,13 @@ public class LocalHostUtil {
             throw new UnknownHostException("127.0.0.1");
         }
     }
+
+    public static Object getLocalHostAddress() {
+        try {
+            String host = LocalHostUtil.getLocalHost().getHostAddress();
+            return (host == null) ? "localhost" : host;
+        } catch (Exception e) {
+            return "localhost";
+        }
+    }
 }

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=1414645&r1=1414644&r2=1414645&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 Wed Nov 28 12:24:01 2012
@@ -20,15 +20,12 @@ package org.apache.cxf.dosgi.dsw.handler
 
 import java.util.Map;
 
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.Bus;
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.qos.IntentUnsatifiedException;
-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.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
@@ -38,15 +35,13 @@ import org.slf4j.LoggerFactory;
 public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
     private static final Logger LOG = LoggerFactory.getLogger(PojoConfigurationTypeHandler.class);
 
-    public PojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager, Map<String, Object> handlerProps) {
-        super(dswBC, intentManager, handlerProps);
+    public PojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager, HttpServiceManager httpServiceManager, Map<String, Object> handlerProps) {
+        super(dswBC, intentManager, httpServiceManager, handlerProps);
     }
 
     public Object createProxy(ServiceReference serviceReference, BundleContext dswContext,
-                              BundleContext callingContext, Class<?> iClass, EndpointDescription sd)
-        throws IntentUnsatifiedException {
-        //
-        String address = getPojoAddress(sd.getProperties(), iClass);
+            BundleContext callingContext, Class<?> iClass, EndpointDescription sd) throws IntentUnsatifiedException {
+        String address = getClientAddress(sd.getProperties(), iClass);
         if (address == null) {
             LOG.warn("Remote address is unavailable");
             // TODO: fire Event
@@ -60,9 +55,9 @@ public class PojoConfigurationTypeHandle
             ClientProxyFactoryBean factory = createClientProxyFactoryBean(serviceReference, iClass);
             factory.setServiceClass(iClass);
             factory.setAddress(address);
-            addWsInterceptorsFeaturesProps(factory.getClientFactoryBean(), callingContext, sd.getProperties());
+            InterceptorUtils.addWsInterceptorsFeaturesProps(factory.getClientFactoryBean(), callingContext, sd.getProperties());
             setClientWsdlProperties(factory.getClientFactoryBean(), dswContext, sd.getProperties(), false);
-            
+
             intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd.getProperties());
 
             Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
@@ -75,43 +70,30 @@ public class PojoConfigurationTypeHandle
         }
         return null;
     }
-
+    
     public ExportResult createServer(ServiceReference sref, BundleContext dswContext,
-                             BundleContext callingContext, Map sd, Class<?> iClass, Object serviceBean)
-        throws IntentUnsatifiedException {
-        String address = getPojoAddress(sd, iClass);
-        if (address == null) {
-            throw new RuntimeException("Remote address is unavailable");
-        }
-
-        LOG.info("Creating a " + iClass.getName() + " endpoint from CXF PublishHook, address is " + address);
-
+                             BundleContext callingContext, Map<String, Object> sd, Class<?> iClass, Object serviceBean) throws IntentUnsatifiedException {
+        String address = getServerAddress(sd, iClass);
+        String contextRoot = httpServiceManager.getServletContextRoot(sd, iClass);
+        
         ServerFactoryBean factory = createServerFactoryBean(sref, iClass);
+        if (contextRoot != null) {
+            Bus bus = httpServiceManager.registerServletAndGetBus(contextRoot, dswContext, sref);
+            factory.setBus(bus);
+        }
         factory.setServiceClass(iClass);
         factory.setAddress(address);
         factory.setServiceBean(serviceBean);
-
-        addWsInterceptorsFeaturesProps(factory, callingContext, sd);
+        InterceptorUtils.addWsInterceptorsFeaturesProps(factory, callingContext, sd);
         setWsdlProperties(factory, callingContext, sd, false);
-        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
-        
         String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
+        
+        String completeEndpointAddress = constructAddress(dswContext, contextRoot, address);
 
         // The properties for the EndpointDescription
-        Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[]{Constants.WS_CONFIG_TYPE}, address,intents);
+        Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[]{Constants.WS_CONFIG_TYPE}, completeEndpointAddress,intents);
 
-        try {
-            Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
-            Server server = factory.create();
-            return new ExportResult(endpointProps, server);                
-        } catch (Exception e) {
-            return new ExportResult(endpointProps, e);
-        } finally {
-            Thread.currentThread().setContextClassLoader(oldClassLoader);
-        }
+        return createServerFromFactory(factory, endpointProps);
     }
 
-    
-
-
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java Wed Nov 28 12:24:01 2012
@@ -26,16 +26,11 @@ import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.binding.BindingConfiguration;
-import org.apache.cxf.binding.soap.SoapBindingConfiguration;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
-import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.osgi.framework.BundleContext;
@@ -44,14 +39,16 @@ import org.osgi.service.remoteserviceadm
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class WsdlConfigurationTypeHandler extends HttpServiceConfigurationTypeHandler {
+@SuppressWarnings("restriction")
+public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
     private static final String CONFIGURATION_TYPE = "wsdl";
     private static final Logger LOG = LoggerFactory.getLogger(WsdlConfigurationTypeHandler.class);
     
     public WsdlConfigurationTypeHandler(BundleContext dswBC,
                                         IntentManager intentManager,
+                                        HttpServiceManager httpServiceManager,
                                         Map<String, Object> handlerProps) {
-        super(dswBC, intentManager, handlerProps);
+        super(dswBC, intentManager, httpServiceManager, handlerProps);
     }
     
     public String getType() {
@@ -107,11 +104,10 @@ public class WsdlConfigurationTypeHandle
         return Service.create(wsdlAddress, serviceQname);
     }
 
-    @Override
     public ExportResult createServer(ServiceReference sref,
                                BundleContext dswContext,
                                BundleContext callingContext,
-                               Map sd, 
+                               Map<String, Object> sd, 
                                Class<?> iClass, 
                                Object serviceBean) {
         
@@ -124,52 +120,35 @@ public class WsdlConfigurationTypeHandle
             throw new RuntimeException("WSDL resource at " + location + " is unavailable");
     	}
         
-    	String address = getPojoAddress(sd, iClass);
-    	String contextRoot = null;
-        if (address == null) {
-        	contextRoot = getServletContextRoot(sd, iClass);
-        	if (contextRoot == null) {
-        	    throw new RuntimeException("Remote address is unavailable");
-        	}
+    	String address = getServerAddress(sd, iClass);
+    	String contextRoot = httpServiceManager.getServletContextRoot(sd, iClass);
+        if (address == null && contextRoot == null) {
+            throw new RuntimeException("Remote address is unavailable");
         }
 
         LOG.info("Creating a " + iClass.getName() + " endpoint from CXF PublishHook, address is " + address);
 
-        Bus bus = null;
-        if (contextRoot != null) {
-        	bus = registerServletAndGetBus(contextRoot, dswContext, sref);
-        }
-        
         DataBinding databinding = new JAXBDataBinding();
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
-
+        if (contextRoot != null) {
+            Bus bus = httpServiceManager.registerServletAndGetBus(contextRoot, dswContext, sref);
+            factory.setBus(bus);
+        }
         factory.setServiceClass(iClass);
         factory.setAddress(address != null ? address : "/");
         factory.getServiceFactory().setDataBinding(databinding);
         factory.setServiceBean(serviceBean);
 
-        addWsInterceptorsFeaturesProps(factory, callingContext, sd);
+        InterceptorUtils.addWsInterceptorsFeaturesProps(factory, callingContext, sd);
         
         setWsdlProperties(factory, callingContext, sd, true);
-        if (bus != null) {
-        	factory.setBus(bus);
-        }
         
         String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
 
         // The properties for the EndpointDescription
         Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[]{Constants.WS_CONFIG_TYPE}, address,intents);
 
-        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
-        try {
-            Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
-            Server server = factory.create();
-            return new ExportResult(endpointProps, server);
-        } catch (Exception e) {
-            return new ExportResult(endpointProps, e);
-        } finally {
-            Thread.currentThread().setContextClassLoader(oldClassLoader);
-        }
+        return createServerFromFactory(factory, endpointProps);
     }
     
     private String getWsdlAddress(EndpointDescription sd, Class<?> iClass) {

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManager.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManager.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManager.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManager.java Wed Nov 28 12:24:01 2012
@@ -20,12 +20,11 @@ package org.apache.cxf.dosgi.dsw.qos;
 
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.feature.Feature;
 
 public interface IntentManager {
     String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory, Map<String, Object> props);
-    void assertAllIntentsSupported(Properties serviceProperties);
+    void assertAllIntentsSupported(Map<String, Object> serviceProperties);
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImpl.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImpl.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImpl.java Wed Nov 28 12:24:01 2012
@@ -24,7 +24,6 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 
 import org.apache.cxf.binding.BindingConfiguration;
@@ -118,7 +117,7 @@ public class IntentManagerImpl implement
         return intentsFound;
     }
     
-    public void assertAllIntentsSupported(Properties serviceProperties) {
+    public void assertAllIntentsSupported(Map<String, Object> serviceProperties) {
         long endTime = System.currentTimeMillis() + maxIntentWaitTime;
         Set<String> requiredIntents = IntentUtils.getRequestedIntents(serviceProperties);
         List<String> unsupportedIntents = new ArrayList<String>();

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java Wed Nov 28 12:24:01 2012
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -36,7 +35,6 @@ import org.apache.cxf.dosgi.dsw.Constant
 import org.apache.cxf.dosgi.dsw.handlers.ConfigTypeHandlerFactory;
 import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
 import org.apache.cxf.dosgi.dsw.handlers.ExportResult;
-import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.util.ClassUtils;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.util.Utils;
@@ -69,28 +67,14 @@ public class RemoteServiceAdminCore impl
     private volatile String defaultHost;
 
     private ConfigTypeHandlerFactory configTypeHandlerFactory;
-    private IntentManager intentManager;
 
-    // protected because of tests
-    protected static final List<String> supportedConfigurationTypes = new ArrayList<String>();
-
-    static {
-        supportedConfigurationTypes.add(Constants.WSDL_CONFIG_TYPE);
-        supportedConfigurationTypes.add(Constants.RS_CONFIG_TYPE);
-        supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE);
-        supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE_OLD);
-    }
-
-    protected final static String DEFAULT_CONFIGURATION = Constants.WS_CONFIG_TYPE;
-
-    public RemoteServiceAdminCore(BundleContext bc, IntentManager intentManager) {
+    public RemoteServiceAdminCore(BundleContext bc, ConfigTypeHandlerFactory configTypeHandlerFactory) {
         bctx = bc;
-        this.intentManager = intentManager;
         eventProducer = new EventProducer(bctx);
-        this.configTypeHandlerFactory = new ConfigTypeHandlerFactory(intentManager);
+        this.configTypeHandlerFactory = configTypeHandlerFactory;
     }
 
-    @SuppressWarnings("rawtypes")
+    @SuppressWarnings({ "rawtypes", "unchecked" })
 	public List<ExportRegistration> exportService(ServiceReference serviceReference, Map additionalProperties)
         throws IllegalArgumentException, UnsupportedOperationException {
 
@@ -114,13 +98,6 @@ public class RemoteServiceAdminCore impl
                 OsgiUtils.overlayProperties(serviceProperties, additionalProperties);
             }
 
-            try {
-                intentManager.assertAllIntentsSupported(serviceProperties);
-            } catch (RuntimeException e) {
-                LOG.error(e.getMessage(), e);
-                return Collections.emptyList();
-            }
-
             List<String> interfaces = getInterfaces(serviceProperties);
             if (interfaces.size() == 0) {
                 LOG.error("export failed: no provided service interfaces found or service_exported_interfaces is null !!");
@@ -129,31 +106,27 @@ public class RemoteServiceAdminCore impl
             }
             LOG.info("interfaces selected for export: " + interfaces);
 
-            List<String> configurationTypes = determineConfigurationTypes(serviceProperties);
-            LOG.info("configuration types selected for export: " + configurationTypes);
-            if (configurationTypes.size() == 0) {
-                LOG.info("the requested configuration types are not supported");
-                // TODO: publish error event ? not sure
-                return Collections.emptyList();
-            }
+            
 
             LinkedHashMap<String, ExportRegistrationImpl> exportRegs = new LinkedHashMap<String, ExportRegistrationImpl>(1);
             Object serviceObject = bctx.getService(serviceReference);
             BundleContext callingContext = serviceReference.getBundle().getBundleContext();
-            ConfigurationTypeHandler handler = getHandler(configurationTypes, serviceProperties, getHandlerProperties());
-            if (handler == null) {
-                // TODO: publish error event ? not sure
+            ConfigurationTypeHandler handler = null;
+            try {
+                handler = configTypeHandlerFactory.getHandler(bctx, (Map)serviceProperties, getHandlerProperties());
+            } catch (RuntimeException e) {
+                LOG.error(e.getMessage(), e);
                 return Collections.emptyList();
             }
 
             // FIXME: move out of synchronized ... -> blocks until publication is finished
             for (String iface : interfaces) {
-                LOG.info("creating server for interface " + iface + " with configurationTypes " + configurationTypes);
+                LOG.info("creating server for interface " + iface);
                 // this is an extra sanity check, but do we really need it now ?
                 Class<?> interfaceClass = ClassUtils.getInterfaceClass(serviceObject, iface);
                 if (interfaceClass != null) {
                     ExportResult exportResult = handler.createServer(serviceReference, bctx, callingContext,
-                            serviceProperties, interfaceClass, serviceObject);
+                            (Map)serviceProperties, interfaceClass, serviceObject);
                     LOG.info("created server for interface " + iface);
                     EndpointDescription epd = new EndpointDescription(exportResult.getEndpointProps());
                     ExportRegistrationImpl exportRegistration = new ExportRegistrationImpl(serviceReference, epd, this);
@@ -240,30 +213,6 @@ public class RemoteServiceAdminCore impl
     }
 
 
-    protected List<String> determineConfigurationTypes(Properties serviceProperties) {
-
-        List<String> configurationTypes = new ArrayList<String>();
-
-        {// determine which configuration types should be used / if the requested are supported
-            String[] requestedConfigurationTypes = Utils.normalizeStringPlus(serviceProperties
-                .get(RemoteConstants.SERVICE_EXPORTED_CONFIGS));
-            if (requestedConfigurationTypes == null || requestedConfigurationTypes.length == 0) {
-                // add default configuration
-                configurationTypes.add(DEFAULT_CONFIGURATION);
-            } else {
-                for (String rct : requestedConfigurationTypes) {
-                    if (supportedConfigurationTypes.contains(rct)) {
-                        // this RSA supports this requested type ...
-                        configurationTypes.add(rct);
-                    }
-                }
-            }
-
-        }
-
-        return configurationTypes;
-    }
-
     private boolean isCreatedByThisRSA(ServiceReference sref) {
         return (sref.getBundle() != null ) && sref.getBundle().equals(bctx.getBundle());
     }
@@ -292,12 +241,6 @@ public class RemoteServiceAdminCore impl
         }
     }
 
-    private ConfigurationTypeHandler getHandler(List<String> configurationTypes, Map<?, ?> serviceProperties,
-                                                Map<String, Object> props) {
-        return configTypeHandlerFactory.getHandler(bctx, configurationTypes, serviceProperties,
-                                                                 props);
-    }
-
     protected Map<String, Object> getHandlerProperties() {
         Map<String, Object> props = new HashMap<String, Object>();
         props.put(Constants.DEFAULT_PORT_CONFIG, defaultPort == null
@@ -326,34 +269,11 @@ public class RemoteServiceAdminCore impl
                 return ir;
             }
 
-            List<String> remoteConfigurationTypes = endpoint.getConfigurationTypes();
-
-            if (remoteConfigurationTypes == null) {
-                LOG.error("the supplied endpoint has no configuration type");
-                return null;
-            }
-
-            List<String> usableConfigurationTypes = new ArrayList<String>();
-            for (String ct : supportedConfigurationTypes) {
-                if (remoteConfigurationTypes.contains(ct)) {
-                    usableConfigurationTypes.add(ct);
-                }
-            }
-
-            if (usableConfigurationTypes.size() == 0) {
-                LOG.error("the supplied endpoint has no compatible configuration type. Supported types are: "
-                            + supportedConfigurationTypes
-                            + "    Types needed by the endpoint: "
-                            + remoteConfigurationTypes);
-                return null;
-            }
-
-            Map<String, Object> emptyProps = Collections.emptyMap();
-            ConfigurationTypeHandler handler = getHandler(usableConfigurationTypes, endpoint.getProperties(),
-                                                          emptyProps);
-
-            if (handler == null) {
-                LOG.error("no handler found");
+            ConfigurationTypeHandler handler = null;
+            try {
+                handler = configTypeHandlerFactory.getHandler(bctx, endpoint);
+            } catch (RuntimeException e) {
+                LOG.error("no handler found: " + e.getMessage(), e);
                 return null;
             }
 
@@ -411,7 +331,6 @@ public class RemoteServiceAdminCore impl
             Dictionary<String, Object> serviceProps = new Hashtable<String, Object>(ed.getProperties());
             serviceProps.put(RemoteConstants.SERVICE_IMPORTED, true);
             serviceProps.remove(RemoteConstants.SERVICE_EXPORTED_INTERFACES);
-            intentManager.assertAllIntentsSupported(getProperties(serviceProps));
                 
             // synchronized (discoveredServices) {
             ClientServiceFactory csf = new ClientServiceFactory(actualContext, iClass, ed, handler, imReg);
@@ -427,16 +346,6 @@ public class RemoteServiceAdminCore impl
         }
     }
 
-    private Properties getProperties(Dictionary<String, Object> serviceProps) {
-        Properties props = new Properties();
-        Enumeration<String> keys = serviceProps.keys();
-        while (keys.hasMoreElements()) {
-            String key = keys.nextElement();
-            props.put(key, serviceProps.get(key));
-        }
-        return props;
-    }
-
     /**
      * Removes the provided Export Registration from the internal management structures -> intended to be used
      * when the export Registration is closed

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java?rev=1414645&r1=1414644&r2=1414645&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java Wed Nov 28 12:24:01 2012
@@ -21,9 +21,7 @@ package org.apache.cxf.dosgi.dsw.service
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
@@ -36,8 +34,8 @@ public class RemoteServiceadminFactory i
 
     private RemoteServiceAdminCore rsaCore;
 
-    public RemoteServiceadminFactory(BundleContext bc, IntentManager intentManager) {
-    	this.rsaCore = new RemoteServiceAdminCore(bc, intentManager);
+    public RemoteServiceadminFactory(RemoteServiceAdminCore rsaCore) {
+    	this.rsaCore = rsaCore;
     }
 
     public Object getService(Bundle b, ServiceRegistration sr) {
@@ -56,12 +54,4 @@ public class RemoteServiceadminFactory i
         }
     }
 
-    public void setRsaCore(RemoteServiceAdminCore rsaCore) {
-        this.rsaCore = rsaCore;
-    }
-
-    public RemoteServiceAdminCore getRsaCore() {
-        return rsaCore;
-    }
-
 }



Mime
View raw message