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/23 09:10:28 UTC

svn commit: r1412771 - in /cxf/dosgi/trunk: dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ dsw/cxf-dsw/src/test/java/org/apache/cxf...

Author: cschneider
Date: Fri Nov 23 08:10:22 2012
New Revision: 1412771

URL: http://svn.apache.org/viewvc?rev=1412771&view=rev
Log:
DOSGI-146 Improve integration test for custom intents, add intent assertion for imported services

Added:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java   (with props)
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java   (with props)
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/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/qos/IntentMap.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/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/qos/IntentManagerImplTest.java
    cxf/dosgi/trunk/systests2/multi-bundle/pom.xml
    cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java
    cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/customintent/TestCustomIntent.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=1412771&r1=1412770&r2=1412771&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 Fri Nov 23 08:10:22 2012
@@ -29,6 +29,7 @@ import org.apache.cxf.dosgi.dsw.qos.Defa
 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.RemoteServiceadminFactory;
 import org.osgi.framework.BundleActivator;
@@ -44,6 +45,8 @@ import org.slf4j.LoggerFactory;
 // registered as spring bean -> start / stop called accordingly 
 public class Activator implements ManagedService, BundleActivator {
 
+    private static final int DEFAULT_INTENT_TIMEOUT = 30000;
+
     private final static Logger LOG = LoggerFactory.getLogger(Activator.class);
 
     private static final String CONFIG_SERVICE_PID = "cxf-dsw";
@@ -52,23 +55,19 @@ public class Activator implements Manage
 
     private ServiceRegistration decoratorReg;
 
+    private IntentTracker intentTracker;
+
     public void start(BundleContext bc) throws Exception {
         // Disable the fast infoset as it's not compatible (yet) with OSGi
         System.setProperty("org.apache.cxf.nofastinfoset", "true");
 
         // should we have a seperate PID for a find and publish hook ?
         // context.registerService(ManagedService.class.getName(), this, getDefaults());
-
-        registerRemoteServiceAdminService(bc);
-
-        decoratorReg = bc.registerService(ServiceDecorator.class.getName(), new ServiceDecoratorImpl(bc),
-                                          null);
-
-    }
-
-    private RemoteServiceadminFactory registerRemoteServiceAdminService(BundleContext bc) {
+        
         IntentMap intentMap = new IntentMap(new DefaultIntentMapFactory().create());
-        IntentManager intentManager = new IntentManagerImpl(bc, intentMap);
+        intentTracker = new IntentTracker(bc, intentMap);
+        intentTracker.open();
+        IntentManager intentManager = new IntentManagerImpl(intentMap, DEFAULT_INTENT_TIMEOUT);
         RemoteServiceadminFactory rsaf = new RemoteServiceadminFactory(bc, intentManager);
         Hashtable<String, Object> props = new Hashtable<String, Object>();
 
@@ -88,16 +87,14 @@ public class Activator implements Manage
                                      org.apache.cxf.dosgi.dsw.Constants.RS_CONFIG_TYPE
         };
         props.put("remote.configs.supported", supportedConfigs);
-        
         LOG.info("Registering RemoteServiceAdminFactory...");
-
         rsaFactoryReg = bc.registerService(RemoteServiceAdmin.class.getName(), rsaf, props);
-        return rsaf;
+        decoratorReg = bc.registerService(ServiceDecorator.class.getName(), new ServiceDecoratorImpl(bc), null);
     }
 
     public void stop(BundleContext context) throws Exception {
         LOG.debug("RemoteServiceAdmin Implementation is shutting down now");
-        
+        intentTracker.close();
         // This also triggers the unimport and unexport of the remote services
         rsaFactoryReg.unregister();
         decoratorReg.unregister();

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=1412771&r1=1412770&r2=1412771&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 Fri Nov 23 08:10:22 2012
@@ -26,6 +26,6 @@ import org.apache.cxf.endpoint.AbstractE
 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);
+    void assertAllIntentsSupported(Properties 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=1412771&r1=1412770&r2=1412771&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 Fri Nov 23 08:10:22 2012
@@ -28,69 +28,27 @@ import java.util.Properties;
 import java.util.Set;
 
 import org.apache.cxf.binding.BindingConfiguration;
-import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.feature.Feature;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-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);
+    static final Logger LOG = LoggerFactory.getLogger(IntentManagerImpl.class);
 
     private final IntentMap intentMap;
-    private final ServiceTracker intentTracker;
+    private long maxIntentWaitTime;
     
     public IntentManagerImpl(IntentMap intentMap) {
-        this.intentMap = intentMap;
-        this.intentTracker = null;
+        this(intentMap, 0);
     }
     
-    public IntentManagerImpl(final BundleContext bc, final IntentMap intentMap) {
+    public IntentManagerImpl(IntentMap intentMap, int maxIntentWaitTime) {
         this.intentMap = intentMap;
-        Filter filter;
-        try {
-            filter = bc.createFilter("(" + Constants.INTENT_NAME_PROP + "=*)");
-        } catch (InvalidSyntaxException e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
-        this.intentTracker = new ServiceTracker(bc, filter, null) {
-
-            @Override
-            public Object addingService(ServiceReference reference) {
-                String intentName = (String) reference.getProperty(Constants.INTENT_NAME_PROP);
-                Object intent = bc.getService(reference);
-                LOG.info("Adding custom intent " + intentName);
-                intentMap.put(intentName, intent);
-                return super.addingService(reference);
-            }
-
-            @Override
-            public void removedService(ServiceReference reference, Object service) {
-                String intentName = (String) reference.getProperty(Constants.INTENT_NAME_PROP);
-                intentMap.remove(intentName);
-                super.removedService(reference, service);
-            }
-            
-        };
-        this.intentTracker.open();
+        this.maxIntentWaitTime = maxIntentWaitTime;
     }
     
-    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>();
@@ -160,15 +118,34 @@ public class IntentManagerImpl implement
         return intentsFound;
     }
     
-    public List<String> getUnsupportedIntents(Properties serviceProperties) {
+    public void assertAllIntentsSupported(Properties serviceProperties) {
+        long endTime = System.currentTimeMillis() + maxIntentWaitTime;
         Set<String> requiredIntents = IntentUtils.getRequestedIntents(serviceProperties);
         List<String> unsupportedIntents = new ArrayList<String>();
-        for (String ri : requiredIntents) {
-            if (!intentMap.containsKey(ri)) {
-                unsupportedIntents.add(ri);
-            }
+        do {
+            unsupportedIntents.clear();
+            for (String ri : requiredIntents) {
+                if (!intentMap.containsKey(ri)) {
+                    unsupportedIntents.add(ri);
+                }
+            }
+            long remainingSeconds = (endTime - System.currentTimeMillis()) / 1000;
+            if (unsupportedIntents.size() > 0 && remainingSeconds > 0) {
+                LOG.debug("Waiting for custom intents " + unsupportedIntents + " timeout in " + remainingSeconds);
+                try {
+                    synchronized (intentMap) {
+                        intentMap.wait(1000);
+                    }
+                } catch (InterruptedException e) {
+                    LOG.warn(e.getMessage(), e);
+                }
+            }
+        } while (unsupportedIntents.size() > 0 && System.currentTimeMillis() < endTime);
+        
+        if (unsupportedIntents.size() > 0) {
+            throw new RuntimeException("service cannot be exported because the following intents are not supported by this RSA: "
+                    + unsupportedIntents);
         }
-        return unsupportedIntents;
     }
 
 }

Modified: 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=1412771&r1=1412770&r2=1412771&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentMap.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentMap.java Fri Nov 23 08:10:22 2012
@@ -43,6 +43,15 @@ public class IntentMap extends Concurren
     }
     
     @Override
+    public Object put(String key, Object value) {
+        Object result = super.put(key, value);
+        synchronized (this) {
+            notifyAll();
+            return result;
+        }
+    }
+
+    @Override
     public Object remove(Object key) {
         Object old = super.remove(key);
         if (defaultMap.containsKey(key)) {

Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java?rev=1412771&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java Fri Nov 23 08:10:22 2012
@@ -0,0 +1,59 @@
+/** 
+  * 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 org.apache.cxf.dosgi.dsw.Constants;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class IntentTracker extends ServiceTracker {
+    private final IntentMap intentMap;
+
+    public IntentTracker(BundleContext context, IntentMap intentMap) {
+        super(context, getFilter(context), null);
+        this.intentMap = intentMap;
+    }
+    
+    static Filter getFilter(BundleContext context) {
+        try {
+            return context.createFilter("(" + Constants.INTENT_NAME_PROP + "=*)");
+        } catch (InvalidSyntaxException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public Object addingService(ServiceReference reference) {
+        String intentName = (String) reference.getProperty(Constants.INTENT_NAME_PROP);
+        Object intent = context.getService(reference);
+        IntentManagerImpl.LOG.info("Adding custom intent " + intentName);
+        intentMap.put(intentName, intent);
+        return super.addingService(reference);
+    }
+
+    @Override
+    public void removedService(ServiceReference reference, Object service) {
+        String intentName = (String) reference.getProperty(Constants.INTENT_NAME_PROP);
+        intentMap.remove(intentName);
+        super.removedService(reference, service);
+    }
+}
\ No newline at end of file

Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.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=1412771&r1=1412770&r2=1412771&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 Fri Nov 23 08:10:22 2012
@@ -89,7 +89,6 @@ public class IntentUtils {
         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=1412771&r1=1412770&r2=1412771&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 Fri Nov 23 08:10:22 2012
@@ -22,6 +22,7 @@ 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;
@@ -113,11 +114,10 @@ public class RemoteServiceAdminCore impl
                 OsgiUtils.overlayProperties(serviceProperties, additionalProperties);
             }
 
-            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
+            try {
+                intentManager.assertAllIntentsSupported(serviceProperties);
+            } catch (RuntimeException e) {
+                LOG.error(e.getMessage(), e);
                 return Collections.emptyList();
             }
 
@@ -392,48 +392,51 @@ public class RemoteServiceAdminCore impl
         try {
             // MARC: relies on dynamic imports ?
             Class<?> iClass = bctx.getBundle().loadClass(interfaceName);
-            if (iClass != null) {
-                BundleContext actualContext = bctx;
-                Class<?> actualClass = requestingContext.getBundle().loadClass(interfaceName);
-                if (actualClass != iClass) {
-                    LOG.info("Class " + interfaceName + " loaded by DSW's bundle context is not "
+            if (iClass == null) {
+                throw new ClassNotFoundException("Cannot load interface class");
+            }
+            
+            BundleContext actualContext = bctx;
+            Class<?> actualClass = requestingContext.getBundle().loadClass(interfaceName);
+            if (actualClass != iClass) {
+                LOG.info("Class " + interfaceName + " loaded by DSW's bundle context is not "
                              + "equal to the one loaded by the requesting bundle context, "
                              + "DSW will use the requesting bundle context to register " + "a proxy service");
-                    iClass = actualClass;
-                    actualContext = requestingContext;
-                }
-
-                /* TODO: add additional local params ... */
-                Dictionary<String, Object> serviceProps = new Hashtable<String, Object>(imReg.getImportedEndpointDescription()
-                    .getProperties());
-                serviceProps.put(RemoteConstants.SERVICE_IMPORTED, true);
-                serviceProps.remove(RemoteConstants.SERVICE_EXPORTED_INTERFACES);
-
-                // synchronized (discoveredServices) {
-                ClientServiceFactory csf = new ClientServiceFactory(actualContext, iClass, imReg
-                    .getImportedEndpointDescription(), handler, imReg);
-
-                imReg.setClientServiceFactory(csf);
-                ServiceRegistration proxyRegistration = actualContext.registerService(interfaceName, csf,
-                                                                                      serviceProps);
-                imReg.setImportedServiceRegistration(proxyRegistration);
-                // cacheEndpointId(sd, proxyRegistration);
-                // }
-            } else {
-                LOG.info("not proxifying service, cannot load interface class: " + interfaceName);
-                imReg.setException(new ClassNotFoundException(
-                                                              "not proxifying service, cannot load interface class: "
-                                                                  + interfaceName));
+                iClass = actualClass;
+                actualContext = requestingContext;
             }
-        } catch (ClassNotFoundException ex) {
+
+            EndpointDescription ed = imReg.getImportedEndpointDescription();
+            /* TODO: add additional local params ... */
+            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);
+            imReg.setClientServiceFactory(csf);
+            ServiceRegistration proxyReg = actualContext.registerService(interfaceName, csf, serviceProps);
+            imReg.setImportedServiceRegistration(proxyReg);
+        } catch (Exception ex) {
             if (LOG.isDebugEnabled()) {
                 // Only logging at debug level as this might be written to the log at the TopologyManager
-                LOG.debug("No class can be found for " + interfaceName, ex);
+                LOG.debug("Can not proxy service with interface " + interfaceName + ": " + ex.getMessage(), ex);
             }
             imReg.setException(ex);
         }
     }
 
+    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/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=1412771&r1=1412770&r2=1412771&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 Fri Nov 23 08:10:22 2012
@@ -43,7 +43,7 @@ public class ConfigTypeHandlerFactoryTes
         Map<String, Object> serviceProps = new HashMap<String, Object>();
 
         IntentMap intentMap = new IntentMap();
-        IntentManager intentManager = new IntentManagerImpl(intentMap );
+        IntentManager intentManager = new IntentManagerImpl(intentMap);
         ConfigTypeHandlerFactory f = new ConfigTypeHandlerFactory(intentManager );
 
         configs.add(Constants.RS_CONFIG_TYPE);

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=1412771&r1=1412770&r2=1412771&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 Fri Nov 23 08:10:22 2012
@@ -18,7 +18,6 @@
   */
 package org.apache.cxf.dosgi.dsw.handlers;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,13 +28,10 @@ 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.qos.IntentUnsatifiedException;
 import org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.feature.Feature;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
@@ -383,10 +379,6 @@ public class HttpServiceConfigurationTyp
             this.applyResult = applyResult;
         }
         
-        public List<String> getUnsupportedIntents(Properties serviceProperties) {
-            return new ArrayList<String>();
-        }
-
         public BindingConfiguration getBindingConfiguration(String[] requestedIntents,
                 BindingConfiguration defaultConfig) {
             return defaultConfig;
@@ -400,5 +392,8 @@ public class HttpServiceConfigurationTyp
         public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory, Map<String, Object> props) {
             return applyResult;
         }
+
+        public void assertAllIntentsSupported(Properties serviceProperties) {
+        }
     };
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java?rev=1412771&r1=1412770&r2=1412771&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java Fri Nov 23 08:10:22 2012
@@ -20,7 +20,6 @@ package org.apache.cxf.dosgi.dsw.qos;
 
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertTrue;
-import static org.easymock.EasyMock.expect;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -37,20 +36,12 @@ import org.apache.cxf.dosgi.dsw.Constant
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.feature.Feature;
-import org.easymock.Capture;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
 import org.junit.Before;
 import org.junit.Test;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
 
 public class IntentManagerImplTest {
-    private static final String MY_INTENT_NAME = "myIntent";
     private Map<String, Object> handlerProps;
     
     @Before
@@ -72,7 +63,7 @@ public class IntentManagerImplTest {
         AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
         control.replay();
 
-        IntentManager intentManager = new IntentManagerImpl(intentMap);
+        IntentManager intentManager = new IntentManagerImpl(intentMap, 10000);
         
         Map<String, Object> props = new HashMap<String, Object>();
         props.put("osgi.remote.requires.intents", "A");
@@ -287,43 +278,6 @@ public class IntentManagerImplTest {
         assertEquals(expectedIntents, effectiveIntents);
     }
     
-    @Test
-    public void testIntentAsService() throws InvalidSyntaxException {
-        IMocksControl c = EasyMock.createControl();
-        BundleContext bc = c.createMock(BundleContext.class);
-        Filter filter = c.createMock(Filter.class);
-        expect(bc.createFilter(EasyMock.<String>anyObject())).andReturn(filter);
-        expect(bc.getProperty(org.osgi.framework.Constants.FRAMEWORK_VERSION)).andReturn("1.6.0");
-        final Capture<ServiceListener> capturedListener = new Capture<ServiceListener>();
-        bc.addServiceListener(EasyMock.capture(capturedListener), EasyMock.<String>anyObject());
-        EasyMock.expectLastCall().atLeastOnce();
-        expect(bc.getServiceReferences(EasyMock.<String>anyObject(), EasyMock.<String>anyObject())).andReturn(new ServiceReference[]{});
-        IntentMap intentMap = new IntentMap();
-
-        // Create a custom intent
-        ServiceReference reference = c.createMock(ServiceReference.class);
-        expect(reference.getProperty(Constants.INTENT_NAME_PROP)).andReturn(MY_INTENT_NAME);
-        TestFeature testIntent = new TestFeature(MY_INTENT_NAME);
-        expect(bc.getService(reference)).andReturn(testIntent).atLeastOnce();
-
-        c.replay();
-        
-        new IntentManagerImpl(bc, intentMap);
-        Assert.assertFalse("IntentMap should not contain " + MY_INTENT_NAME, intentMap.containsKey(MY_INTENT_NAME));
-        ServiceListener listener = capturedListener.getValue();
-        
-        // Simulate adding custom intent service
-        ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, reference);
-        listener.serviceChanged(event);
-        
-        // our custom intent should now be available
-        Assert.assertTrue("IntentMap should contain " + MY_INTENT_NAME, intentMap.containsKey(MY_INTENT_NAME));
-        Assert.assertEquals(testIntent, intentMap.get(MY_INTENT_NAME));
-        
-        c.verify();
-        
-    }
-    
     private static class TestFeature extends AbstractFeature {
         private final String name;
         

Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java?rev=1412771&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java Fri Nov 23 08:10:22 2012
@@ -0,0 +1,78 @@
+/** 
+  * 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 static org.easymock.EasyMock.expect;
+import junit.framework.Assert;
+
+import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.feature.AbstractFeature;
+import org.easymock.Capture;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+
+public class IntentTrackerTest {
+    private static final String MY_INTENT_NAME = "myIntent";
+
+    @Test
+    public void testIntentAsService() throws InvalidSyntaxException {
+        IMocksControl c = EasyMock.createControl();
+        BundleContext bc = c.createMock(BundleContext.class);
+        Filter filter = c.createMock(Filter.class);
+        expect(bc.createFilter(EasyMock.<String>anyObject())).andReturn(filter);
+        expect(bc.getProperty(org.osgi.framework.Constants.FRAMEWORK_VERSION)).andReturn("1.6.0");
+        final Capture<ServiceListener> capturedListener = new Capture<ServiceListener>();
+        bc.addServiceListener(EasyMock.capture(capturedListener), EasyMock.<String>anyObject());
+        EasyMock.expectLastCall().atLeastOnce();
+        expect(bc.getServiceReferences(EasyMock.<String>anyObject(), EasyMock.<String>anyObject())).andReturn(new ServiceReference[]{});
+        IntentMap intentMap = new IntentMap();
+
+        // Create a custom intent
+        ServiceReference reference = c.createMock(ServiceReference.class);
+        expect(reference.getProperty(Constants.INTENT_NAME_PROP)).andReturn(MY_INTENT_NAME);
+        AbstractFeature testIntent = new AbstractFeature() {};
+        expect(bc.getService(reference)).andReturn(testIntent).atLeastOnce();
+
+        c.replay();
+
+        IntentTracker tracker = new IntentTracker(bc, intentMap);
+        tracker.open();
+        
+        Assert.assertFalse("IntentMap should not contain " + MY_INTENT_NAME, intentMap.containsKey(MY_INTENT_NAME));
+        ServiceListener listener = capturedListener.getValue();
+        
+        // Simulate adding custom intent service
+        ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, reference);
+        listener.serviceChanged(event);
+        
+        // our custom intent should now be available
+        Assert.assertTrue("IntentMap should contain " + MY_INTENT_NAME, intentMap.containsKey(MY_INTENT_NAME));
+        Assert.assertEquals(testIntent, intentMap.get(MY_INTENT_NAME));
+        
+        c.verify();
+        
+    }
+}

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

Modified: cxf/dosgi/trunk/systests2/multi-bundle/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/pom.xml?rev=1412771&r1=1412770&r2=1412771&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/pom.xml (original)
+++ cxf/dosgi/trunk/systests2/multi-bundle/pom.xml Fri Nov 23 08:10:22 2012
@@ -146,11 +146,6 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <version>1.6.1</version>
-        </dependency>
     </dependencies>
 
     <build>

Modified: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java?rev=1412771&r1=1412770&r2=1412771&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java (original)
+++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java Fri Nov 23 08:10:22 2012
@@ -114,7 +114,9 @@ public class MultiBundleTools {
         List<Option> opts = new ArrayList<Option>();
         for (Map.Entry<Integer, String> entry : bundles.entrySet()) {
             String bundleUri = entry.getValue();
-            opts.add(CoreOptions.bundle(bundleUri));
+            if (!bundleUri.contains("pax-logging")) {
+                opts.add(CoreOptions.bundle(bundleUri));
+            }
         }
         return opts.toArray(new Option[opts.size()]);
     }
@@ -124,6 +126,6 @@ public class MultiBundleTools {
     }
     
     public static Option getDistro() throws Exception {
-        return CoreOptions.composite(getDistroBundleOptions(true));
+        return CoreOptions.composite(getDistroBundleOptions(false));
     }
 }

Modified: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/customintent/TestCustomIntent.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/customintent/TestCustomIntent.java?rev=1412771&r1=1412770&r2=1412771&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/customintent/TestCustomIntent.java (original)
+++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/customintent/TestCustomIntent.java Fri Nov 23 08:10:22 2012
@@ -21,6 +21,7 @@ package org.apache.cxf.dosgi.systests2.m
 import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import java.io.IOException;
@@ -47,6 +48,7 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.Configuration;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 
@@ -78,17 +80,19 @@ public class TestCustomIntent extends Ab
         return new Option[] {
                 MultiBundleTools.getDistro(),
                 systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
-                mavenBundle().groupId("org.apache.servicemix.bundles")
-                        .artifactId("org.apache.servicemix.bundles.junit").version("4.9_2"),
-                mavenBundle().groupId("org.apache.cxf.dosgi.samples")
-                        .artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
-                mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common")
-                        .versionAsInProject(), provision(getCustomIntentBundle()), provision(getServiceBundle()),
+                mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.junit").version("4.9_2"),
+                mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
+                mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common").versionAsInProject(), 
+                streamBundle(getCustomIntentBundle()).noStart(), 
+                provision(getServiceBundle()),
                 frameworkStartLevel(100) };
     }
 
     @Test
-    public void testAccessEndpoint() throws Exception {
+    public void testCustomIntent() throws Exception {
+        // There should be warnings of unsatisfied intent myIntent in the log at debug level
+        Thread.sleep(2000);
+        getBundleByName(bundleContext, "CustomIntent").start();
         waitPort(9090);
         ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
         factory.setServiceClass(GreeterService.class);
@@ -109,6 +113,15 @@ public class TestCustomIntent extends Ab
         }
     }
     
+    private Bundle getBundleByName(BundleContext bc, String sn) {
+        for (Bundle bundle : bc.getBundles()) {
+            if (bundle.getSymbolicName().equals(sn)) {
+                return bundle;
+            }
+        }
+        return null;
+    }
+
     private void waitPort(int port) throws Exception {
         for (int i = 0; i < 20; i++) {
             Socket s = null;