You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by li...@apache.org on 2009/12/02 16:46:55 UTC
svn commit: r886180 - in /incubator/aries/trunk/blueprint: ./ blueprint-core/
blueprint-core/src/main/java/org/apache/aries/blueprint/container/
blueprint-itests/
blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/
Author: linsun
Date: Wed Dec 2 15:46:53 2009
New Revision: 886180
URL: http://svn.apache.org/viewvc?rev=886180&view=rev
Log:
ARIES-51 Allow to use different blueprint bundle tracker customizer based on different osgi framework + itest for this feature
Modified:
incubator/aries/trunk/blueprint/blueprint-core/pom.xml
incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
incubator/aries/trunk/blueprint/blueprint-itests/pom.xml
incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java
incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java
incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestConfigAdmin.java
incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestReferences.java
incubator/aries/trunk/blueprint/pom.xml
Modified: incubator/aries/trunk/blueprint/blueprint-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/pom.xml?rev=886180&r1=886179&r2=886180&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-core/pom.xml Wed Dec 2 15:46:53 2009
@@ -38,6 +38,10 @@
<artifactId>org.apache.aries.blueprint.api</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
@@ -88,7 +92,7 @@
<Export-Package>
org.apache.aries.blueprint*;version="${pom.version}"
</Export-Package>
- <Import-Package>!org.apache.aries.blueprint*,*</Import-Package>
+ <Import-Package>!org.apache.aries.blueprint*,org.apache.aries.util.tracker;resolution:=optional,*</Import-Package>
<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
<_removeheaders>Ignore-Package,Include-Resource,Private-Package,Bundle-DocURL</_removeheaders>
</instructions>
Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java?rev=886180&r1=886179&r2=886180&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java (original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java Wed Dec 2 15:46:53 2009
@@ -35,6 +35,7 @@
import org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl;
import org.apache.aries.blueprint.utils.HeaderParser;
import org.apache.aries.blueprint.utils.HeaderParser.PathElement;
+import org.apache.aries.util.tracker.AriesBundleTrackerCustomizer;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -75,8 +76,13 @@
eventDispatcher = new BlueprintEventDispatcher(context, executors);
containers = new HashMap<Bundle, BlueprintContainerImpl>();
- // TODO: allow aries consumer to plugin their own bundletracker customizer.
- bt = new BundleTracker(context, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, new BlueprintBundleTrackerCustomizer());
+ ServiceReference sr = this.context.getServiceReference("org.osgi.service.framework.CompositeBundleFactory");
+ if (sr == null) {
+ bt = new BundleTracker(context, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, new BlueprintBundleTrackerCustomizer());
+ } else {
+ // composite bundle factory service is active, let's track blueprint bundles installed in the child frameworks too.
+ bt = new BundleTracker(context, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, new BlueprintMutilBundleTrackerCustomizer());
+ }
bt.open();
Bundle[] bundles = context.getBundles();
@@ -346,4 +352,40 @@
public void removedBundle(Bundle b, BundleEvent event, Object arg2) {
}
}
+
+ // blueprint bundle tracker calls bundleChanged to minimize changes.
+ // this bundle tracker customizer handles bundles installed in the child framework as well
+ private class BlueprintMutilBundleTrackerCustomizer extends
+ AriesBundleTrackerCustomizer {
+
+ public BlueprintMutilBundleTrackerCustomizer() {
+ }
+
+ public Object addingBundle(Bundle b, BundleEvent event) {
+
+ if (event == null) {
+ return null;
+ }
+
+ super.addingBundle(b, event);
+ bundleChanged(event);
+
+ return b;
+ }
+
+ public void modifiedBundle(Bundle b, BundleEvent event, Object arg2) {
+ if (event == null) {
+ return;
+ }
+
+ super.modifiedBundle(b, event, arg2);
+ bundleChanged(event);
+
+ }
+
+ // don't think we would be interested in removedBundle, as that is
+ // called when bundle is removed from the tracker
+ public void removedBundle(Bundle b, BundleEvent event, Object arg2) {
+ }
+ }
}
Modified: incubator/aries/trunk/blueprint/blueprint-itests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-itests/pom.xml?rev=886180&r1=886179&r2=886180&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-itests/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-itests/pom.xml Wed Dec 2 15:46:53 2009
@@ -32,12 +32,32 @@
</description>
<dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>org.apache.aries.blueprint</artifactId>
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>org.apache.aries.blueprint.sample</artifactId>
<scope>test</scope>
@@ -96,16 +116,7 @@
<artifactId>org.apache.felix.main</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.eclipse</groupId>
- <artifactId>osgi</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>test</scope>
- </dependency>
+
</dependencies>
<build>
Modified: incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java?rev=886180&r1=886179&r2=886180&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java (original)
+++ incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java Wed Dec 2 15:46:53 2009
@@ -48,6 +48,10 @@
protected BlueprintContainer getBlueprintContainerForBundle(String symbolicName, long timeout) throws Exception {
return getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=" + symbolicName + ")", timeout);
}
+
+ protected BlueprintContainer getBlueprintContainerForBundle(BundleContext bc, String symbolicName, long timeout) throws Exception {
+ return getOsgiService(bc, BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=" + symbolicName + ")", timeout);
+ }
protected <T> T getOsgiService(Class<T> type, long timeout) {
return getOsgiService(type, null, timeout);
@@ -56,8 +60,8 @@
protected <T> T getOsgiService(Class<T> type) {
return getOsgiService(type, null, DEFAULT_TIMEOUT);
}
-
- protected <T> T getOsgiService(Class<T> type, String filter, long timeout) {
+
+ protected <T> T getOsgiService(BundleContext bc, Class<T> type, String filter, long timeout) {
ServiceTracker tracker = null;
try {
String flt;
@@ -71,7 +75,7 @@
flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
}
Filter osgiFilter = FrameworkUtil.createFilter(flt);
- tracker = new ServiceTracker(bundleContext, osgiFilter, null);
+ tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter, null);
tracker.open();
// Note that the tracker is not closed to keep the reference
// This is buggy, has the service reference may change i think
@@ -86,9 +90,14 @@
throw new RuntimeException(e);
}
}
+
+ protected <T> T getOsgiService(Class<T> type, String filter, long timeout) {
+ return getOsgiService(null, type, filter, timeout);
+ }
protected Bundle installBundle(String groupId, String artifactId) throws Exception {
MavenArtifactProvisionOption mvnUrl = mavenBundle(groupId, artifactId);
+ System.out.println("***linsun: mvnUrl.getURL() " + mvnUrl.getURL());
return bundleContext.installBundle(mvnUrl.getURL());
}
Modified: incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java?rev=886180&r1=886179&r2=886180&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java (original)
+++ incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java Wed Dec 2 15:46:53 2009
@@ -18,29 +18,25 @@
*/
package org.apache.aries.blueprint.itests;
-import java.text.SimpleDateFormat;
-import java.util.Currency;
-import java.util.Hashtable;
-
-import org.apache.aries.blueprint.sample.Bar;
-import org.apache.aries.blueprint.sample.Foo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.junit.Assert.assertNull;
-import org.junit.Test;
-import org.junit.runner.RunWith;
import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.mavenConfiguration;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.customFramework;
+
+import java.text.SimpleDateFormat;
+import java.util.Currency;
+import java.util.Hashtable;
+
+import org.apache.aries.blueprint.sample.Bar;
+import org.apache.aries.blueprint.sample.Foo;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.profile;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.rawPaxRunnerOption;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.Bundle;
import org.osgi.service.blueprint.container.BlueprintContainer;
@@ -125,6 +121,7 @@
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
// Bundles
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample").noStart(),
mavenBundle("org.osgi", "org.osgi.compendium"),
Modified: incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestConfigAdmin.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestConfigAdmin.java?rev=886180&r1=886179&r2=886180&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestConfigAdmin.java (original)
+++ incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestConfigAdmin.java Wed Dec 2 15:46:53 2009
@@ -18,23 +18,19 @@
*/
package org.apache.aries.blueprint.itests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
import java.util.Currency;
import java.util.Hashtable;
import org.apache.aries.blueprint.sample.Foo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.mavenConfiguration;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.customFramework;
import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.OptionUtils;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.Bundle;
import org.osgi.service.blueprint.container.BlueprintContainer;
@@ -182,6 +178,7 @@
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
// Bundles
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample").noStart(),
mavenBundle("org.osgi","org.osgi.compendium"),
Modified: incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestReferences.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestReferences.java?rev=886180&r1=886179&r2=886180&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestReferences.java (original)
+++ incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestReferences.java Wed Dec 2 15:46:53 2009
@@ -18,27 +18,23 @@
*/
package org.apache.aries.blueprint.itests;
-import java.util.Hashtable;
-import java.util.List;
-
-import org.apache.aries.blueprint.sample.BindingListener;
-import org.apache.aries.blueprint.sample.InterfaceA;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.mavenConfiguration;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.customFramework;
+
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.aries.blueprint.sample.BindingListener;
+import org.apache.aries.blueprint.sample.InterfaceA;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.profile;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.rawPaxRunnerOption;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
@@ -144,6 +140,7 @@
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
// Bundles
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample"),
mavenBundle("org.osgi", "org.osgi.compendium"),
Modified: incubator/aries/trunk/blueprint/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/pom.xml?rev=886180&r1=886179&r2=886180&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/pom.xml (original)
+++ incubator/aries/trunk/blueprint/pom.xml Wed Dec 2 15:46:53 2009
@@ -88,6 +88,11 @@
<version>${version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>