sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1430740 - in /sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util: OSGiActivator.java SystemListener.java
Date Wed, 09 Jan 2013 09:13:51 GMT
Author: desruisseaux
Date: Wed Jan  9 09:13:50 2013
New Revision: 1430740

URL: http://svn.apache.org/viewvc?rev=1430740&view=rev
Log:
Be notified with the classpath changed in an OSGi context.

Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SystemListener.java

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java?rev=1430740&r1=1430739&r2=1430740&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java
Wed Jan  9 09:13:50 2013
@@ -19,6 +19,8 @@ package org.apache.sis.internal.util;
 import javax.management.JMException;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
 
 
 /**
@@ -30,7 +32,7 @@ import org.osgi.framework.BundleActivato
  * @version 0.3
  * @module
  */
-public final class OSGiActivator implements BundleActivator {
+public final class OSGiActivator implements BundleActivator, BundleListener {
     /**
      * Creates a new bundle activator.
      */
@@ -44,6 +46,7 @@ public final class OSGiActivator impleme
      */
     @Override
     public void start(final BundleContext context) {
+        context.addBundleListener(this);
     }
 
     /**
@@ -55,6 +58,23 @@ public final class OSGiActivator impleme
      */
     @Override
     public void stop(final BundleContext context) throws JMException {
+        context.removeBundleListener(this);
         Shutdown.stop(getClass());
     }
+
+    /**
+     * Invoked when an other module has been installed or un-installed.
+     * This method notifies the Apache SIS library that the classpath may have changed.
+     *
+     * @param event The event that describe the life-cycle change.
+     */
+    @Override
+    public void bundleChanged(final BundleEvent event) {
+        switch (event.getType()) {
+            case BundleEvent.STARTED:
+            case BundleEvent.STOPPED: {
+                SystemListener.fireClasspathChanged();
+            }
+        }
+    }
 }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SystemListener.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SystemListener.java?rev=1430740&r1=1430739&r2=1430740&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SystemListener.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SystemListener.java
Wed Jan  9 09:13:50 2013
@@ -63,6 +63,10 @@ public abstract class SystemListener imp
      * a paranoiac check.`
      *
      * @param listener The listener to remove.
+     *
+     * @todo Not yet used. Given that the intend of this method is to remove all listeners
+     *       registered by a specific module, a possible approach would be to remove all
+     *       listeners associated to that through some module identifier.
      */
     public static synchronized void remove(final SystemListener listener) {
         SystemListener[] list = listeners;



Mime
View raw message