Return-Path: Delivered-To: apmail-incubator-aries-commits-archive@minotaur.apache.org Received: (qmail 89683 invoked from network); 23 Dec 2010 14:22:47 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 23 Dec 2010 14:22:47 -0000 Received: (qmail 92877 invoked by uid 500); 23 Dec 2010 14:22:46 -0000 Delivered-To: apmail-incubator-aries-commits-archive@incubator.apache.org Received: (qmail 92789 invoked by uid 500); 23 Dec 2010 14:22:46 -0000 Mailing-List: contact aries-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: aries-dev@incubator.apache.org Delivered-To: mailing list aries-commits@incubator.apache.org Received: (qmail 92774 invoked by uid 99); 23 Dec 2010 14:22:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Dec 2010 14:22:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Dec 2010 14:22:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 79CCD23888E4; Thu, 23 Dec 2010 14:22:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1052277 - in /incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook: SpiFly/src/org/apache/aries/spifly/ SpiFlyTests/src/org/apache/aries/spifly/ SpiFlyTests/src/org/apache/aries/spifly/impl2_123/ SpiFlyTests/src/org/apache/aries/s... Date: Thu, 23 Dec 2010 14:22:19 -0000 To: aries-commits@incubator.apache.org From: davidb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101223142219.79CCD23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davidb Date: Thu Dec 23 14:22:18 2010 New Revision: 1052277 URL: http://svn.apache.org/viewvc?rev=1052277&view=rev Log: Add bundle version support. Added: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/META-INF/ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/META-INF/services/ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/MySPIImpl2B.java Modified: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/ClientWeavingHook.java incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/Pair.java incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/ClientWeavingHookTest.java Modified: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/ClientWeavingHook.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/ClientWeavingHook.java?rev=1052277&r1=1052276&r2=1052277&view=diff ============================================================================== --- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/ClientWeavingHook.java (original) +++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/ClientWeavingHook.java Thu Dec 23 14:22:18 2010 @@ -30,6 +30,7 @@ import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import org.osgi.framework.Version; import org.osgi.framework.hooks.weaving.WeavingHook; import org.osgi.framework.hooks.weaving.WovenClass; import org.osgi.service.log.LogService; @@ -82,9 +83,12 @@ public class ClientWeavingHook implement * * The following attributes are supported: *
    - *
  • bundle - restrict wiring to the bundle with the specifies Symbolic Name. + *
  • bundle - restrict wiring to the bundle with the specifies Symbolic Name. The attribute value + * is a list of bundle identifiers separated by a '|' sign. The bundle identifier starts with the Symbolic name + * and can optionally contain a version suffix. E.g. bundle=impl2:version=1.2.3 or bundle=impl2|impl4. *
  • bundleId - restrict wiring to the bundle with the specified bundle ID. Typically used when - * the service should be forceably picked up from the system bundle (bundleId=0). + * the service should be forceably picked up from the system bundle (bundleId=0). Multiple bundle IDs + * can be specified separated by a '|' sign. *
* * @param consumerBundle the consuming bundle. @@ -161,13 +165,23 @@ public class ClientWeavingHook implement bsn = bsn.trim(); if (bsn.length() > 0) { for (String s : bsn.split("\\|")) { - allowedBundles.add(new BundleDescriptor(s)); + int colonIdx = s.indexOf(':'); + if (colonIdx > 0) { + String sn = s.substring(0, colonIdx); + String versionSfx = s.substring(colonIdx + 1); + if (versionSfx.startsWith("version=")) { + allowedBundles.add(new BundleDescriptor(sn, + Version.parseVersion(versionSfx.substring("version=".length())))); + } else { + allowedBundles.add(new BundleDescriptor(sn)); + } + } else { + allowedBundles.add(new BundleDescriptor(s)); + } } } } - - // TODO bundle version - + String bid = element.getAttribute("bundleId"); if (bid != null) { bid = bid.trim(); Modified: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/Pair.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/Pair.java?rev=1052277&r1=1052276&r2=1052277&view=diff ============================================================================== --- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/Pair.java (original) +++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFly/src/org/apache/aries/spifly/Pair.java Thu Dec 23 14:22:18 2010 @@ -54,7 +54,7 @@ public class Pair { if (getClass() != obj.getClass()) return false; - Pair other = (Pair) obj; + Pair other = (Pair) obj; if (left == null) { if (other.left != null) return false; Modified: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/ClientWeavingHookTest.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/ClientWeavingHookTest.java?rev=1052277&r1=1052276&r2=1052277&view=diff ============================================================================== --- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/ClientWeavingHookTest.java (original) +++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/ClientWeavingHookTest.java Thu Dec 23 14:22:18 2010 @@ -186,11 +186,11 @@ public class ClientWeavingHookTest { @Test public void testClientSpecifyingProviderVersion() throws Exception { Dictionary headers = new Hashtable(); - headers.put(SpiFlyConstants.SPI_CONSUMER_HEADER, "java.util.ServiceLoader#load(java.lang.Class);bundle=impl2;version=1.2.3"); + headers.put(SpiFlyConstants.SPI_CONSUMER_HEADER, "java.util.ServiceLoader#load(java.lang.Class);bundle=impl2:version=1.2.3"); Bundle providerBundle1 = mockProviderBundle("impl1", 1); Bundle providerBundle2 = mockProviderBundle("impl2", 2); - Bundle providerBundle3 = mockProviderBundle("impl2", 3, new Version(1, 2, 3)); + Bundle providerBundle3 = mockProviderBundle("impl2_123", 3, new Version(1, 2, 3)); Activator.activator.registerProviderBundle("org.apache.aries.mytest.MySPI", providerBundle1); Activator.activator.registerProviderBundle("org.apache.aries.mytest.MySPI", providerBundle2); Activator.activator.registerProviderBundle("org.apache.aries.mytest.MySPI", providerBundle3); @@ -209,7 +209,7 @@ public class ClientWeavingHookTest { Class cls = wc.getDefinedClass(); Method method = cls.getMethod("test", new Class [] {String.class}); Object result = method.invoke(cls.newInstance(), "hello"); - Assert.assertEquals("Only the services from bundle impl2 should be selected", "Updated!Hello!Updated", result); + Assert.assertEquals("Only the services from bundle impl2 should be selected", "Updated!hello!Updated", result); } @Test @@ -532,7 +532,12 @@ public class ClientWeavingHookTest { Bundle providerBundle = EasyMock.createMock(Bundle.class); EasyMock.expect(providerBundle.adapt(BundleWiring.class)).andReturn(bw).anyTimes(); - EasyMock.expect(providerBundle.getSymbolicName()).andReturn(subdir).anyTimes(); + String bsn = subdir; + int idx = bsn.indexOf('_'); + if (idx > 0) { + bsn = bsn.substring(0, idx); + } + EasyMock.expect(providerBundle.getSymbolicName()).andReturn(bsn).anyTimes(); EasyMock.expect(providerBundle.getBundleId()).andReturn(id).anyTimes(); EasyMock.expect(providerBundle.getVersion()).andReturn(version).anyTimes(); EasyMock.replay(providerBundle); Added: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI?rev=1052277&view=auto ============================================================================== --- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI (added) +++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI Thu Dec 23 14:22:18 2010 @@ -0,0 +1 @@ +org.apache.aries.spifly.impl2_123.MySPIImpl2B \ No newline at end of file Added: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/MySPIImpl2B.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/MySPIImpl2B.java?rev=1052277&view=auto ============================================================================== --- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/MySPIImpl2B.java (added) +++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/SpiFlyTests/src/org/apache/aries/spifly/impl2_123/MySPIImpl2B.java Thu Dec 23 14:22:18 2010 @@ -0,0 +1,28 @@ +/** + * 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.aries.spifly.impl2_123; + +import org.apache.aries.mytest.MySPI; + +public class MySPIImpl2B implements MySPI { + @Override + public String someMethod(String s) { + return "Updated!" + s + "!Updated"; + } +}