aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1291355 - in /aries/trunk/spi-fly: spi-fly-core/src/main/java/org/apache/aries/spifly/ spi-fly-core/src/main/java/org/apache/aries/spifly/api/ spi-fly-core/src/test/java/org/apache/aries/spifly/ spi-fly-dynamic-bundle/ spi-fly-dynamic-bund...
Date Mon, 20 Feb 2012 16:44:30 GMT
Author: davidb
Date: Mon Feb 20 16:44:29 2012
New Revision: 1291355

URL: http://svn.apache.org/viewvc?rev=1291355&view=rev
Log:
Change Provide-Capability/Require-Capability model to follow latest thinking for the ServiceLoader
Mediator spec.

Modified:
    aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/BaseActivator.java
    aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java
    aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizer.java
    aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/api/SpiFlyConstants.java
    aries/trunk/spi-fly/spi-fly-core/src/test/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizerGenericCapabilityTest.java
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookGenericCapabilityTest.java
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-client2-bundle/pom.xml
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider2-bundle/pom.xml

Modified: aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/BaseActivator.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/BaseActivator.java?rev=1291355&r1=1291354&r2=1291355&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/BaseActivator.java
(original)
+++ aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/BaseActivator.java
Mon Feb 20 16:44:29 2012
@@ -230,13 +230,13 @@ public abstract class BaseActivator impl
                 } else if (desc.getFilter() != null) {
                     Hashtable<String, Object> d = new Hashtable<String, Object>();
                     d.put(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, b.getSymbolicName());
-                    d.put(SpiFlyConstants.BUNDLE_VERSION_ATTRIBUTE, b.getVersion());
+                    d.put(Constants.BUNDLE_VERSION_ATTRIBUTE, b.getVersion());
 
                     if (ServiceLoader.class.getName().equals(className) &&
                         "load".equals(methodName)) {
                         String type = args.get(new Pair<Integer, String>(0, Class.class.getName()));
                         if (type != null) {
-                            d.put(SpiFlyConstants.SERVICE_ATTRIBUTE, type);
+                            d.put(SpiFlyConstants.CONSUMED_SPI_CONDITION, type);
                             d.putAll(getCustomBundleAttributes(type, b));
                         }
                     }

Modified: aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java?rev=1291355&r1=1291354&r2=1291355&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java
(original)
+++ aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java
Mon Feb 20 16:44:29 2012
@@ -170,27 +170,25 @@ public class ConsumerHeaderProcessor {
 
         List<GenericMetadata> requirements = ManifestHeaderProcessor.parseRequirementString(consumerHeader);
         for (GenericMetadata req : requirements) {
-            if (SpiFlyConstants.SPI_CAPABILITY_NAMESPACE.equals(req.getNamespace())) {
-                if (!"active".equals(req.getDirectives().get("effective"))) {
-                    continue;
-                }
-
-                ArgRestrictions ar = new ArgRestrictions();
-                ar.addRestriction(0, Class.class.getName());
-                MethodRestriction mr = new MethodRestriction("load", ar);
-
-                List<BundleDescriptor> allowedBundles = new ArrayList<BundleDescriptor>();
-                String filterString = req.getDirectives().get("filter");
-                if (filterString != null) {
-                    try {
-                        Filter filter = FrameworkUtil.createFilter(filterString);
-                        allowedBundles.add(new BundleDescriptor(filter));
-                    } catch (InvalidSyntaxException e) {
-                        throw new IllegalArgumentException("Syntax error in filter " + filterString
+ " which appears in " + consumerHeader);
+            if (SpiFlyConstants.EXTENDER_CAPABILITY_NAMESPACE.equals(req.getNamespace()))
{
+                if (SpiFlyConstants.CLIENT_EXTENDER_NAME.equals(req.getAttributes().get(SpiFlyConstants.EXTENDER_CAPABILITY_NAMESPACE)))
{
+                    ArgRestrictions ar = new ArgRestrictions();
+                    ar.addRestriction(0, Class.class.getName());
+                    MethodRestriction mr = new MethodRestriction("load", ar);
+
+                    List<BundleDescriptor> allowedBundles = new ArrayList<BundleDescriptor>();
+                    String filterString = req.getDirectives().get(SpiFlyConstants.PROVIDER_FILTER_DIRECTIVE);
+                    if (filterString != null) {
+                        try {
+                            Filter filter = FrameworkUtil.createFilter(filterString);
+                            allowedBundles.add(new BundleDescriptor(filter));
+                        } catch (InvalidSyntaxException e) {
+                            throw new IllegalArgumentException("Syntax error in filter "
+ filterString + " which appears in " + consumerHeader);
+                        }
                     }
-                }
 
-                weavingData.add(createWeavingData(ServiceLoader.class.getName(), "load",
mr, allowedBundles));
+                    weavingData.add(createWeavingData(ServiceLoader.class.getName(), "load",
mr, allowedBundles));
+                }
             }
         }
 

Modified: aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizer.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizer.java?rev=1291355&r1=1291354&r2=1291355&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizer.java
(original)
+++ aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizer.java
Mon Feb 20 16:44:29 2012
@@ -69,13 +69,8 @@ public class ProviderBundleTrackerCustom
         List<String> providedServices = null;
         Map<String, Object> customAttributes = new HashMap<String, Object>();
         Map<String, String> directives = new HashMap<String, String>();
-        if (bundle.getHeaders().get("Provide-Capability") != null) {
-            providedServices = readProvideCapability(bundle.getHeaders(), directives, customAttributes);
-
-            if (!"active".equals(directives.get(SpiFlyConstants.EFFECTIVE_DIRECTIVE))) {
-                log(LogService.LOG_INFO, "Effective is not equal to 'active'. Not processing
bundle " + bundle.getSymbolicName());
-                return null;
-            }
+        if (bundle.getHeaders().get(SpiFlyConstants.REQUIRE_CAPABILITY) != null) {
+            providedServices = readRequireCapability(bundle.getHeaders(), directives, customAttributes);
         }
 
         if (providedServices == null && bundle.getHeaders().get(SpiFlyConstants.SPI_PROVIDER_HEADER)
!= null) {
@@ -156,7 +151,7 @@ public class ProviderBundleTrackerCustom
                         log(LogService.LOG_INFO, "Instantiated SPI provider: " + o);
 
                         Hashtable<String, Object> props = new Hashtable<String,
Object>();
-                        props.put(SpiFlyConstants.SPI_PROVIDER_URL, serviceFile);
+                        props.put(SpiFlyConstants.SPI_PROVIDER_URL_PROPERTY, serviceFile);
                         props.putAll(customAttributes);
 
                         if (!"false".equalsIgnoreCase(directives.get(SpiFlyConstants.SERVICE_REGISTRY_DIRECTIVE)))
{
@@ -184,33 +179,41 @@ public class ProviderBundleTrackerCustom
     // An empty list returned means 'all SPIs'
     // A return value of null means no SPIs
     // A populated list means: only these SPIs
-    @SuppressWarnings("unchecked")
-    private List<String> readProvideCapability(Dictionary<?,?> headers, Map<String,
String> directives, Map<String, Object> customAttributes) {
-        Object capabilityHeader = headers.get(SpiFlyConstants.PROVIDE_CAPABILITY);
+    private List<String> readRequireCapability(Dictionary<?,?> headers, Map<String,
String> directives, Map<String, Object> customAttributes) {
+        Object capabilityHeader = headers.get(SpiFlyConstants.REQUIRE_CAPABILITY);
         if (capabilityHeader == null)
             return null;
 
         List<GenericMetadata> capabilities = ManifestHeaderProcessor.parseCapabilityString(capabilityHeader.toString());
         for (GenericMetadata cap : capabilities) {
-            if (!SpiFlyConstants.SPI_CAPABILITY_NAMESPACE.equals(cap.getNamespace()))
+            if (!SpiFlyConstants.EXTENDER_CAPABILITY_NAMESPACE.equals(cap.getNamespace()))
                 continue;
 
-            List<String> serviceNames = new ArrayList<String>();
             for (Map.Entry<String, Object> entry : cap.getAttributes().entrySet())
{
-                if (SpiFlyConstants.SERVICE_ATTRIBUTE.equals(entry.getKey())) {
-                    if (entry.getValue() instanceof String) {
-                        serviceNames.add((String) entry.getValue());
-                    } else if (entry.getValue() instanceof String []) {
-                        serviceNames.addAll(Arrays.asList((String []) entry.getValue()));
-                    } else if (entry.getValue() instanceof List) {
-                        serviceNames.addAll((List<String>) entry.getValue());
+                if (SpiFlyConstants.EXTENDER_CAPABILITY_NAMESPACE.equals(entry.getKey()))
+                    continue;
+
+                customAttributes.put(entry.getKey(), entry.getValue());
+            }
+
+            List<String> serviceNames = new ArrayList<String>();
+            for (Map.Entry<String, String> entry : cap.getDirectives().entrySet())
{
+                if ("filter".equals(entry.getKey()))
+                    continue;
+                if ("resolution".equals(entry.getKey()))
+                    continue;
+
+                if (SpiFlyConstants.PROVIDED_SPI_DIRECTIVE.equals(entry.getKey())) {
+                    if (entry.getValue() != null) {
+                        serviceNames.add(entry.getValue());
+                        // TODO split string
                     }
                 } else {
-                    customAttributes.put(entry.getKey(), entry.getValue());
+                    directives.put(entry.getKey(), entry.getValue());
                 }
             }
 
-            directives.putAll(cap.getDirectives());
+            // directives.putAll(cap.getDirectives());
             return serviceNames;
         }
         return null;

Modified: aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/api/SpiFlyConstants.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/api/SpiFlyConstants.java?rev=1291355&r1=1291354&r2=1291355&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/api/SpiFlyConstants.java
(original)
+++ aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/api/SpiFlyConstants.java
Mon Feb 20 16:44:29 2012
@@ -20,22 +20,26 @@ package org.apache.aries.spifly.api;
 
 public interface SpiFlyConstants {
     // Not taken from OSGi Constants because this code needs to compile with the 4.2 OSGi
classes.
-    String PROVIDE_CAPABILITY = "Provide-Capability";
     String REQUIRE_CAPABILITY = "Require-Capability";
 
     String SPI_CONSUMER_HEADER = "SPI-Consumer";
     String SPI_PROVIDER_HEADER = "SPI-Provider";
 
-    String SPI_CAPABILITY_NAMESPACE = "osgi.spi.provider";
-    String EXTENDER_CAPABILITY_NAMESPACE = "osgi.jse.serviceloader";
+    String EXTENDER_CAPABILITY_NAMESPACE = "osgi.extender";
 
-    String BUNDLE_VERSION_ATTRIBUTE = "bundle-version";
-    String SERVICE_ATTRIBUTE = "service";
+    String CLIENT_EXTENDER_NAME = "spi.consumer.mediator";
+    String PROVIDER_EXTENDER_NAME = "spi.provider.mediator";
 
-    String EFFECTIVE_DIRECTIVE = "effective";
+    String CLIENT_REQUIREMENT = EXTENDER_CAPABILITY_NAMESPACE + "; " + EXTENDER_CAPABILITY_NAMESPACE
+ "=" + CLIENT_EXTENDER_NAME;
+    String PROVIDER_REQUIREMENT = EXTENDER_CAPABILITY_NAMESPACE + "; " + EXTENDER_CAPABILITY_NAMESPACE
+ "=" + PROVIDER_EXTENDER_NAME;
+
+    String CONSUMED_SPI_CONDITION = "spi";
+
+    String PROVIDED_SPI_DIRECTIVE = "provided-spi";
+    String PROVIDER_FILTER_DIRECTIVE = "provider-filter";
     String SERVICE_REGISTRY_DIRECTIVE = "service-registry";
 
     String PROCESSED_SPI_CONSUMER_HEADER = "X-SpiFly-Processed-SPI-Consumer";
 
-    String SPI_PROVIDER_URL = "spi.provider.url";
+    String SPI_PROVIDER_URL_PROPERTY = "spi.provider.url";
 }

Modified: aries/trunk/spi-fly/spi-fly-core/src/test/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizerGenericCapabilityTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-core/src/test/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizerGenericCapabilityTest.java?rev=1291355&r1=1291354&r2=1291355&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-core/src/test/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizerGenericCapabilityTest.java
(original)
+++ aries/trunk/spi-fly/spi-fly-core/src/test/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizerGenericCapabilityTest.java
Mon Feb 20 16:44:29 2012
@@ -102,7 +102,8 @@ public class ProviderBundleTrackerCustom
         EasyMock.replay(sreg);
 
         BundleContext implBC = mockSPIBundleContext(sreg);
-        Bundle implBundle = mockSPIBundle(implBC, "osgi.spi.provider; effective:=active;
service-registry:=true; approval=global");
+        Bundle implBundle = mockSPIBundle(implBC, SpiFlyConstants.PROVIDER_REQUIREMENT +
+                "; service-registry:=true; approval=global");
 
         List<ServiceRegistration> registrations = customizer.addingBundle(implBundle,
null);
         assertEquals(1, registrations.size());
@@ -129,12 +130,12 @@ public class ProviderBundleTrackerCustom
 
         BundleContext implBC = mockSPIBundleContext4();
         Bundle implBundle =
-            mockSPIBundle4(implBC, "osgi.spi.provider; effective:=active; service=org.apache.aries.mytest.MySPI;
approval=global");
+            mockSPIBundle4(implBC, SpiFlyConstants.PROVIDER_REQUIREMENT + "; " + SpiFlyConstants.PROVIDED_SPI_DIRECTIVE
+ ":=org.apache.aries.mytest.MySPI; approval=global");
 
         List<ServiceRegistration> registrations = customizer.addingBundle(implBundle,
null);
         assertEquals(1, registrations.size());
         assertEquals("org.apache.aries.mytest.MySPI", registrations.iterator().next().getReference().getProperty(Constants.OBJECTCLASS));
-        assertNotNull(registrations.iterator().next().getReference().getProperty(SpiFlyConstants.SPI_PROVIDER_URL));
+        assertNotNull(registrations.iterator().next().getReference().getProperty(SpiFlyConstants.SPI_PROVIDER_URL_PROPERTY));
         assertEquals("global", registrations.iterator().next().getReference().getProperty("approval"));
     }
 
@@ -152,7 +153,7 @@ public class ProviderBundleTrackerCustom
 
         BundleContext implBC = mockSPIBundleContext4();
         Bundle implBundle =
-            mockSPIBundle4(implBC, "osgi.spi.provider; effective:=active");
+            mockSPIBundle4(implBC, SpiFlyConstants.PROVIDER_REQUIREMENT);
 
         List<ServiceRegistration> registrations = customizer.addingBundle(implBundle,
null);
         assertEquals(3, registrations.size());
@@ -194,7 +195,7 @@ public class ProviderBundleTrackerCustom
         EasyMock.replay(sreg);
 
         BundleContext implBC = mockSPIBundleContext(sreg);
-        Bundle implBundle = mockSPIBundle(implBC, "osgi.spi.provider; effective:=active;
service-registry:=false");
+        Bundle implBundle = mockSPIBundle(implBC, SpiFlyConstants.PROVIDER_REQUIREMENT +
"; service-registry:=false");
 
         List<ServiceRegistration> registrations = customizer.addingBundle(implBundle,
null);
         assertEquals(0, registrations.size());
@@ -275,7 +276,7 @@ public class ProviderBundleTrackerCustom
         EasyMock.expect(implBundle.getBundleContext()).andReturn(implBC).anyTimes();
 
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put("Provide-Capability", "osgi.spi.provider; effective:=active;");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.PROVIDER_REQUIREMENT);
         headers.put(Constants.BUNDLE_CLASSPATH, ".,non-jar.jar,embedded.jar,embedded2.jar");
         EasyMock.expect(implBundle.getHeaders()).andReturn(headers).anyTimes();
 
@@ -303,7 +304,7 @@ public class ProviderBundleTrackerCustom
 
         assertEquals("Precondition", 0, activator.findProviderBundles("org.apache.aries.mytest.MySPI").size());
         // Call addingBundle();
-        List<ServiceRegistration> registrations = customizer.addingBundle(implBundle,
null);
+        customizer.addingBundle(implBundle, null);
         Collection<Bundle> bundles = activator.findProviderBundles("org.apache.aries.mytest.MySPI");
         assertEquals(1, bundles.size());
         assertSame(implBundle, bundles.iterator().next());
@@ -324,7 +325,7 @@ public class ProviderBundleTrackerCustom
     }
 
     private Bundle mockSPIBundle(BundleContext implBC) throws ClassNotFoundException {
-        return mockSPIBundle(implBC, "osgi.spi.provider; effective:=active;");
+        return mockSPIBundle(implBC, SpiFlyConstants.PROVIDER_REQUIREMENT);
     }
 
     private Bundle mockSPIBundle(BundleContext implBC, String spiProviderHeader) throws ClassNotFoundException
{
@@ -333,7 +334,7 @@ public class ProviderBundleTrackerCustom
 
         Dictionary<String, String> headers = new Hashtable<String, String>();
         if (spiProviderHeader != null)
-            headers.put("Provide-Capability", spiProviderHeader);
+            headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, spiProviderHeader);
         EasyMock.expect(implBundle.getHeaders()).andReturn(headers).anyTimes();
 
         // List the resources found at META-INF/services in the test bundle
@@ -350,6 +351,7 @@ public class ProviderBundleTrackerCustom
         return implBundle;
     }
 
+    @SuppressWarnings("unchecked")
     private BundleContext mockSPIBundleContext4() {
         BundleContext implBC = EasyMock.createNiceMock(BundleContext.class);
 
@@ -357,7 +359,6 @@ public class ProviderBundleTrackerCustom
             registerService((String) EasyMock.anyObject(), EasyMock.anyObject(), (Dictionary<String,?>)EasyMock.anyObject())).
             andAnswer(new IAnswer<ServiceRegistration>() {
                 @Override
-                @SuppressWarnings("unchecked")
                 public ServiceRegistration answer() throws Throwable {
                     final String className = (String) EasyMock.getCurrentArguments()[0];
                     final Object serviceObject = EasyMock.getCurrentArguments()[1];
@@ -398,7 +399,7 @@ public class ProviderBundleTrackerCustom
 
         Dictionary<String, String> headers = new Hashtable<String, String>();
         if (spiProviderHeader != null)
-            headers.put("Provide-Capability", spiProviderHeader);
+            headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, spiProviderHeader);
         EasyMock.expect(implBundle.getHeaders()).andReturn(headers).anyTimes();
 
         // List the resources found at META-INF/services in the test bundle

Modified: aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml?rev=1291355&r1=1291354&r2=1291355&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml (original)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml Mon Feb 20 16:44:29 2012
@@ -107,6 +107,7 @@ JRE through META-INF/services resources)
                             org.apache.aries.spifly.dynamic
                         </Private-Package>
                         <Embed-Dependency>org.apache.aries.spifly.*;scope=compile;inline=true</Embed-Dependency>
+                        <Provide-Capability>osgi.extender;osgi.extender=spi.consumer.mediator,osgi.extender;osgi.extender=spi.provider.mediator</Provide-Capability>
                     </instructions>
                 </configuration>
             </plugin>

Modified: aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookGenericCapabilityTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookGenericCapabilityTest.java?rev=1291355&r1=1291354&r2=1291355&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookGenericCapabilityTest.java
(original)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookGenericCapabilityTest.java
Mon Feb 20 16:44:29 2012
@@ -74,7 +74,7 @@ public class ClientWeavingHookGenericCap
     @Test
     public void testBasicServiceLoaderUsage() throws Exception {
         Dictionary<String, String> consumerHeaders = new Hashtable<String, String>();
-        consumerHeaders.put(SpiFlyConstants.REQUIRE_CAPABILITY, "osgi.spi.provider; effective:=active");
+        consumerHeaders.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT);
 
         // Register the bundle that provides the SPI implementation.
         Bundle providerBundle = mockProviderBundle("impl1", 1);
@@ -116,7 +116,7 @@ public class ClientWeavingHookGenericCap
         Assert.assertSame("Precondition", cl, Thread.currentThread().getContextClassLoader());
 
         Dictionary<String, String> consumerHeaders = new Hashtable<String, String>();
-        consumerHeaders.put(SpiFlyConstants.REQUIRE_CAPABILITY, "osgi.spi.provider; effective:=active");
+        consumerHeaders.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT);
 
         // Register the bundle that provides the SPI implementation.
         Bundle providerBundle = mockProviderBundle("impl1", 1);
@@ -162,7 +162,7 @@ public class ClientWeavingHookGenericCap
         Bundle spiFlyBundle = mockSpiFlyBundle();
 
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, "osgi.spi.provider; effective:=active");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT);
         Bundle consumerBundle = mockConsumerBundle(headers, spiFlyBundle);
 
         WeavingHook wh = new ClientWeavingHook(spiFlyBundle.getBundleContext(), activator);
@@ -194,7 +194,7 @@ public class ClientWeavingHookGenericCap
         Bundle spiFlyBundle = mockSpiFlyBundle();
 
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, "osgi.spi.provider; effective:=active");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT);
 
         Bundle consumerBundle = mockConsumerBundle(headers, spiFlyBundle);
         activator.addConsumerWeavingData(consumerBundle, SpiFlyConstants.REQUIRE_CAPABILITY);
@@ -224,7 +224,8 @@ public class ClientWeavingHookGenericCap
     @Test
     public void testClientSpecifyingProvider() throws Exception {
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, "osgi.spi.provider; effective:=active;
filter:=\"(bundle-symbolic-name=impl2)\"");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT
+
+                "; " + SpiFlyConstants.PROVIDER_FILTER_DIRECTIVE + ":=\"(bundle-symbolic-name=impl2)\"");
 
         Bundle providerBundle1 = mockProviderBundle("impl1", 1);
         Bundle providerBundle2 = mockProviderBundle("impl2", 2);
@@ -253,7 +254,8 @@ public class ClientWeavingHookGenericCap
     @Test
     public void testClientSpecifyingProviderVersion() throws Exception {
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, "osgi.spi.provider; effective:=active;
filter:=\"(&(bundle-symbolic-name=impl2)(bundle-version=1.2.3))\"");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT
+
+                "; " + SpiFlyConstants.PROVIDER_FILTER_DIRECTIVE + ":=\"(&(bundle-symbolic-name=impl2)(bundle-version=1.2.3))\"");
 
         Bundle providerBundle1 = mockProviderBundle("impl1", 1);
         Bundle providerBundle2 = mockProviderBundle("impl2", 2);
@@ -283,8 +285,8 @@ public class ClientWeavingHookGenericCap
     @Test
     public void testClientMultipleTargetBundles() throws Exception {
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY,
-                "osgi.spi.provider; effective:=active; filter:=\"(|(bundle-symbolic-name=impl1)(bundle-symbolic-name=impl4))\"");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT
+
+                "; " + SpiFlyConstants.PROVIDER_FILTER_DIRECTIVE + ":=\"(|(bundle-symbolic-name=impl1)(bundle-symbolic-name=impl4))\"");
 
         Bundle providerBundle1 = mockProviderBundle("impl1", 1);
         Bundle providerBundle2 = mockProviderBundle("impl2", 2);
@@ -316,9 +318,9 @@ public class ClientWeavingHookGenericCap
     @Test
     public void testServiceFiltering() throws Exception {
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY,
-                "osgi.spi.provider; effective:=active; filter:=\"(|(service=org.apache.aries.mytest.MySPI)"
+
-                "(&(service=org.apache.aries.mytest.AltSPI)(bundle-symbolic-name=impl4)))\"");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT
+
+                "; " + SpiFlyConstants.PROVIDER_FILTER_DIRECTIVE + ":=\"(|(" + SpiFlyConstants.CONSUMED_SPI_CONDITION
+ "=org.apache.aries.mytest.MySPI)" +
+                "(&(" + SpiFlyConstants.CONSUMED_SPI_CONDITION + "=org.apache.aries.mytest.AltSPI)(bundle-symbolic-name=impl4)))\"");
 
         Bundle providerBundle1 = mockProviderBundle("impl1", 1);
         Bundle providerBundle2 = mockProviderBundle("impl2", 2);
@@ -362,9 +364,9 @@ public class ClientWeavingHookGenericCap
     @Test
     public void testServiceFilteringAlternative() throws Exception {
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY,
-                "osgi.spi.provider; effective:=active; filter:=\"(|(!(service=org.apache.aries.mytest.AltSPI))"
+
-                "(&(service=org.apache.aries.mytest.AltSPI)(bundle-symbolic-name=impl4)))\"");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT
+
+                "; " + SpiFlyConstants.PROVIDER_FILTER_DIRECTIVE + ":=\"(|(!(" + SpiFlyConstants.CONSUMED_SPI_CONDITION
+ "=org.apache.aries.mytest.AltSPI))" +
+                "(&(" + SpiFlyConstants.CONSUMED_SPI_CONDITION + "=org.apache.aries.mytest.AltSPI)(bundle-symbolic-name=impl4)))\"");
 
         Bundle providerBundle1 = mockProviderBundle("impl1", 1);
         Bundle providerBundle2 = mockProviderBundle("impl2", 2);
@@ -408,9 +410,8 @@ public class ClientWeavingHookGenericCap
     @Test
     public void testServiceFilteringNarrow() throws Exception {
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY,
-                "osgi.spi.provider; effective:=active; filter:=\"" +
-                "(&(service=org.apache.aries.mytest.AltSPI)(bundle-symbolic-name=impl4))\"");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT
+
+                "; " + SpiFlyConstants.PROVIDER_FILTER_DIRECTIVE + ":=\"(&(" + SpiFlyConstants.CONSUMED_SPI_CONDITION
+ "=org.apache.aries.mytest.AltSPI)(bundle-symbolic-name=impl4))\"");
 
         Bundle providerBundle1 = mockProviderBundle("impl1", 1);
         Bundle providerBundle2 = mockProviderBundle("impl2", 2);
@@ -454,7 +455,8 @@ public class ClientWeavingHookGenericCap
     @Test
     public void testFilteringCustomAttribute() throws Exception {
         Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, "osgi.spi.provider; effective:=active;
filter:=\"(approval=global)\"");
+        headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT
+
+                "; " + SpiFlyConstants.PROVIDER_FILTER_DIRECTIVE + ":=\"(approval=global)\"");
 
         Bundle providerBundle1 = mockProviderBundle("impl1", 1);
         Bundle providerBundle2 = mockProviderBundle("impl2", 2);

Modified: aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-client2-bundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-client2-bundle/pom.xml?rev=1291355&r1=1291354&r2=1291355&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-client2-bundle/pom.xml (original)
+++ aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-client2-bundle/pom.xml Mon Feb 20
16:44:29 2012
@@ -65,7 +65,7 @@
                             org.apache.aries.spifly.examples.client2.impl
                         </Private-Package>
                         <Bundle-Activator>org.apache.aries.spifly.examples.client2.impl.Activator</Bundle-Activator>
-                        <Require-Capability>osgi.spi.provider; effective:=active</Require-Capability>
+                        <Require-Capability>osgi.extender; osgi.extender=spi.consumer.mediator</Require-Capability>
                     </instructions>
                 </configuration>
             </plugin>

Modified: aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider2-bundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider2-bundle/pom.xml?rev=1291355&r1=1291354&r2=1291355&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider2-bundle/pom.xml (original)
+++ aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider2-bundle/pom.xml Mon Feb
20 16:44:29 2012
@@ -59,7 +59,7 @@
                         <Private-Package>
                             org.apache.aries.spifly.mysvc.impl2
                         </Private-Package>
-                        <Provide-Capability>osgi.spi.provider; effective:=active</Provide-Capability>
+                        <Require-Capability>osgi.extender; osgi.extender=spi.provider.mediator</Require-Capability>
                     </instructions>
                 </configuration>
             </plugin>



Mime
View raw message