cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r702246 - in /cxf/sandbox/dosgi: discovery/local/src/test/resources/ 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/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ ...
Date Mon, 06 Oct 2008 20:06:42 GMT
Author: eglynn
Date: Mon Oct  6 13:06:39 2008
New Revision: 702246

URL: http://svn.apache.org/viewvc?rev=702246&view=rev
Log:
Applying dOSGi patch on behalf of David Bosschaert.


Added:
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/IntentUnsatifiedException.java
  (with props)
Modified:
    cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml
    cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/META-INF/osgi/remote-services.xml
    cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/META-INF/osgi/remote-services.xml
    cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/META-INF/osgi/remote-services.xml
    cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/META-INF/osgi/remote-services.xml
    cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java
    cxf/sandbox/dosgi/systests/basic/src/test/resources/META-INF/osgi/remote-services.xml

Modified: cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml (original)
+++ cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml Mon Oct  6 13:06:39
2008
@@ -16,15 +16,15 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.GreeterService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
+    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9005/greeter</property>
   </service-description>
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.GreeterService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
+    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:10000/greeter</property>
   </service-description>

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java Mon
Oct  6 13:06:39 2008
@@ -19,10 +19,12 @@
 package org.apache.cxf.dosgi.dsw;
 
 public class Constants {
+    public static final String INTENTS_PROPERTY = "osgi.intents";
+    
     public static final String REMOTE_PROPERTY_PREFIX = "osgi.remote";
     
-    public static final String PUBLISH_PROPERTY = REMOTE_PROPERTY_PREFIX + ".publish.interfaces";
-    public static final String INTENTS_PROPERTY = REMOTE_PROPERTY_PREFIX + ".publish.intents";
+    public static final String REMOTE_INTERFACES_PROPERTY = REMOTE_PROPERTY_PREFIX + ".interfaces";
+    public static final String REQUIRES_INTENTS_PROPERTY = REMOTE_PROPERTY_PREFIX + ".requires.intents";
     public static final String CONFIGURATION_PROPERTY = ".configuration";
 
     public static final String CONFIG_TYPE_PROPERTY = 

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
Mon Oct  6 13:06:39 2008
@@ -52,6 +52,9 @@
                                        requestingBundle.getBundleContext(),
                                        iClass,
                                        sd);
+        } catch (IntentUnsatifiedException iue) {
+            LOG.info("Did not create proxy for " + sd.getInterfaceName() + " because intent
" +
+                    iue.getIntent() + " could not be satisfied");
         } catch (Exception ex) {
             LOG.log(Level.WARNING,
                     "Problem creating a remote proxy for " 

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/IntentUnsatifiedException.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/IntentUnsatifiedException.java?rev=702246&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/IntentUnsatifiedException.java
(added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/IntentUnsatifiedException.java
Mon Oct  6 13:06:39 2008
@@ -0,0 +1,16 @@
+package org.apache.cxf.dosgi.dsw.handlers;
+
+public class IntentUnsatifiedException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+    
+    private String intent;
+    
+    public IntentUnsatifiedException(String theIntent) {
+        super(theIntent);
+        intent = theIntent;
+    }
+    
+    public String getIntent() {
+        return intent;
+    }
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/IntentUnsatifiedException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/IntentUnsatifiedException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
Mon Oct  6 13:06:39 2008
@@ -63,7 +63,8 @@
     public Object createProxy(ServiceReference serviceReference,
                               BundleContext dswContext,
                               BundleContext callingContext,
-                              Class<?> iClass, ServiceDescription sd) {
+                              Class<?> iClass, ServiceDescription sd) 
+                              throws IntentUnsatifiedException {
         
         
         String address = getPojoAddress(sd, iClass);
@@ -102,8 +103,7 @@
                                BundleContext callingContext, 
                                ServiceDescription sd, 
                                Class<?> iClass,
-                               Object serviceBean) {
-        
+                               Object serviceBean) throws IntentUnsatifiedException {   
    
         String address = getPojoAddress(sd, iClass);
         if (address == null) {
             LOG.warning("Remote address is unavailable");
@@ -119,35 +119,56 @@
         factory.getServiceFactory().setDataBinding(new AegisDatabinding());
         factory.setServiceBean(serviceBean);
 
-        applyIntents(dswContext, callingContext, factory.getFeatures(), factory, sd);
+        String [] intents = applyIntents(
+            dswContext, callingContext, factory.getFeatures(), factory, sd);
 
         Server server = factory.create();                
-        getDistributionProvider().addExposedService(serviceReference, registerPublication(server));
+        getDistributionProvider().addExposedService(serviceReference, registerPublication(server,
intents));
         return server;
     }
 
-    private Map<String, String> registerPublication(Server server) {
+    private Map<String, String> registerPublication(Server server, String[] intents)
{
         Map<String, String> publicationProperties = new HashMap<String, String>();
         publicationProperties.put(Constants.CONFIG_TYPE_PROPERTY, Constants.POJO_CONFIG_TYPE);
         publicationProperties.put(Constants.POJO_ADDRESS_PROPERTY, 
                 server.getDestination().getAddress().getAddress().getValue());
+        
+        StringBuilder intentsValue = new StringBuilder();
+        boolean first = true;
+        for (String intent : intents) {
+            if (first) {
+                first = false;
+            } else {
+                intentsValue.append(' ');
+            }
+            intentsValue.append(intent);
+        }
+        
+        if (intentsValue.length() > 0) {
+            publicationProperties.put(Constants.INTENTS_PROPERTY, intentsValue.toString());
+        }
         return publicationProperties;
     }
 
-    void applyIntents(BundleContext dswContext,
-                                             BundleContext callingContext,
-                                     List<AbstractFeature> features,
-                                     AbstractEndpointFactory factory,
-                                     ServiceDescription sd) {
+    String [] applyIntents(BundleContext dswContext,
+                           BundleContext callingContext,
+                           List<AbstractFeature> features,
+                           AbstractEndpointFactory factory,
+                           ServiceDescription sd) throws IntentUnsatifiedException {
         String[] requestedIntents = getRequestedIntents(sd);
         
-        IntentMap intentMap = OsgiUtils.getIntentMap(callingContext);
+        IntentMap intentMap = getIntentMap(callingContext);
         
         if (useMasterMap()) {
             intentMap = mergeWithMaster(dswContext, intentMap);
         }
         
         for (int i = 0; i < requestedIntents.length; i++) {
+            // This is temporary
+            if ("HTTP".equals(requestedIntents[i])) {
+                continue;
+            }
+            
             Object intent = intentMap.get(requestedIntents[i]);
             if (intent instanceof AbstractFeature) {
                 AbstractFeature feature = (AbstractFeature)intent;
@@ -162,13 +183,19 @@
                 factory.setBindingConfig(bindingCfg);
             } else {
                 LOG.info("No mapping for intent: " + requestedIntents[i]);
+                throw new IntentUnsatifiedException(requestedIntents[i]);
             }
         }
+        return requestedIntents;
+    }
+
+    IntentMap getIntentMap(BundleContext callingContext) {
+        return OsgiUtils.getIntentMap(callingContext);
     }
 
     private static String[] getRequestedIntents(ServiceDescription sd) {
         String property = 
-            OsgiUtils.getProperty(sd, Constants.INTENTS_PROPERTY);
+            OsgiUtils.getProperty(sd, Constants.REQUIRES_INTENTS_PROPERTY);
         String[] intents = OsgiUtils.parseIntents(property);
         for (int i = 0; i < intents.length; i++) {
             LOG.fine("Intent asserted: " + intents[i]);
@@ -177,11 +204,10 @@
     }
     
     private IntentMap mergeWithMaster(BundleContext dswContext, IntentMap intentMap) {
-        
         synchronized (this) {
             if (masterMap == null) {
                 LOG.fine("Loading master intent map");
-                masterMap = OsgiUtils.getIntentMap(dswContext);
+                masterMap = getIntentMap(dswContext);
             }
         }
         if (masterMap != null) {

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
Mon Oct  6 13:06:39 2008
@@ -56,7 +56,7 @@
         for (ServiceDescription sd  : sds) {
             
             
-            if (!OsgiUtils.getBooleanProperty(sd, Constants.PUBLISH_PROPERTY)) {
+            if (!OsgiUtils.getBooleanProperty(sd, Constants.REMOTE_INTERFACES_PROPERTY))
{
                 continue;
             }
             

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
Mon Oct  6 13:06:39 2008
@@ -56,7 +56,7 @@
         // local configuration data, if any available - it will let
         // this code to check for SDs from the additional source
         if (sd == null
-            || !OsgiUtils.getBooleanProperty(sd, Constants.PUBLISH_PROPERTY)) {
+            || !OsgiUtils.getBooleanProperty(sd, Constants.REMOTE_INTERFACES_PROPERTY)) {
             return;
         }
 

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java
Mon Oct  6 13:06:39 2008
@@ -27,6 +27,7 @@
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.handlers.ConfigTypeHandlerFactory;
 import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.handlers.IntentUnsatifiedException;
 import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.apache.cxf.endpoint.Server;
 import org.osgi.framework.BundleContext;
@@ -82,6 +83,9 @@
                                             sd, 
                                             interfaceClass, 
                                             serviceObject);
+            } catch (IntentUnsatifiedException iue) {
+                LOG.info("Did not remote service " + sd.getInterfaceName() + " because intent
" +
+                		iue.getIntent() + " could not be satisfied");
             } catch (Exception ex) {
                 LOG.warning("WARNING : Problem creating a remote endpoint for " + sd.getInterfaceName()
                         + " from CXF PublishHook, reason is " + ex.getMessage());

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml Mon Oct
 6 13:06:39 2008
@@ -40,6 +40,7 @@
            <entry key="SOAP" value-ref="soap11Binding"/>
            <entry key="SOAP.1_1" value-ref="soap11Binding"/>
            <entry key="SOAP.1_2" value-ref="soap12Binding"/>
+           <!--  <entry key="HTTP"/> -->
          </map>
        </property>
     </bean>

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
Mon Oct  6 13:06:39 2008
@@ -16,7 +16,7 @@
     public void testGetRemoteReferencesFromRegistrationProperties() {
         final Map<String, Object> props = new HashMap<String, Object>();
         props.put(org.osgi.framework.Constants.OBJECTCLASS, new String [] {"myClass"});
-        props.put(Constants.PUBLISH_PROPERTY, "*");
+        props.put(Constants.REMOTE_INTERFACES_PROPERTY, "*");
         
         Bundle b = EasyMock.createNiceMock(Bundle.class);        
         EasyMock.replay(b);
@@ -36,7 +36,7 @@
         
         // Actual test starts here
         ServiceDescription sd = OsgiUtils.getRemoteReference(sr, true);
-        assertEquals("*", sd.getProperties().get(Constants.PUBLISH_PROPERTY));
+        assertEquals("*", sd.getProperties().get(Constants.REMOTE_INTERFACES_PROPERTY));
         
         EasyMock.verify(sr);
     }

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
Mon Oct  6 13:06:39 2008
@@ -18,6 +18,8 @@
   */
 package org.apache.cxf.dosgi.dsw.handlers;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -25,7 +27,9 @@
 import junit.framework.TestCase;
 
 import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.qos.IntentMap;
 import org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl;
+import org.apache.cxf.dosgi.dsw.service.ServiceDescriptionImpl;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.AbstractFeature;
@@ -37,6 +41,7 @@
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.easymock.IAnswer;
 import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.discovery.ServiceDescription;
@@ -70,8 +75,10 @@
             }
             
             @Override
-            void applyIntents(BundleContext dswContext, BundleContext callingContext,
-                List<AbstractFeature> features, AbstractEndpointFactory factory, ServiceDescription
sd) {}
+            String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
+                List<AbstractFeature> features, AbstractEndpointFactory factory, ServiceDescription
sd) {
+                return new String[0];
+            }
         };
         
         ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
@@ -101,8 +108,10 @@
             }
 
             @Override
-            void applyIntents(BundleContext dswContext, BundleContext callingContext,
-                List<AbstractFeature> features, AbstractEndpointFactory factory, ServiceDescription
sd) {}
+            String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
+                List<AbstractFeature> features, AbstractEndpointFactory factory, ServiceDescription
sd) {
+                return new String []{"A", "B"};
+            }
         };
         
         ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
@@ -122,6 +131,7 @@
         Map<String, String> expected = new HashMap<String, String>();
         expected.put("osgi.remote.configuration.type", "pojo");
         expected.put("osgi.remote.configuration.pojo.address", "http://somehost:54321/java/lang/String");
+        expected.put("osgi.intents", "A B");
         assertEquals(expected, dp.getPublicationProperties(sr));
     }
 
@@ -175,4 +185,192 @@
         EasyMock.replay(server);
         return server;
     }
+    
+    public void testIntents() throws Exception {
+        Map<String, Object> intents = new HashMap<String, Object>();
+        intents.put("A", new AbstractFeature() {});
+        final IntentMap intentMap = new IntentMap();
+        intentMap.setIntents(intents);
+        
+        DistributionProviderImpl dp = new DistributionProviderImpl();
+        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp, handlerProps)
{
+            @Override
+            IntentMap getIntentMap(BundleContext callingContext) {
+                return intentMap;
+            }            
+        };
+        
+        IMocksControl control = EasyMock.createNiceControl();
+        BundleContext dswContext = control.createMock(BundleContext.class);
+        BundleContext callingContext = control.createMock(BundleContext.class);        
+        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
+        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
+        control.replay();
+
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(Constants.REQUIRES_INTENTS_PROPERTY, "A");
+        ServiceDescription sd = new ServiceDescriptionImpl(Arrays.asList(String.class.getName()),
props);
+
+        List<String> effectiveIntents = 
+            Arrays.asList(p.applyIntents(dswContext, callingContext, features, factory, sd));
+        assertEquals(Arrays.asList("A"), effectiveIntents);
+    }    
+    
+    public void testMultiIntents() {
+        Map<String, Object> intents = new HashMap<String, Object>();
+        intents.put("confidentiality.message", new AbstractFeature() {});
+        intents.put("transactionality", new AbstractFeature() {});
+        final IntentMap intentMap = new IntentMap();
+        intentMap.setIntents(intents);
+        
+        DistributionProviderImpl dp = new DistributionProviderImpl();
+        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp, handlerProps)
{
+            @Override
+            IntentMap getIntentMap(BundleContext callingContext) {
+                return intentMap;
+            }            
+        };
+        
+        IMocksControl control = EasyMock.createNiceControl();
+        BundleContext dswContext = control.createMock(BundleContext.class);
+        BundleContext callingContext = control.createMock(BundleContext.class);        
+        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
+        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
+        control.replay();
+
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(Constants.REQUIRES_INTENTS_PROPERTY, "transactionality confidentiality.message");
+        ServiceDescription sd = new ServiceDescriptionImpl(Arrays.asList(String.class.getName()),
props);
+
+        List<String> effectiveIntents = 
+            Arrays.asList(p.applyIntents(dswContext, callingContext, features, factory, sd));
+        assertTrue(effectiveIntents.contains("transactionality"));        
+        assertTrue(effectiveIntents.contains("confidentiality.message"));        
+    }
+    
+    public void testFailedIntent() {
+        Map<String, Object> intents = new HashMap<String, Object>();
+        intents.put("A", new AbstractFeature() {});
+        final IntentMap intentMap = new IntentMap();
+        intentMap.setIntents(intents);
+        
+        DistributionProviderImpl dp = new DistributionProviderImpl();
+        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp, handlerProps)
{
+            @Override
+            IntentMap getIntentMap(BundleContext callingContext) {
+                return intentMap;
+            }            
+        };
+        
+        IMocksControl control = EasyMock.createNiceControl();
+        BundleContext dswContext = control.createMock(BundleContext.class);
+        BundleContext callingContext = control.createMock(BundleContext.class);        
+        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
+        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
+        control.replay();
+
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(Constants.REQUIRES_INTENTS_PROPERTY, "A B");
+        ServiceDescription sd = new ServiceDescriptionImpl(Arrays.asList(String.class.getName()),
props);
+
+        try {
+            p.applyIntents(dswContext, callingContext, features, factory, sd);
+            fail("applyIntents() should have thrown an exception as there was an unsatisfiable
intent");
+        } catch (IntentUnsatifiedException iue) {
+            assertEquals("B", iue.getIntent());
+        }
+    }
+    
+    public void testInheritMasterIntentMapDefault() {
+        List<String> features = runTestInheritMasterIntentMap("A B");
+        
+        assertEquals(2, features.size());
+        assertTrue(features.contains("appFeatureA"));
+        assertTrue(features.contains("masterFeatureB"));
+    }
+    
+    public void testInheritMasterIntentMap() {
+        handlerProps.put(Constants.USE_MASTER_MAP, "true");
+        List<String> features = runTestInheritMasterIntentMap("A B");
+        
+        assertEquals(2, features.size());
+        assertTrue(features.contains("appFeatureA"));
+        assertTrue(features.contains("masterFeatureB"));
+    }
+
+    public void testDontInheritMasterIntentMapFails() {
+        handlerProps.put(Constants.USE_MASTER_MAP, "false");
+        try {
+            runTestInheritMasterIntentMap("A B");
+            fail("Should have failed as intent B was not satisfied");
+        } catch (IntentUnsatifiedException iue) {
+            assertEquals("B", iue.getIntent());
+        }    
+    }
+
+    public void testDontInheritMasterIntentMapSucceeds() {
+        handlerProps.put(Constants.USE_MASTER_MAP, "false");
+        List<String> features = runTestInheritMasterIntentMap("A");
+        
+        assertEquals(1, features.size());
+        assertTrue(features.contains("appFeatureA"));
+    }
+
+    private List<String> runTestInheritMasterIntentMap(String requestedIntents) {
+        Map<String, Object> masterIntents = new HashMap<String, Object>();
+        masterIntents.put("A", new TestFeature("masterFeatureA"));
+        masterIntents.put("B", new TestFeature("masterFeatureB"));
+        final IntentMap masterIntentMap = new IntentMap();
+        masterIntentMap.setIntents(masterIntents);
+        
+        Map<String, Object> appIntents = new HashMap<String, Object>();
+        appIntents.put("A", new TestFeature("appFeatureA"));
+        final IntentMap appIntentMap = new IntentMap();
+        appIntentMap.setIntents(appIntents);
+
+        DistributionProviderImpl dp = new DistributionProviderImpl();
+        IMocksControl control = EasyMock.createNiceControl();
+        final BundleContext dswContext = control.createMock(BundleContext.class);
+        final BundleContext callingContext = control.createMock(BundleContext.class);   
    
+        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
+        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
+        control.replay();
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(Constants.REQUIRES_INTENTS_PROPERTY, requestedIntents);
+        ServiceDescription sd = new ServiceDescriptionImpl(Arrays.asList(String.class.getName()),
props);
+        
+        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp, handlerProps)
{
+            @Override
+            IntentMap getIntentMap(BundleContext ctx) {
+                if (ctx == callingContext) {
+                    return appIntentMap;
+                } else if (ctx == dswContext) {
+                    return masterIntentMap;
+                } else {
+                    return null;
+                }
+            }            
+        };
+        
+        p.applyIntents(dswContext, callingContext, features, factory, sd);
+
+        List<String> featureNames = new ArrayList<String>();
+        for (AbstractFeature f : features) {
+            featureNames.add(f.toString());
+        }
+        return featureNames;
+    }
+    
+    private static class TestFeature extends AbstractFeature {
+        private final String name;
+        
+        private TestFeature(String n) {
+            name = n;
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+    }
 }

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml Mon
Oct  6 13:06:39 2008
@@ -22,8 +22,8 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.dsw.hooks.TestService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
+    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9000/hello</property>
   </service-description>

Modified: cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/META-INF/osgi/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/META-INF/osgi/remote-services.xml?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/META-INF/osgi/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/META-INF/osgi/remote-services.xml
Mon Oct  6 13:06:39 2008
@@ -16,12 +16,12 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.greeter.GreeterService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
+    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <!--
-      property name="osgi.remote.publish.intents">reliability decoupled
+      property name="osgi.remote.requires.intents">reliability decoupled
       SOAP HTTP</property
     -->
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9090/greeter</property>
   </service-description>

Modified: cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/META-INF/osgi/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/META-INF/osgi/remote-services.xml?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/META-INF/osgi/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/META-INF/osgi/remote-services.xml
Mon Oct  6 13:06:39 2008
@@ -16,8 +16,8 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.greeter.GreeterService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
+    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9090/greeter</property>
   </service-description>

Modified: cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/META-INF/osgi/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/META-INF/osgi/remote-services.xml?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/META-INF/osgi/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/META-INF/osgi/remote-services.xml
Mon Oct  6 13:06:39 2008
@@ -16,20 +16,20 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.HelloService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
+    <property key="osgi.remote.interfaces">true</property>
 
 <!-- Uncomment to enable SOAP 1.2 and confirm via message logging -->
     <!--
-      property name="osgi.remote.publish.intents">logging SOAP.1_2
+      property name="osgi.remote.requires.intents">logging SOAP.1_2
       HTTP</property
     -->
 
 <!-- Uncomment to enable WS-RM and confirm via message logging -->
     <!--
-      property name="osgi.remote.publish.intents">logging reliability
+      property name="osgi.remote.requires.intents">logging reliability
       SOAP HTTP</property
     -->
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9000/hello</property>
   </service-description>

Modified: cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/META-INF/osgi/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/META-INF/osgi/remote-services.xml?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/META-INF/osgi/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/META-INF/osgi/remote-services.xml
Mon Oct  6 13:06:39 2008
@@ -16,27 +16,27 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.HelloService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
+    <property key="osgi.remote.interfaces">true</property>
 
 <!-- Uncomment to enable SOAP 1.2 and confirm via message logging -->
     <!--
-      property name="osgi.remote.publish.intents">logging SOAP.1_2
+      property name="osgi.remote.requires.intents">logging SOAP.1_2
       HTTP</property
     -->
 
 <!-- Uncomment to enable WS-RM and confirm via message logging -->
     <!--
-      property name="osgi.remote.publish.intents">logging reliability
+      property name="osgi.remote.requires.intents">logging reliability
       SOAP HTTP</property
     -->
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9000/hello</property>
   </service-description>
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.GreeterService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
+    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9005/greeter</property>
   </service-description>

Modified: cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java
(original)
+++ cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java
Mon Oct  6 13:06:39 2008
@@ -89,7 +89,6 @@
     public void testBasicInvocation() throws Exception {
         
         Dictionary<String, Object> props = new Hashtable<String, Object>();
-        props.put("use.master.map", "false");
         props.put(Constants.SERVICE_PID, "cxf-dsw");
         
         ServiceReference[] srefs

Modified: cxf/sandbox/dosgi/systests/basic/src/test/resources/META-INF/osgi/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/systests/basic/src/test/resources/META-INF/osgi/remote-services.xml?rev=702246&r1=702245&r2=702246&view=diff
==============================================================================
--- cxf/sandbox/dosgi/systests/basic/src/test/resources/META-INF/osgi/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/systests/basic/src/test/resources/META-INF/osgi/remote-services.xml
Mon Oct  6 13:06:39 2008
@@ -16,15 +16,15 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.HelloService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
+    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9000/hello</property>
   </service-description>
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.GreeterService" />
-    <property key="osgi.remote.publish.interfaces">true</property>
-    <property key="osgi.remote.publish.intents">SOAP HTTP</property>
+    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9005/greeter</property>
   </service-description>



Mime
View raw message