Add support to notify module listeners that the definition of a module has been modified - this is an experimental feature to make extension bundle exports work again (FELIX-30).
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@576159 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java b/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java
index 701def4..657c73b 100644
--- a/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java
+++ b/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -32,4 +32,13 @@
public void removeModuleListener(ModuleListener l);
public void setSecurityContext(IModule module, Object securityContext);
+
+ /**
+ * This is an experimental method that is likely to change or go
+ * away - so don't use it for now.
+ *
+ * Note to self, we need to think about what the implications of
+ * this are and whether we are fine with them.
+ */
+ public void refreshModule(IModule currentModule);
}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java b/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java
index 62c4902..4487aa2 100644
--- a/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java
+++ b/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -72,6 +72,28 @@
return module;
}
+ /**
+ * This is an experimental method that is likely to change or go
+ * away - so don't use it for now.
+ *
+ * Note to self, we need to think about what the implications of
+ * this are and whether we are fine with them.
+ */
+ public void refreshModule(IModule module)
+ {
+ boolean fire = false;
+
+ synchronized (this)
+ {
+ fire = (m_moduleMap.get(module.getId()) != null);
+ }
+
+ if (fire)
+ {
+ fireModuleRefreshed(module);
+ }
+ }
+
public void removeModule(IModule module)
{
// Use a synchronized block instead of synchronizing the
@@ -269,4 +291,32 @@
listeners[i].moduleRemoved(event);
}
}
+
+ /**
+ * This is an experimental method that is likely to change or go
+ * away - so don't use it for now.
+ *
+ * Note to self, we need to think about what the implications of
+ * this are and whether we are fine with them.
+ */
+ protected void fireModuleRefreshed(IModule module)
+ {
+ // Event holder.
+ ModuleEvent event = null;
+
+ // Get a copy of the listener array, which is guaranteed
+ // to not be null.
+ ModuleListener[] listeners = m_listeners;
+
+ // Loop through listeners and fire events.
+ for (int i = 0; i < listeners.length; i++)
+ {
+ // Lazily create event.
+ if (event == null)
+ {
+ event = new ModuleEvent(this, module);
+ }
+ listeners[i].moduleRefreshed(event);
+ }
+ }
}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java b/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java
index e3a8cea..775787d 100644
--- a/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java
+++ b/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -48,4 +48,13 @@
* @param event the event object containing the event details.
**/
public void moduleRemoved(ModuleEvent event);
+
+ /**
+ * This is an experimental method that is likely to change or go
+ * away - so don't use it for now.
+ *
+ * Note to self, we need to think about what the implications of
+ * this are and whether we are fine with them.
+ */
+ public void moduleRefreshed(ModuleEvent event);
}
\ No newline at end of file