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/11/24 17:01:56 UTC

svn commit: r883743 - in /incubator/aries/trunk/blueprint: blueprint-bundle/pom.xml blueprint-cm/pom.xml blueprint-core/pom.xml blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java pom.xml

Author: linsun
Date: Tue Nov 24 16:01:55 2009
New Revision: 883743

URL: http://svn.apache.org/viewvc?rev=883743&view=rev
Log:
ARIES-7 Use BundleTracker from OSGi 4.2

Modified:
    incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml
    incubator/aries/trunk/blueprint/blueprint-cm/pom.xml
    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/pom.xml

Modified: incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml?rev=883743&r1=883742&r2=883743&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml Tue Nov 24 16:01:55 2009
@@ -50,10 +50,11 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.felix</groupId>
+            <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
             <scope>provided</scope>
         </dependency>
+
     </dependencies>
 
     <build>

Modified: incubator/aries/trunk/blueprint/blueprint-cm/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-cm/pom.xml?rev=883743&r1=883742&r2=883743&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-cm/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-cm/pom.xml Tue Nov 24 16:01:55 2009
@@ -37,12 +37,12 @@
           <artifactId>aries-blueprint-core</artifactId>
       </dependency>
       <dependency>
-          <groupId>org.eclipse</groupId>
-          <artifactId>osgi</artifactId>
+          <groupId>org.osgi</groupId>
+          <artifactId>org.osgi.core</artifactId>
           <scope>provided</scope>
       </dependency>
       <dependency>
-          <groupId>org.apache.felix</groupId>
+          <groupId>org.osgi</groupId>
           <artifactId>org.osgi.compendium</artifactId>
           <scope>provided</scope>
       </dependency>

Modified: incubator/aries/trunk/blueprint/blueprint-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/pom.xml?rev=883743&r1=883742&r2=883743&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-core/pom.xml Tue Nov 24 16:01:55 2009
@@ -38,12 +38,12 @@
           <artifactId>aries-blueprint-api</artifactId>
       </dependency>
       <dependency>
-          <groupId>org.apache.felix</groupId>
+          <groupId>org.osgi</groupId>
           <artifactId>org.osgi.core</artifactId>
           <scope>provided</scope>
       </dependency>
       <dependency>
-          <groupId>org.apache.felix</groupId>
+          <groupId>org.osgi</groupId>
           <artifactId>org.osgi.compendium</artifactId>
           <scope>provided</scope>
       </dependency>

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=883743&r1=883742&r2=883743&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 Tue Nov 24 16:01:55 2009
@@ -44,11 +44,14 @@
 import org.osgi.framework.SynchronousBundleListener;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.container.BlueprintEvent;
+import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * TODO: javadoc
+ * This is the blueprint extender that listens to blueprint bundles.  it implements the sync
+ * bundle listener but it doesn't register the listener and uses the bundle tracker instead.
  *
  * @version $Rev: 760378 $, $Date: 2009-03-31 11:31:38 +0200 (Tue, 31 Mar 2009) $
  */
@@ -61,6 +64,7 @@
     private Map<Bundle, BlueprintContainerImpl> containers;
     private BlueprintEventDispatcher eventDispatcher;
     private NamespaceHandlerRegistry handlers;
+    private BundleTracker bt;
 
     public void start(BundleContext context) {
         LOGGER.debug("Starting blueprint extender...");
@@ -71,8 +75,10 @@
         eventDispatcher = new BlueprintEventDispatcher(context, executors);
         containers = new HashMap<Bundle, BlueprintContainerImpl>();
 
-        context.addBundleListener(this);
-
+        // TODO: allow aries consumer to plugin their own bundletracker customizer.
+        bt = new BundleTracker(context, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, new BlueprintBundleTrackerCustomizer());
+        bt.open();
+        
         Bundle[] bundles = context.getBundles();
         for (Bundle b : bundles) {
             // If the bundle is active, check it
@@ -92,7 +98,10 @@
 
     public void stop(BundleContext context) {
         LOGGER.debug("Stopping blueprint extender...");
-        context.removeBundleListener(this);
+        if (bt != null) {
+        	bt.close();
+        }
+
         // Orderly shutdown of containers
         while (!containers.isEmpty()) {
             for (Bundle bundle : getBundlesToDestroy()) {
@@ -305,4 +314,38 @@
             }
         }
     }
+    
+    // blueprint bundle tracker calls bundleChanged to minimize changes.
+    private class BlueprintBundleTrackerCustomizer implements BundleTrackerCustomizer {
+
+        public BlueprintBundleTrackerCustomizer() {
+        }
+        
+        public Object addingBundle(Bundle b, BundleEvent event)
+        {
+          if (event == null) {
+            return null;
+          }
+          
+          bundleChanged(event);
+          
+          return b;
+        }
+
+        public void modifiedBundle(Bundle b, BundleEvent event, Object arg2)
+        {          
+            if (event == null) {
+                return;
+            }
+        
+            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/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/pom.xml?rev=883743&r1=883742&r2=883743&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/pom.xml (original)
+++ incubator/aries/trunk/blueprint/pom.xml Tue Nov 24 16:01:55 2009
@@ -88,34 +88,14 @@
                 <version>${version}</version>
             </dependency>
             <dependency>
-                <groupId>org.apache.felix</groupId>
+                <groupId>org.osgi</groupId>
                 <artifactId>org.osgi.core</artifactId>
-                <version>1.4.0</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>org.apache.felix</groupId>
-                        <artifactId>org.osgi.foundation</artifactId>
-                    </exclusion>
-                </exclusions>
+                <version>4.2.0</version>
             </dependency>
             <dependency>
-                <groupId>org.apache.felix</groupId>
+                <groupId>org.osgi</groupId>
                 <artifactId>org.osgi.compendium</artifactId>
-                <version>1.2.0</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>org.apache.felix</groupId>
-                        <artifactId>org.osgi.core</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>org.apache.felix</groupId>
-                        <artifactId>org.osgi.foundation</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>org.apache.felix</groupId>
-                        <artifactId>javax.servlet</artifactId>
-                    </exclusion>
-                </exclusions>
+                <version>4.2.0</version>
             </dependency>
             <dependency>
                 <groupId>junit</groupId>