incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1367962 - in /sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl: LaunchpadListener.java ServicesListener.java
Date Wed, 01 Aug 2012 12:39:41 GMT
Author: cziegeler
Date: Wed Aug  1 12:39:41 2012
New Revision: 1367962

URL: http://svn.apache.org/viewvc?rev=1367962&view=rev
Log:
SLING-2552 : Correctly handle register/unregister of OSGi installer

Modified:
    sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadListener.java
    sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/ServicesListener.java

Modified: sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadListener.java?rev=1367962&r1=1367961&r2=1367962&view=diff
==============================================================================
--- sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadListener.java
(original)
+++ sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadListener.java
Wed Aug  1 12:39:41 2012
@@ -35,12 +35,29 @@ public class LaunchpadListener implement
      */
     public void onEvent(final InstallationEvent event) {
         if ( event.getType() == InstallationEvent.TYPE.STARTED ) {
+            this.start();
+        } else if ( event.getType() == InstallationEvent.TYPE.SUSPENDED ) {
+            this.stop();
+        }
+    }
+
+    /**
+     * Suspend the startup handler (if not already done so)
+     */
+    public void start() {
+        if ( !started ) {
             this.startupHandler.waitWithStartup(true);
             started = true;
-        } else if ( event.getType() == InstallationEvent.TYPE.SUSPENDED ) {
-            if ( started ) {
-                this.startupHandler.waitWithStartup(false);
-            }
+        }
+    }
+
+    /**
+     * Make sure the startup handler is not in suspended state
+     */
+    public void stop() {
+        if ( started ) {
+            this.startupHandler.waitWithStartup(false);
+            started = false;
         }
     }
 

Modified: sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/ServicesListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/ServicesListener.java?rev=1367962&r1=1367961&r2=1367962&view=diff
==============================================================================
--- sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/ServicesListener.java
(original)
+++ sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/ServicesListener.java
Wed Aug  1 12:39:41 2012
@@ -57,6 +57,8 @@ public class ServicesListener {
     /** Boolean marker to not reprocess things. */
     private volatile boolean installed = false;
 
+    private LaunchpadListener launchpadListener;
+
     /**
      * Start listeners
      */
@@ -84,7 +86,7 @@ public class ServicesListener {
         if ( installer != null && lcp != null && handler != null ) {
             if ( !this.installed ) {
                 this.installed = true;
-                final LaunchpadListener launchpadListener = new LaunchpadListener(handler);
+                this.launchpadListener = new LaunchpadListener(handler);
                 final Dictionary<String, Object> props = new Hashtable<String, Object>();
                 props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Launchpad Startup
Listener");
                 props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
@@ -102,9 +104,11 @@ public class ServicesListener {
         this.providerListener.deactivate();
         this.startupListener.deactivate();
         if ( this.launchpadListenerReg != null ) {
+            this.launchpadListener.stop();
             this.launchpadListenerReg.unregister();
             this.launchpadListenerReg = null;
         }
+        this.launchpadListener = null;
     }
 
     /**



Mime
View raw message