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/03 03:35:07 UTC
svn commit: r886659 - in /incubator/aries/trunk/blueprint:
blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java
Author: linsun
Date: Thu Dec 3 02:35:05 2009
New Revision: 886659
URL: http://svn.apache.org/viewvc?rev=886659&view=rev
Log:
ARIES-64 leverage bundle tracker to process the initial bundles
Modified:
incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java
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=886659&r1=886658&r2=886659&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 Thu Dec 3 02:35:05 2009
@@ -85,42 +85,30 @@
bt = new BundleTracker(context, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, new BlueprintMutilBundleTrackerCustomizer());
}
bt.open();
-
- Bundle[] bundles = context.getBundles();
- checkAllBundles(bundles, sr);
LOGGER.debug("Blueprint extender started");
}
-
/**
- * this method check all bundles. if the sr is null, then we only check
- * bundles within the current bundle context where this bundle resides.
- * if sr is not null, then we also check the bundles inside the child frameworks
- * that are associated with composite bundles
- * @param bundles bundles to be checked
- * @param sr Service reference for the composite bundle factory service
+ * this method checks the initial bundle that are installed/active before
+ * bundle tracker is opened.
*/
- private void checkAllBundles(Bundle[] bundles, ServiceReference sr) {
- for (Bundle b : bundles) {
- if (sr != null && (b instanceof CompositeBundle)) {
- // let's check bundles associated with the composite bundle
- CompositeBundle cb = (CompositeBundle)b;
- Bundle[] buns = cb.getCompositeFramework().getBundleContext().getBundles();
- checkAllBundles(buns, sr);
- } else {
- // If the bundle is active, check it
- if (b.getState() == Bundle.ACTIVE) {
- checkBundle(b);
- // Also check bundles in the starting state with a lazy activation policy
- } else if (b.getState() == Bundle.STARTING) {
- String activationPolicyHeader = (String) b.getHeaders().get(Constants.BUNDLE_ACTIVATIONPOLICY);
- if (activationPolicyHeader != null && activationPolicyHeader.startsWith(Constants.ACTIVATION_LAZY)) {
- checkBundle(b);
- }
- }
+ private void checkInitialBundle(Bundle b) {
+ // If the bundle is active, check it
+ if (b.getState() == Bundle.ACTIVE) {
+ checkBundle(b);
+ // Also check bundles in the starting state with a lazy activation
+ // policy
+ } else if (b.getState() == Bundle.STARTING) {
+ String activationPolicyHeader = (String) b.getHeaders().get(
+ Constants.BUNDLE_ACTIVATIONPOLICY);
+ if (activationPolicyHeader != null
+ && activationPolicyHeader
+ .startsWith(Constants.ACTIVATION_LAZY)) {
+ checkBundle(b);
}
}
+
}
public void stop(BundleContext context) {
@@ -351,16 +339,18 @@
public Object addingBundle(Bundle b, BundleEvent event) {
if (event == null) {
- return null;
+ // existing bundles first added to the tracker with no event change
+ checkInitialBundle(b);
+ } else {
+ bundleChanged(event);
}
- bundleChanged(event);
-
return b;
}
public void modifiedBundle(Bundle b, BundleEvent event, Object arg2) {
if (event == null) {
+ // cannot think of why we would be interested in a modified bundle with no bundle event
return;
}
@@ -387,22 +377,26 @@
super.addingBundle(b, event);
if (event == null) {
- return null;
+ // existing bundles first added to the tracker with no event change
+ checkInitialBundle(b);
+ } else {
+ bundleChanged(event);
}
-
- bundleChanged(event);
return b;
}
public void modifiedBundle(Bundle b, BundleEvent event, Object arg2) {
+
+ super.modifiedBundle(b, event, arg2);
+
if (event == null) {
+ // cannot think of why we would be interested in a modified bundle with no bundle event
return;
+ } else {
+ bundleChanged(event);
}
- super.modifiedBundle(b, event, arg2);
- bundleChanged(event);
-
}
// don't think we would be interested in removedBundle, as that is
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=886659&r1=886658&r2=886659&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 Thu Dec 3 02:35:05 2009
@@ -84,7 +84,7 @@
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"),
-// org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+ // org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
equinox().version("3.5.0")
);