You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2012/11/21 16:51:38 UTC

svn commit: r1412157 [1/2] - in /cxf/dosgi/trunk: distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ dsw/cxf-dsw/s...

Author: cschneider
Date: Wed Nov 21 15:51:35 2012
New Revision: 1412157

URL: http://svn.apache.org/viewvc?rev=1412157&view=rev
Log:
DOSGI-146 factoring intent handling out into IntentManager

Added:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java   (with props)
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManager.java   (with props)
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImpl.java   (with props)
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentMap.java   (with props)
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/IntentManagerTest.java   (with props)
Removed:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentMapBeanInfo.java
Modified:
    cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java
    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/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/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.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/DefaultIntentMapFactory.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.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/HttpServiceConfigurationTypeHandlerTest.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/IntentUtilsTest.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
    cxf/dosgi/trunk/samples/greeter/impl/src/main/java/org/apache/cxf/dosgi/samples/greeter/impl/Activator.java
    cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java

Modified: cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java?rev=1412157&r1=1412156&r2=1412157&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java (original)
+++ cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java Wed Nov 21 15:51:35 2012
@@ -28,7 +28,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.cxf.dosgi.dsw.Activator;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;

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=1412157&r1=1412156&r2=1412157&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 21 15:51:35 2012
@@ -25,6 +25,9 @@ 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.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.IntentUtils;
 import org.apache.cxf.dosgi.dsw.service.RemoteServiceadminFactory;
@@ -64,8 +67,9 @@ public class Activator implements Manage
     }
 
     private RemoteServiceadminFactory registerRemoteServiceAdminService(BundleContext bc) {
-    	IntentMap intentMap = IntentUtils.getIntentMap(bc);
-        RemoteServiceadminFactory rsaf = new RemoteServiceadminFactory(bc, intentMap);
+        IntentMap intentMap = new IntentMap(new DefaultIntentMapFactory().create());
+        IntentManager intentManager = new IntentManagerImpl(bc, intentMap);
+        RemoteServiceadminFactory rsaf = new RemoteServiceadminFactory(bc, intentManager);
         Hashtable<String, Object> props = new Hashtable<String, Object>();
 
         // TODO .... RemoteAdminService.XXX
@@ -73,7 +77,7 @@ public class Activator implements Manage
         // props.put(DistributionProvider.PRODUCT_VERSION, getHeader("Bundle-Version"));
         // props.put(DistributionProvider.VENDOR_NAME, getHeader("Bundle-Vendor"));
 
-        String[] supportedIntents = intentMap.getIntents().keySet().toArray(new String[] {});
+        String[] supportedIntents = intentMap.keySet().toArray(new String[] {});
         String siString = IntentUtils.formatIntents(supportedIntents);
         props.put("remote.intents.supported", siString);
 

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=1412157&r1=1412156&r2=1412157&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 21 15:51:35 2012
@@ -19,17 +19,12 @@
 package org.apache.cxf.dosgi.dsw.handlers;
 
 import java.lang.reflect.Proxy;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
 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.osgi.framework.BundleContext;
@@ -38,14 +33,15 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractConfigurationHandler implements ConfigurationTypeHandler {
-
     private static final Logger LOG = LoggerFactory.getLogger(AbstractConfigurationHandler.class);
 
-    final Map<String, Object> handlerProps;
+    private final Map<String, Object> handlerProps;
+    protected IntentManager intentManager;
     protected BundleContext bundleContext;
 
-    protected AbstractConfigurationHandler(BundleContext dswBC, Map<String, Object> handlerProps) {
+    protected AbstractConfigurationHandler(BundleContext dswBC, IntentManager intentManager, Map<String, Object> handlerProps) {
         this.bundleContext = dswBC;
+        this.intentManager = intentManager;
         this.handlerProps = handlerProps;
     }
 
@@ -57,7 +53,7 @@ public abstract class AbstractConfigurat
         Object h = handlerProps.get(Constants.DEFAULT_HOST_CONFIG);
         if (h == null || h.toString().equals("localhost")) {
             try {
-                h = getLocalHost().getHostAddress();
+                h = LocalHostUtil.getLocalHost().getHostAddress();
             } catch (Exception e) {
                 h = "localhost";
             }
@@ -85,26 +81,12 @@ public abstract class AbstractConfigurat
         return buf.toString();
     }
 
-    protected boolean useMasterMap() {
-
-        Object value = handlerProps.get(Constants.USE_MASTER_MAP);
-        if (value == null) {
-            return true;
-        }
-
-        return OsgiUtils.toBoolean(value);
-    }
-
     protected Object getProxy(Object serviceProxy, Class<?> iType) {
         return Proxy.newProxyInstance(iType.getClassLoader(), new Class[] {
             iType
         }, new ServiceInvocationHandler(serviceProxy, iType));
     }
 
-    protected BundleContext getBundleContext() {
-        return bundleContext;
-    }
-
     protected Map<String, Object> createEndpointProps(Map sd, Class<?> iClass, String[] importedConfigs,
                                                       String address, String[] intents) {
         Map<String, Object> props = new HashMap<String, Object>();
@@ -117,10 +99,10 @@ public abstract class AbstractConfigurat
         props.remove(org.osgi.framework.Constants.SERVICE_ID);
         props.put(org.osgi.framework.Constants.OBJECTCLASS, sa);
         props.put(RemoteConstants.ENDPOINT_SERVICE_ID, sd.get(org.osgi.framework.Constants.SERVICE_ID));        
-        props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, OsgiUtils.getUUID(getBundleContext()));
+        props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, OsgiUtils.getUUID(bundleContext));
         props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
         props.put(RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + pkg, 
-                OsgiUtils.getVersion(iClass, getBundleContext()));
+                OsgiUtils.getVersion(iClass, bundleContext));
 
         for (String configurationType : importedConfigs) {
             if(Constants.WS_CONFIG_TYPE.equals(configurationType))
@@ -169,72 +151,5 @@ public abstract class AbstractConfigurat
         }
     }
     
-    // Utility methods to get the local address even on a linux host
 
-    /**
-     * Returns an InetAddress representing the address of the localhost. Every attempt is made to find an address for
-     * this host that is not the loopback address. If no other address can be found, the loopback will be returned.
-     * 
-     * @return InetAddress - the address of localhost
-     * @throws UnknownHostException
-     *             - if there is a problem determing the address
-     */
-    public static InetAddress getLocalHost() throws UnknownHostException {
-        InetAddress localHost = InetAddress.getLocalHost();
-        if (!localHost.isLoopbackAddress())
-            return localHost;
-        InetAddress[] addrs = getAllLocalUsingNetworkInterface();
-        for (int i = 0; i < addrs.length; i++) {
-            if (!addrs[i].isLoopbackAddress() && !addrs[i].getHostAddress().contains(":"))
-                return addrs[i];
-        }
-        return localHost;
-    }
-
-    /**
-     * This method attempts to find all InetAddresses for this machine in a conventional way (via InetAddress). If only
-     * one address is found and it is the loopback, an attempt is made to determine the addresses for this machine using
-     * NetworkInterface.
-     * 
-     * @return InetAddress[] - all addresses assigned to the local machine
-     * @throws UnknownHostException
-     *             - if there is a problem determining addresses
-     */
-    public static InetAddress[] getAllLocal() throws UnknownHostException {
-        InetAddress[] iAddresses = InetAddress.getAllByName("127.0.0.1");
-        if (iAddresses.length != 1)
-            return iAddresses;
-        if (!iAddresses[0].isLoopbackAddress())
-            return iAddresses;
-        return getAllLocalUsingNetworkInterface();
-
-    }
-
-    /**
-     * Utility method that delegates to the methods of NetworkInterface to determine addresses for this machine.
-     * 
-     * @return InetAddress[] - all addresses found from the NetworkInterfaces
-     * @throws UnknownHostException
-     *             - if there is a problem determining addresses
-     */
-    private static InetAddress[] getAllLocalUsingNetworkInterface() throws UnknownHostException {
-        ArrayList addresses = new ArrayList();
-        Enumeration e = null;
-        try {
-            e = NetworkInterface.getNetworkInterfaces();
-        } catch (SocketException ex) {
-            throw new UnknownHostException("127.0.0.1");
-        }
-        while (e.hasMoreElements()) {
-            NetworkInterface ni = (NetworkInterface) e.nextElement();
-            for (Enumeration e2 = ni.getInetAddresses(); e2.hasMoreElements();) {
-                addresses.add(e2.nextElement());
-            }
-        }
-        InetAddress[] iAddresses = new InetAddress[addresses.size()];
-        for (int i = 0; i < iAddresses.length; i++) {
-            iAddresses[i] = (InetAddress) addresses.get(i);
-        }
-        return iAddresses;
-    }
 }

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=1412157&r1=1412156&r2=1412157&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 21 15:51:35 2012
@@ -19,28 +19,18 @@
 package org.apache.cxf.dosgi.dsw.handlers;
 
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.binding.BindingConfiguration;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.qos.IntentMap;
-import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
+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.feature.Feature;
 import org.apache.cxf.frontend.ClientFactoryBean;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
@@ -55,14 +45,12 @@ import org.slf4j.LoggerFactory;
 
 public abstract class AbstractPojoConfigurationTypeHandler extends AbstractConfigurationHandler {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractPojoConfigurationTypeHandler.class);
-    private static final String PROVIDED_INTENT_VALUE = "PROVIDED";
     private static final String CONFIGURATION_TYPE = "org.apache.cxf.ws";
     
-    private IntentMap masterMap;
-    
-    public AbstractPojoConfigurationTypeHandler(BundleContext dswBC,                                                
+    public AbstractPojoConfigurationTypeHandler(BundleContext dswBC,
+                                                IntentManager intentManager,
                                                 Map<String, Object> handlerProps) {
-        super(dswBC,  handlerProps);
+        super(dswBC, intentManager, handlerProps);
     }
 
     // Isolated so that it can be substituted for testing
@@ -83,35 +71,6 @@ public abstract class AbstractPojoConfig
       }
     }
 
-    String [] applyIntents(BundleContext dswContext,
-                           BundleContext callingContext,
-                           List<Feature> features,
-                           AbstractEndpointFactory factory,
-                           Map sd) throws IntentUnsatifiedException {
-        String[] requestedIntents = getRequestedIntents(sd);
-        Set<String> appliedIntents = new HashSet<String>(Arrays.asList(requestedIntents));
-        
-        IntentMap intentMap = getIntentMap(callingContext);        
-        if (useMasterMap()) {
-            intentMap = mergeWithMaster(dswContext, intentMap);
-        }
-        appliedIntents.addAll(reverseLookup(intentMap, PROVIDED_INTENT_VALUE));
-        
-        boolean bindingConfigAdded = false;
-        for (String requestedName : requestedIntents) {
-            bindingConfigAdded 
-                |= processIntent(appliedIntents, features, factory, requestedName, intentMap);
-        }
-        
-        if (!bindingConfigAdded && getDefaultBindingIntent() != null) {
-            // If no binding config was specified, add SOAP
-            processIntent(appliedIntents, features, factory, getDefaultBindingIntent(), intentMap);
-        }
-
-        appliedIntents.addAll(addSynonymIntents(appliedIntents, intentMap));        
-        return appliedIntents.toArray(new String[0]);
-    }
-
     protected void setWsdlProperties(ServerFactoryBean factory,
                                      BundleContext callingContext,  
                                      Map sd, boolean wsdlType) {
@@ -241,118 +200,11 @@ public abstract class AbstractPojoConfig
         	factory.getProperties(true).putAll(props);
         }
     }
-    
-    private boolean processIntent(Set<String> appliedIntents,
-                                  List<Feature> features,
-                                  AbstractEndpointFactory factory, String intentName,
-                                  IntentMap intentMap) throws IntentUnsatifiedException {
-        boolean rc = processIntent(features, factory, intentName, intentMap);
-        appliedIntents.add(intentName);
-        return rc;
-    }
-    
-    private boolean processIntent(List<Feature> features,
-                                  AbstractEndpointFactory factory, String intentName,
-                                  IntentMap intentMap) throws IntentUnsatifiedException {
-        Object intent = intentMap.get(intentName);
-        if (intent instanceof String) {
-            if (PROVIDED_INTENT_VALUE.equalsIgnoreCase((String) intent)) {
-                return false;
-            }
-        } else if (intent instanceof Feature) {
-            Feature feature = (Feature)intent;
-            LOG.info("Applying intent: " + intentName
-                     + " via feature: " + feature);
-            features.add(feature);
-            return false;
-        } else if (intent instanceof BindingConfiguration) {
-            BindingConfiguration bindingCfg = (BindingConfiguration)intent;
-            LOG.info("Applying intent: " + intentName
-                     + " via binding config: " + bindingCfg);
-            factory.setBindingConfig(bindingCfg);
-            return true;
-        } else {
-            LOG.info("No mapping for intent: " + intentName);
-            throw new IntentUnsatifiedException(intentName);
-        }
-        return false;
-    }
-    
-
-    private Collection<String> addSynonymIntents(Collection<String> appliedIntents, IntentMap intentMap) {
-        // E.g. SOAP and SOAP.1_1 are synonyms
-        List<Object> values = new ArrayList<Object>();
-        for (String key : appliedIntents) {
-            values.add(intentMap.get(key));
-        }
-        return reverseLookup(intentMap, values);
-    }
-
-    private Collection<String> reverseLookup(IntentMap intentMap, Object obj) {
-        return reverseLookup(intentMap, Collections.singleton(obj));
-    }
-    
-    private Collection<String> reverseLookup(IntentMap intentMap, Collection<? extends Object> objs) {
-        Set<String> intentsFound = new HashSet<String>();
-        for (Map.Entry<String, Object> entry : intentMap.getIntents().entrySet()) {
-            if (objs.contains(entry.getValue())) {
-                intentsFound.add(entry.getKey());
-            }
-        }
-        return intentsFound;
-    }
-    
-    String getDefaultBindingIntent() {
-        return "SOAP";
-    }
-
-    IntentMap getIntentMap(BundleContext callingContext) {
-        return IntentUtils.getIntentMap(callingContext);
-    }
 
     public String getType() {
         return CONFIGURATION_TYPE;
     }
 
-    private static String[] getRequestedIntents(Map sd) {
-        Collection<String> intents = Arrays.asList(
-            IntentUtils.parseIntents(OsgiUtils.getProperty(sd, RemoteConstants.SERVICE_EXPORTED_INTENTS)));        
-        Collection<String> extraIntents = Arrays.asList(
-            IntentUtils.parseIntents(OsgiUtils.getProperty(sd, RemoteConstants.SERVICE_EXPORTED_INTENTS)));
-        Collection<String> oldIntents = Arrays.asList(
-            IntentUtils.parseIntents(OsgiUtils.getProperty(sd, Constants.EXPORTED_INTENTS_OLD))); 
-        
-        Set<String> allIntents = new HashSet<String>(intents.size() + extraIntents.size() + oldIntents.size());
-        allIntents.addAll(intents);
-        allIntents.addAll(extraIntents);
-        allIntents.addAll(oldIntents);
-        
-        LOG.debug("Intents asserted: " + allIntents);
-        return allIntents.toArray(new String[allIntents.size()]);
-    }
-    
-    private IntentMap mergeWithMaster(BundleContext dswContext, IntentMap intentMap) {
-        synchronized (this) {
-            if (masterMap == null) {
-                LOG.debug("Loading master intent map");
-                masterMap = getIntentMap(dswContext);
-            }
-        }
-        if (masterMap != null) {
-            Iterator<String> masterKeys = masterMap.getIntents().keySet().iterator();
-            while (masterKeys.hasNext()) {
-                String masterKey = masterKeys.next();
-                if (intentMap.get(masterKey) == null) {
-                    LOG.debug("Merging in master intent map entry: " + masterKey);
-                    intentMap.getIntents().put(masterKey, masterMap.get(masterKey));
-                } else {
-                    LOG.debug("Overridden master intent map entry: " + masterKey);
-                }
-            }
-        }
-        return intentMap;
-    }    
-
     protected String getPojoAddress(Map sd, Class<?> iClass) {
         String address = OsgiUtils.getProperty(sd, RemoteConstants.ENDPOINT_ID);
         if(address == null && sd.get(RemoteConstants.ENDPOINT_ID)!=null ){

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=1412157&r1=1412156&r2=1412157&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 21 15:51:35 2012
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;
 
 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.osgi.framework.BundleContext;
@@ -30,15 +31,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public final class ConfigTypeHandlerFactory {
-
     private static final Logger LOG = LoggerFactory.getLogger(ConfigTypeHandlerFactory.class);
-    private static final ConfigTypeHandlerFactory FACTORY = new ConfigTypeHandlerFactory();
-
-    private ConfigTypeHandlerFactory() {
-    }
+    private IntentManager intentManager;
 
-    public static ConfigTypeHandlerFactory getInstance() {
-        return FACTORY;
+    public ConfigTypeHandlerFactory(IntentManager intentManager) {
+        this.intentManager = intentManager;
+        
     }
 
     public ConfigurationTypeHandler getHandler(BundleContext dswBC, List<String> configurationTypes,
@@ -53,16 +51,16 @@ public final class ConfigTypeHandlerFact
                 || OsgiUtils.getProperty(serviceProperties, Constants.RS_HTTP_SERVICE_CONTEXT) != null
                 || OsgiUtils.getProperty(serviceProperties, Constants.WS_HTTP_SERVICE_CONTEXT_OLD) != null) {
                 return jaxrs
-                    ? new JaxRSHttpServiceConfigurationTypeHandler(dswBC, props)
-                    : new HttpServiceConfigurationTypeHandler(dswBC, props);
+                    ? new JaxRSHttpServiceConfigurationTypeHandler(dswBC, intentManager, props)
+                    : new HttpServiceConfigurationTypeHandler(dswBC, intentManager, props);
 
             } else {
                 return jaxrs
-                    ? new JaxRSPojoConfigurationTypeHandler(dswBC, props)
-                    : new PojoConfigurationTypeHandler(dswBC, props);
+                    ? new JaxRSPojoConfigurationTypeHandler(dswBC, intentManager, props)
+                    : new PojoConfigurationTypeHandler(dswBC, intentManager, props);
             }
         } else if (configurationTypes.contains(Constants.WSDL_CONFIG_TYPE)) {
-            return new WsdlConfigurationTypeHandler(dswBC, props);
+            return new WsdlConfigurationTypeHandler(dswBC, intentManager, props);
         }
 
         LOG.warn("None of the configuration types in " + configurationTypes + " is supported.");

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java?rev=1412157&r1=1412156&r2=1412157&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java Wed Nov 21 15:51:35 2012
@@ -31,6 +31,7 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 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.OsgiUtils;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
@@ -47,7 +48,6 @@ import org.osgi.framework.ServiceReferen
 import org.osgi.service.http.HttpContext;
 import org.osgi.service.http.HttpService;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
 import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -58,10 +58,8 @@ public class HttpServiceConfigurationTyp
     Set<ServiceReference> httpServiceReferences = new CopyOnWriteArraySet<ServiceReference>();
     Map<Long, String> exportedAliases = Collections.synchronizedMap(new HashMap<Long, String>());
     
-    protected HttpServiceConfigurationTypeHandler(BundleContext dswBC,
-
-    Map<String, Object> handlerProps) {
-        super(dswBC, handlerProps);
+    protected HttpServiceConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager, Map<String, Object> handlerProps) {
+        super(dswBC, intentManager, handlerProps);
 
         ServiceTracker st = new ServiceTracker(dswBC, HttpService.class.getName(), null) {
             @Override
@@ -108,8 +106,7 @@ public class HttpServiceConfigurationTyp
             factory.setAddress(address);
             factory.getServiceFactory().setDataBinding(databinding);
 
-            applyIntents(dswContext, callingContext, factory.getFeatures(), factory.getClientFactoryBean(),
-                         sd.getProperties());
+            intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd.getProperties());
 
             Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
             Object proxy = getProxy(factory.create(), iClass);
@@ -160,7 +157,7 @@ public class HttpServiceConfigurationTyp
         		constructAddress(dswContext, contextRoot, relativeEndpointAddress);
         
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
-        String[] intents = applyIntents(dswContext, callingContext, factory.getFeatures(), factory, sd);
+        String[] intents = intentManager.applyIntents(factory.getFeatures(),factory, sd);
 
         // The properties for the EndpointDescription
         Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[] {
@@ -210,7 +207,7 @@ public class HttpServiceConfigurationTyp
 
         String hostName = null;
         try {
-            hostName = AbstractConfigurationHandler.getLocalHost().getHostAddress();
+            hostName = LocalHostUtil.getLocalHost().getHostAddress();
         } catch (UnknownHostException e) {
             hostName = "localhost";
         }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java?rev=1412157&r1=1412156&r2=1412157&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java Wed Nov 21 15:51:35 2012
@@ -24,6 +24,7 @@ import java.util.Map;
 
 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.util.OsgiUtils;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
@@ -38,8 +39,9 @@ public class JaxRSHttpServiceConfigurati
     private static final Logger LOG = LoggerFactory.getLogger(JaxRSHttpServiceConfigurationTypeHandler.class);
 
     protected JaxRSHttpServiceConfigurationTypeHandler(BundleContext dswBC,
+                                                       IntentManager intentManager,
                                                        Map<String, Object> handlerProps) {
-        super(dswBC, handlerProps);
+        super(dswBC, intentManager, handlerProps);
     }
 
     @Override

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=1412157&r1=1412156&r2=1412157&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 21 15:51:35 2012
@@ -25,6 +25,7 @@ import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
 
 import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
@@ -44,10 +45,8 @@ public class JaxRSPojoConfigurationTypeH
 
     Set<ServiceReference> httpServiceReferences = new CopyOnWriteArraySet<ServiceReference>();
 
-    protected JaxRSPojoConfigurationTypeHandler(BundleContext dswBC,
-
-    Map<String, Object> handlerProps) {
-        super(dswBC, handlerProps);
+    protected JaxRSPojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager, Map<String, Object> handlerProps) {
+        super(dswBC, intentManager, handlerProps);
     }
 
     @Override

Added: 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=1412157&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java Wed Nov 21 15:51:35 2012
@@ -0,0 +1,85 @@
+package org.apache.cxf.dosgi.dsw.handlers;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+/**
+ * Utility methods to get the local address even on a linux host
+ */
+public class LocalHostUtil {
+    
+    private LocalHostUtil() {
+        // Util Class
+    }
+    
+    /**
+     * Returns an InetAddress representing the address of the localhost. Every attempt is made to find an address for
+     * this host that is not the loopback address. If no other address can be found, the loopback will be returned.
+     * 
+     * @return InetAddress - the address of localhost
+     * @throws UnknownHostException
+     *             - if there is a problem determing the address
+     */
+    public static InetAddress getLocalHost() throws UnknownHostException {
+        InetAddress localHost = InetAddress.getLocalHost();
+        if (!localHost.isLoopbackAddress())
+            return localHost;
+        InetAddress[] addrs = getAllLocalUsingNetworkInterface();
+        for (int i = 0; i < addrs.length; i++) {
+            if (!addrs[i].isLoopbackAddress() && !addrs[i].getHostAddress().contains(":"))
+                return addrs[i];
+        }
+        return localHost;
+    }
+
+    /**
+     * This method attempts to find all InetAddresses for this machine in a conventional way (via InetAddress). If only
+     * one address is found and it is the loopback, an attempt is made to determine the addresses for this machine using
+     * NetworkInterface.
+     * 
+     * @return InetAddress[] - all addresses assigned to the local machine
+     * @throws UnknownHostException
+     *             - if there is a problem determining addresses
+     */
+    public static InetAddress[] getAllLocal() throws UnknownHostException {
+        InetAddress[] iAddresses = InetAddress.getAllByName("127.0.0.1");
+        if (iAddresses.length != 1)
+            return iAddresses;
+        if (!iAddresses[0].isLoopbackAddress())
+            return iAddresses;
+        return getAllLocalUsingNetworkInterface();
+
+    }
+
+    /**
+     * Utility method that delegates to the methods of NetworkInterface to determine addresses for this machine.
+     * 
+     * @return InetAddress[] - all addresses found from the NetworkInterfaces
+     * @throws UnknownHostException
+     *             - if there is a problem determining addresses
+     */
+    private static InetAddress[] getAllLocalUsingNetworkInterface() throws UnknownHostException {
+        ArrayList addresses = new ArrayList();
+        Enumeration e = null;
+        try {
+            e = NetworkInterface.getNetworkInterfaces();
+        } catch (SocketException ex) {
+            throw new UnknownHostException("127.0.0.1");
+        }
+        while (e.hasMoreElements()) {
+            NetworkInterface ni = (NetworkInterface) e.nextElement();
+            for (Enumeration e2 = ni.getInetAddresses(); e2.hasMoreElements();) {
+                addresses.add(e2.nextElement());
+            }
+        }
+        InetAddress[] iAddresses = new InetAddress[addresses.size()];
+        for (int i = 0; i < iAddresses.length; i++) {
+            iAddresses[i] = (InetAddress) addresses.get(i);
+        }
+        return iAddresses;
+    }
+}

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

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=1412157&r1=1412156&r2=1412157&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 21 15:51:35 2012
@@ -21,8 +21,12 @@ package org.apache.cxf.dosgi.dsw.handler
 import java.util.Map;
 
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.binding.BindingConfiguration;
+import org.apache.cxf.binding.soap.SoapBindingConfiguration;
 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.ClientProxyFactoryBean;
@@ -38,8 +42,8 @@ import org.slf4j.LoggerFactory;
 public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
     private static final Logger LOG = LoggerFactory.getLogger(PojoConfigurationTypeHandler.class);
 
-    public PojoConfigurationTypeHandler(BundleContext dswBC, Map<String, Object> handlerProps) {
-        super(dswBC, handlerProps);
+    public PojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager, Map<String, Object> handlerProps) {
+        super(dswBC, intentManager, handlerProps);
     }
 
     public Object createProxy(ServiceReference serviceReference, BundleContext dswContext,
@@ -73,8 +77,7 @@ public class PojoConfigurationTypeHandle
             addWsInterceptorsFeaturesProps(factory.getClientFactoryBean(), callingContext, sd.getProperties());
             setClientWsdlProperties(factory.getClientFactoryBean(), dswContext, sd.getProperties(), false);
             
-            applyIntents(dswContext, callingContext, factory.getFeatures(), factory.getClientFactoryBean(),
-                         sd.getProperties());
+            intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd.getProperties());
 
             Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
             Object proxy = getProxy(factory.create(), iClass);
@@ -115,7 +118,8 @@ public class PojoConfigurationTypeHandle
         addWsInterceptorsFeaturesProps(factory, callingContext, sd);
         setWsdlProperties(factory, callingContext, sd, false);
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
-        String[] intents = applyIntents(dswContext, callingContext, factory.getFeatures(), factory, sd);
+        
+        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);

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=1412157&r1=1412156&r2=1412157&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 21 15:51:35 2012
@@ -26,9 +26,13 @@ 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;
@@ -45,9 +49,9 @@ public class WsdlConfigurationTypeHandle
     private static final Logger LOG = LoggerFactory.getLogger(WsdlConfigurationTypeHandler.class);
     
     public WsdlConfigurationTypeHandler(BundleContext dswBC,
-                               
+                                        IntentManager intentManager,
                                         Map<String, Object> handlerProps) {
-        super(dswBC, handlerProps);
+        super(dswBC, intentManager, handlerProps);
     }
     
     public String getType() {
@@ -151,7 +155,7 @@ public class WsdlConfigurationTypeHandle
         	factory.setBus(bus);
         }
         
-        String[] intents = applyIntents(dswContext, callingContext, factory.getFeatures(), factory, sd);
+        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);

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/DefaultIntentMapFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/DefaultIntentMapFactory.java?rev=1412157&r1=1412156&r2=1412157&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/DefaultIntentMapFactory.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/DefaultIntentMapFactory.java Wed Nov 21 15:51:35 2012
@@ -1,3 +1,21 @@
+/** 
+  * 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.qos;
 
 import java.util.HashMap;
@@ -12,8 +30,8 @@ import org.apache.cxf.ws.policy.WSPolicy
 import org.apache.neethi.Policy;
 
 public class DefaultIntentMapFactory {
-    public IntentMap create() {
-        Map<String, Object> intentMap = new HashMap<String, Object>();
+    public Map<String, Object> create() {
+        Map<String,Object> intentMap = new HashMap<String, Object>();
         intentMap.put("addressing", getNonDecoupledAddressing());
         intentMap.put("logging", getLoggingFeature());
         Object soap11 = getSoapBinding(Soap11.getInstance());
@@ -21,10 +39,7 @@ public class DefaultIntentMapFactory {
         intentMap.put("SOAP.1_1", soap11);
         intentMap.put("SOAP.1_2", getSoapBinding(Soap12.getInstance()));
         intentMap.put("HTTP", "PROVIDED");
-
-        IntentMap intentMap2 = new IntentMap();
-        intentMap2.setIntents(intentMap );
-        return intentMap2;
+        return intentMap;
     }
 
     private Object getNonDecoupledAddressing() {

Added: 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=1412157&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManager.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManager.java Wed Nov 21 15:51:35 2012
@@ -0,0 +1,31 @@
+/** 
+  * 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.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 {
+    List<String> getUnsupportedIntents(Properties serviceProperties);
+    String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory, Map<String, Object> props);
+}

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

Added: 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=1412157&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImpl.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImpl.java Wed Nov 21 15:51:35 2012
@@ -0,0 +1,147 @@
+/** 
+  * 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.qos;
+
+import java.util.ArrayList;
+import java.util.Collection;
+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;
+import org.apache.cxf.dosgi.dsw.handlers.IntentUnsatifiedException;
+import org.apache.cxf.endpoint.AbstractEndpointFactory;
+import org.apache.cxf.feature.Feature;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IntentManagerImpl implements IntentManager {
+    private static final String PROVIDED_INTENT_VALUE = "PROVIDED";
+    private static final Logger LOG = LoggerFactory.getLogger(IntentManagerImpl.class);
+
+    private IntentMap intentMap;
+    private ServiceTracker intentTracker;
+    
+    public IntentManagerImpl(IntentMap intentMap) {
+        this.intentMap = intentMap;
+        this.intentTracker = null;
+    }
+    
+    public IntentManagerImpl(BundleContext bc, IntentMap intentMap) {
+        this.intentMap = intentMap;
+        this.intentTracker = new ServiceTracker(bc, "", null);
+        this.intentTracker.open();
+    }
+    
+    public BindingConfiguration getBindingConfiguration(String[] requestedIntents, BindingConfiguration defaultConfig) {
+        for (String intentName : requestedIntents) {
+            Object intent = intentMap.get(intentName);
+            if (intent instanceof BindingConfiguration) {
+                return (BindingConfiguration) intent;
+            }
+        }
+        return defaultConfig;
+    }
+
+    public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory, Map<String, Object> props) throws IntentUnsatifiedException {
+        Set<String> requestedIntents = IntentUtils.getRequestedIntents(props);
+        Set<String> appliedIntents = new HashSet<String>();
+        appliedIntents.addAll(reverseLookup(intentMap, PROVIDED_INTENT_VALUE));
+        boolean bindingApplied = false;
+        for (String intentName : requestedIntents) {
+            bindingApplied |= processIntent(features, factory, intentName, intentMap.get(intentName));
+            appliedIntents.add(intentName);
+        }
+        if (!bindingApplied) {
+            String defaultBindingName = "SOAP";
+            processIntent(features, factory, defaultBindingName, intentMap.get(defaultBindingName));
+            appliedIntents.add(defaultBindingName);
+        }
+        appliedIntents.addAll(addSynonymIntents(appliedIntents, intentMap));
+        return appliedIntents.toArray(new String[0]);
+    }
+    
+    private boolean processIntent(List<Feature> features, AbstractEndpointFactory factory, String intentName, Object intent) throws IntentUnsatifiedException {
+        if (intent instanceof String) {
+            if (PROVIDED_INTENT_VALUE.equalsIgnoreCase((String) intent)) {
+                return false;
+            }
+        } else if (intent instanceof BindingConfiguration) {
+            BindingConfiguration bindingCfg = (BindingConfiguration)intent;
+            LOG.info("Applying intent: " + intentName + " via binding config: " + bindingCfg);
+            factory.setBindingConfig(bindingCfg);
+            return true;
+        } else if (intent instanceof Feature) {
+            Feature feature = (Feature) intent;
+            LOG.info("Applying intent: " + intentName + " via feature: " + feature);
+            features.add(feature);
+            return false;
+        } else {
+            LOG.info("No mapping for intent: " + intentName);
+            throw new IntentUnsatifiedException(intentName);
+        }
+        return false;
+    }
+
+    private Collection<String> addSynonymIntents(Collection<String> appliedIntents, IntentMap intentMap) {
+        // E.g. SOAP and SOAP.1_1 are synonyms
+        List<Object> values = new ArrayList<Object>();
+        for (String key : appliedIntents) {
+            values.add(intentMap.get(key));
+        }
+        return reverseLookup(intentMap, values);
+    }
+
+    private Collection<String> reverseLookup(IntentMap intentMap, Object obj) {
+        return reverseLookup(intentMap, Collections.singleton(obj));
+    }
+
+    /**
+     * Retrieves all keys that have a value that can be found in objs
+     * @param intentMap
+     * @param objs
+     * @return
+     */
+    private Collection<String> reverseLookup(IntentMap intentMap, Collection<? extends Object> objs) {
+        Set<String> intentsFound = new HashSet<String>();
+        for (Map.Entry<String, Object> entry : intentMap.entrySet()) {
+            if (objs.contains(entry.getValue())) {
+                intentsFound.add(entry.getKey());
+            }
+        }
+        return intentsFound;
+    }
+    
+    public List<String> getUnsupportedIntents(Properties serviceProperties) {
+        Set<String> requiredIntents = IntentUtils.getRequestedIntents(serviceProperties);
+        List<String> unsupportedIntents = new ArrayList<String>();
+        for (String ri : requiredIntents) {
+            if (!intentMap.containsKey(ri)) {
+                unsupportedIntents.add(ri);
+            }
+        }
+        return unsupportedIntents;
+    }
+
+}

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

Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentMap.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentMap.java?rev=1412157&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentMap.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentMap.java Wed Nov 21 15:51:35 2012
@@ -0,0 +1,53 @@
+/** 
+  * 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.qos;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Maps intent names to intent objects
+ * An intent object can be a Feature, a BindingConfiguration or a String
+ * 
+ * Also supports a default intent map. Custom intents can override the defaults 
+ */
+public class IntentMap extends HashMap<String, Object> {
+    private static final long serialVersionUID = 2606460607920520767L;
+    private Map<String, Object> defaultMap;
+    
+    public IntentMap() {
+        super(new HashMap<String, Object>());
+    }
+    
+    public IntentMap(Map<String, Object> defaultMap) {
+        super();
+        this.defaultMap = defaultMap;
+        putAll(defaultMap);
+    }
+    
+    @Override
+    public Object remove(Object key) {
+        Object old = super.remove(key);
+        if (defaultMap.containsKey(key)) {
+            put((String)key, defaultMap.get(key));
+        }
+        return old;
+    }
+    
+}

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

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java?rev=1412157&r1=1412156&r2=1412157&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java Wed Nov 21 15:51:35 2012
@@ -1,12 +1,34 @@
+/** 
+  * 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.qos;
 
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
+import org.apache.cxf.dosgi.dsw.Constants;
+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.RemoteConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,47 +54,6 @@ public class IntentUtils {
         return intentsSequence == null ? new String[] {} : intentsSequence.split(" ");
     }
 
-    public static IntentMap getIntentMap(BundleContext bundleContext) {
-        IntentMap im = null;
-        try {
-            im = IntentUtils.readIntentMap(bundleContext);
-        } catch (Throwable t) {
-            LOG.warn("Intent map load failed: ", t);
-        }
-        if (im == null) {
-            // Couldn't read an intent map
-            LOG.debug("Using default intent map");
-            im = new IntentMap();
-            im.setIntents(new HashMap<String, Object>());
-        }
-        return im;
-    }
-
-    
-    
-    public static IntentMap readIntentMap(BundleContext bundleContext) {
-        return new DefaultIntentMapFactory().create();
-    }
-
-    @SuppressWarnings("rawtypes")
-    public static String[] getAllRequiredIntents(Map serviceProperties) {
-        // Get the intents that need to be supported by the RSA
-        String[] requiredIntents = Utils.normalizeStringPlus(serviceProperties.get(RemoteConstants.SERVICE_EXPORTED_INTENTS));
-        if (requiredIntents == null) {
-            requiredIntents = new String[0];
-        }
-
-        { // merge with extra intents;
-            String[] requiredExtraIntents = Utils.normalizeStringPlus(serviceProperties.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA));
-            if (requiredExtraIntents != null && requiredExtraIntents.length > 0) {
-
-                requiredIntents = IntentUtils.mergeArrays(requiredIntents, requiredExtraIntents);
-            }
-        }
-
-        return requiredIntents;
-    }
-
     @SuppressWarnings("rawtypes")
     public static String[] getInetntsImplementedByTheService(Map serviceProperties) {
         // Get the Intents that are implemented by the service
@@ -98,5 +79,18 @@ public class IntentUtils {
 
         return list.toArray(new String[list.size()]);
     }
+    
+    public static Set<String> getRequestedIntents(Map<?, ?> sd) {
+        Collection<String> intents = Arrays.asList(
+            IntentUtils.parseIntents(OsgiUtils.getProperty(sd, RemoteConstants.SERVICE_EXPORTED_INTENTS)));        
+        Collection<String> oldIntents = Arrays.asList(
+            IntentUtils.parseIntents(OsgiUtils.getProperty(sd, Constants.EXPORTED_INTENTS_OLD))); 
+        
+        Set<String> allIntents = new HashSet<String>(intents.size() + oldIntents.size());
+        allIntents.addAll(intents);
+        allIntents.addAll(oldIntents);
+        LOG.debug("Intents asserted: " + allIntents);
+        return allIntents;
+    }
 
 }

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=1412157&r1=1412156&r2=1412157&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 21 15:51:35 2012
@@ -35,8 +35,7 @@ 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.IntentMap;
-import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
+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;
@@ -63,12 +62,14 @@ public class RemoteServiceAdminCore impl
 
     private BundleContext bctx;
     private EventProducer eventProducer;
-    private IntentMap intentMap;
 
     private volatile boolean useMasterMap = true;
     private volatile String defaultPort;
     private volatile String defaultHost;
 
+    private ConfigTypeHandlerFactory configTypeHandlerFactory;
+    private IntentManager intentManager;
+
     // protected because of tests
     protected static final List<String> supportedConfigurationTypes = new ArrayList<String>();
 
@@ -81,10 +82,11 @@ public class RemoteServiceAdminCore impl
 
     protected final static String DEFAULT_CONFIGURATION = Constants.WS_CONFIG_TYPE;
 
-    public RemoteServiceAdminCore(BundleContext bc, IntentMap intentMap) {
+    public RemoteServiceAdminCore(BundleContext bc, IntentManager intentManager) {
         bctx = bc;
+        this.intentManager = intentManager;
         eventProducer = new EventProducer(bctx);
-        this.intentMap = intentMap;
+        this.configTypeHandlerFactory = new ConfigTypeHandlerFactory(intentManager);
     }
 
     @SuppressWarnings("rawtypes")
@@ -144,25 +146,13 @@ public class RemoteServiceAdminCore impl
                 OsgiUtils.overlayProperties(serviceProperties,additionalProperties);
             }
 
-            // Get the intents that need to be supported by the RSA
-            String[] requiredIntents = IntentUtils.getAllRequiredIntents(serviceProperties);
-
-            {
-                List<String> unsupportedIntents = new ArrayList<String>();
-
-                for (String ri : requiredIntents) {
-                    if (!intentMap.getIntents().containsKey(ri)) {
-                        unsupportedIntents.add(ri);
-                    }
-                }
-
-                if (unsupportedIntents.size() > 0) {
-                    LOG.error("service cannot be exported because the following intents are not supported by this RSA: "
-                                + unsupportedIntents);
-                    // TODO: publish error event
-                    return Collections.emptyList();
-                }
-
+            List<String> unsupportedIntents = intentManager.getUnsupportedIntents(serviceProperties);
+            
+            if (unsupportedIntents.size() > 0) {
+                LOG.error("service cannot be exported because the following intents are not supported by this RSA: "
+                            + unsupportedIntents);
+                // TODO: publish error event
+                return Collections.emptyList();
             }
 
             List<String> interfaces = new ArrayList<String>(1);
@@ -322,7 +312,7 @@ public class RemoteServiceAdminCore impl
 
     private ConfigurationTypeHandler getHandler(List<String> configurationTypes, Map<?, ?> serviceProperties,
                                                 Map<String, Object> props) {
-        return ConfigTypeHandlerFactory.getInstance().getHandler(bctx, configurationTypes, serviceProperties,
+        return configTypeHandlerFactory.getHandler(bctx, configurationTypes, serviceProperties,
                                                                  props);
     }
 

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=1412157&r1=1412156&r2=1412157&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 21 15:51:35 2012
@@ -21,7 +21,7 @@ package org.apache.cxf.dosgi.dsw.service
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.cxf.dosgi.dsw.qos.IntentMap;
+import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceFactory;
@@ -36,8 +36,8 @@ public class RemoteServiceadminFactory i
 
     private RemoteServiceAdminCore rsaCore;
 
-    public RemoteServiceadminFactory(BundleContext bc, IntentMap intentMap) {
-    	this.rsaCore = new RemoteServiceAdminCore(bc, intentMap);
+    public RemoteServiceadminFactory(BundleContext bc, IntentManager intentManager) {
+    	this.rsaCore = new RemoteServiceAdminCore(bc, intentManager);
     }
 
     public Object getService(Bundle b, ServiceRegistration sr) {

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java?rev=1412157&r1=1412156&r2=1412157&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java Wed Nov 21 15:51:35 2012
@@ -26,6 +26,9 @@ import java.util.Map;
 import junit.framework.TestCase;
 
 import org.apache.cxf.dosgi.dsw.Constants;
+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.easymock.EasyMock;
 import org.osgi.framework.BundleContext;
 
@@ -38,7 +41,9 @@ public class ConfigTypeHandlerFactoryTes
         List<String> configs = new ArrayList<String>();
         Map<String, Object> serviceProps = new HashMap<String, Object>();
 
-        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        IntentMap intentMap = new IntentMap();
+        IntentManager intentManager = new IntentManagerImpl(intentMap );
+        ConfigTypeHandlerFactory f = new ConfigTypeHandlerFactory(intentManager );
 
         configs.add(Constants.RS_CONFIG_TYPE);
 
@@ -53,7 +58,9 @@ public class ConfigTypeHandlerFactoryTes
         List<String> configs = new ArrayList<String>();
         Map<String, Object> serviceProps = new HashMap<String, Object>();
 
-        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        IntentMap intentMap = new IntentMap();
+        IntentManager intentManager = new IntentManagerImpl(intentMap);
+        ConfigTypeHandlerFactory f = new ConfigTypeHandlerFactory(intentManager);
         configs.add(Constants.RS_CONFIG_TYPE);
         serviceProps.put(Constants.EXPORTED_INTENTS, "HTTP");
 
@@ -68,7 +75,9 @@ public class ConfigTypeHandlerFactoryTes
         List<String> configs = new ArrayList<String>();
         Map<String, Object> serviceProps = new HashMap<String, Object>();
 
-        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        IntentMap intentMap = new IntentMap();
+        IntentManager intentManager = new IntentManagerImpl(intentMap);
+        ConfigTypeHandlerFactory f = new ConfigTypeHandlerFactory(intentManager);
         configs.add(Constants.RS_CONFIG_TYPE);
         serviceProps.put(Constants.EXPORTED_INTENTS, "SOAP HTTP");
 
@@ -84,7 +93,9 @@ public class ConfigTypeHandlerFactoryTes
         List<String> configs = new ArrayList<String>();
         Map<String, Object> serviceProps = new HashMap<String, Object>();
 
-        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        IntentMap intentMap = new IntentMap();
+        IntentManager intentManager = new IntentManagerImpl(intentMap);
+        ConfigTypeHandlerFactory f = new ConfigTypeHandlerFactory(intentManager);
         configs.add(Constants.WS_CONFIG_TYPE);
 
         ConfigurationTypeHandler handler = f.getHandler(bc, configs, serviceProps, null);
@@ -95,7 +106,9 @@ public class ConfigTypeHandlerFactoryTes
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.replay(bc);
 
-        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        IntentMap intentMap = new IntentMap();
+        IntentManager intentManager = new IntentManagerImpl(intentMap);
+        ConfigTypeHandlerFactory f = new ConfigTypeHandlerFactory(intentManager);
 
         List<String> configs = new ArrayList<String>();
         Map<String, Object> serviceProps = new HashMap<String, Object>();
@@ -111,7 +124,9 @@ public class ConfigTypeHandlerFactoryTes
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.replay(bc);
 
-        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        IntentMap intentMap = new IntentMap();
+        IntentManager intentManager = new IntentManagerImpl(intentMap);
+        ConfigTypeHandlerFactory f = new ConfigTypeHandlerFactory(intentManager);
 
         List<String> configs = new ArrayList<String>();
         Map<String, Object> serviceProps = new HashMap<String, Object>();
@@ -126,7 +141,9 @@ public class ConfigTypeHandlerFactoryTes
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.replay(bc);
 
-        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        IntentMap intentMap = new IntentMap();
+        IntentManager intentManager = new IntentManagerImpl(intentMap);
+        ConfigTypeHandlerFactory f = new ConfigTypeHandlerFactory(intentManager);
 
         List<String> configs = new ArrayList<String>();
         Map<String, Object> serviceProps = new HashMap<String, Object>();

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java?rev=1412157&r1=1412156&r2=1412157&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java Wed Nov 21 15:51:35 2012
@@ -18,13 +18,18 @@
   */
 package org.apache.cxf.dosgi.dsw.handlers;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import junit.framework.TestCase;
 
+import org.apache.cxf.binding.BindingConfiguration;
 import org.apache.cxf.dosgi.dsw.Constants;
+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.service.RemoteServiceAdminCore;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
@@ -49,35 +54,29 @@ import org.osgi.service.remoteserviceadm
 public class HttpServiceConfigurationTypeHandlerTest extends TestCase {
     
     public void testServer() throws Exception {
-        BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
+        IMocksControl c = EasyMock.createNiceControl();
+        BundleContext dswContext = c.createMock(BundleContext.class);
         EasyMock.expect(dswContext.getProperty("org.osgi.service.http.port")).
             andReturn("1327").anyTimes();
-        HttpService httpService = EasyMock.createNiceMock(HttpService.class);
+        HttpService httpService = c.createMock(HttpService.class);
         // expect that the cxf servlet is registered
-        EasyMock.replay(httpService);
         
-        ServiceReference httpSvcSR = EasyMock.createNiceMock(ServiceReference.class);
-        EasyMock.replay(httpSvcSR);
+        ServiceReference httpSvcSR = c.createMock(ServiceReference.class);
         EasyMock.expect(dswContext.getService(httpSvcSR)).andReturn(httpService).anyTimes();
-        EasyMock.replay(dswContext);
         
         final ServerFactoryBean sfb = createMockServerFactoryBean();
         
         //        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);
         Map<String, Object> handlerProps = new HashMap<String, Object>();
+        IntentManager intentManager = new DummyIntentManager(new String [] {"a.b.c"});
+        c.replay();
+        
         HttpServiceConfigurationTypeHandler h = 
-            new HttpServiceConfigurationTypeHandler(dswContext,  handlerProps) {
+            new HttpServiceConfigurationTypeHandler(dswContext, intentManager , handlerProps) {
                 @Override
                 ServerFactoryBean createServerFactoryBean(String frontend) {
                     return sfb;
                 }
-
-                @Override
-                String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
-                        List<Feature> features, AbstractEndpointFactory factory, 
-                        Map sd) {
-                    return new String [] {"a.b.c"};
-                }            
         };
         h.httpServiceReferences.add(httpSvcSR);
         
@@ -105,7 +104,7 @@ public class HttpServiceConfigurationTyp
         
         String hostName;
         try {
-            hostName = AbstractConfigurationHandler.getLocalHost().getHostAddress();
+            hostName = LocalHostUtil.getLocalHost().getHostAddress();
         } catch (Exception e) {
             hostName = "localhost";
         }
@@ -141,22 +140,18 @@ public class HttpServiceConfigurationTyp
         
         final ServerFactoryBean sfb = createMockServerFactoryBean();
         
-        IntentMap intentMap = new IntentMap();
-		RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext, intentMap );
+        IntentManager intentManager = new DummyIntentManager(new String[]{});
+        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext, intentManager);
         Map<String, Object> handlerProps = new HashMap<String, Object>();
+        
         HttpServiceConfigurationTypeHandler h = 
-            new HttpServiceConfigurationTypeHandler(dswContext,  handlerProps) {
+            new HttpServiceConfigurationTypeHandler(dswContext, intentManager, handlerProps) {
                 @Override
                 ServerFactoryBean createServerFactoryBean(String frontend) {
                     return sfb;
                 }
 
-                @Override
-                String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
-                        List<Feature> features, AbstractEndpointFactory factory, 
-                        Map sd) {
-                    return new String [] {};
-                }            
+                            
         };
         h.httpServiceReferences.add(httpSvcSR);
         
@@ -181,7 +176,7 @@ public class HttpServiceConfigurationTyp
         
         String hostname;
         try {
-            hostname = AbstractConfigurationHandler.getLocalHost().getHostAddress();
+            hostname = LocalHostUtil.getLocalHost().getHostAddress();
         } catch (Exception e) {
             hostname = "localhost";
         }
@@ -213,22 +208,15 @@ public class HttpServiceConfigurationTyp
         
         final ServerFactoryBean sfb = createMockServerFactoryBean();
         
-        IntentMap intentMap = new IntentMap();
-		RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext, intentMap);
+		IntentManager intentManager = new DummyIntentManager(new String [] {});
+        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext, intentManager);
         Map<String, Object> handlerProps = new HashMap<String, Object>();
         HttpServiceConfigurationTypeHandler h = 
-            new HttpServiceConfigurationTypeHandler(dswContext,  handlerProps) {
+            new HttpServiceConfigurationTypeHandler(dswContext, intentManager, handlerProps) {
                 @Override
                 ServerFactoryBean createServerFactoryBean(String frontend) {
                     return sfb;
                 }
-
-                @Override
-                String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
-                        List<Feature> features, AbstractEndpointFactory factory, 
-                        Map sd) {
-                    return new String [] {};
-                }            
         };
         h.httpServiceReferences.add(httpSvcSR);
         
@@ -255,7 +243,7 @@ public class HttpServiceConfigurationTyp
         
         String hostName;
         try {
-            hostName = AbstractConfigurationHandler.getLocalHost().getHostAddress();
+            hostName = LocalHostUtil.getLocalHost().getHostAddress();
         } catch (Exception e) {
             hostName = "localhost";
         }
@@ -350,17 +338,13 @@ public class HttpServiceConfigurationTyp
         c.replay();
 
         Map<String, Object> handlerProps = new HashMap<String, Object>();
-        HttpServiceConfigurationTypeHandler h = new HttpServiceConfigurationTypeHandler(bc1, handlerProps) {
+        IntentManager intentManager = new DummyIntentManager(new String[] { "a.b.c" });
+        HttpServiceConfigurationTypeHandler h = new HttpServiceConfigurationTypeHandler(bc1, intentManager , handlerProps) {
             @Override
             ClientProxyFactoryBean createClientProxyFactoryBean(String frontend) {
                 return cpfb;
             }
 
-            @Override
-            String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
-                    List<Feature> features, AbstractEndpointFactory factory, Map sd) {
-                return new String[] { "a.b.c" };
-            }
         };
 
         h.httpServiceReferences.add(httpSvcSR);
@@ -390,4 +374,30 @@ public class HttpServiceConfigurationTyp
     public void testServletUnregistration() {        
     }
     */
+    
+    class DummyIntentManager implements IntentManager {
+        private String[] applyResult;
+
+        public DummyIntentManager(String[] applyResult) {
+            this.applyResult = applyResult;
+        }
+        
+        public List<String> getUnsupportedIntents(Properties serviceProperties) {
+            return new ArrayList<String>();
+        }
+
+        public BindingConfiguration getBindingConfiguration(String[] requestedIntents,
+                BindingConfiguration defaultConfig) {
+            return defaultConfig;
+        }
+
+        public String[] applyIntents(List<Feature> features, String[] requestedIntents)
+                throws IntentUnsatifiedException {
+            return applyResult;
+        }
+
+        public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory, Map<String, Object> props) {
+            return applyResult;
+        }
+    };
 }