Improved move of resolver state handling to bundle. (FELIX-851)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@737878 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
index d9303e7..80ef6fa 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
@@ -72,7 +72,9 @@
// extends BundleImpl and it doesn't have an archive.
if (m_archive != null)
{
- addModule(createModule());
+ IModule module = createModule();
+ addModule(module);
+ m_felix.getResolverState().addModule(module);
}
}
@@ -85,14 +87,14 @@
return m_felix;
}
- synchronized void refresh(FelixResolverState state) throws Exception
+ synchronized void refresh() throws Exception
{
// We are refreshing the bundle. First, we must remove all existing
// modules from the resolver state and close them. Closing the modules
// is important, since we will likely be deleting their associated files.
for (int i = 0; i < m_modules.length; i++)
{
- state.removeModule(m_modules[i]);
+ m_felix.getResolverState().removeModule(m_modules[i]);
((ModuleImpl) m_modules[i]).close();
}
@@ -104,7 +106,7 @@
m_modules = new IModule[0];
final IModule module = createModule();
addModule(module);
- state.addModule(module);
+ m_felix.getResolverState().addModule(module);
m_state = Bundle.INSTALLED;
m_stale = false;
m_cachedHeaders.clear();
@@ -890,11 +892,14 @@
return used;
}
- synchronized void revise(String location, InputStream is) throws Exception
+ synchronized void revise(String location, InputStream is)
+ throws Exception
{
// This operation will increase the revision count for the bundle.
m_archive.revise(location, is);
- addModule(createModule());
+ IModule module = createModule();
+ addModule(module);
+ m_felix.addModule(module);
}
synchronized boolean rollbackRevise() throws Exception
@@ -923,7 +928,7 @@
m_modules = dest;
}
- private synchronized IModule createModule() throws Exception
+ private IModule createModule() throws Exception
{
// Get and parse the manifest from the most recent revision to
// create an associated module for it.
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index 0c931fb..32050f4 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -315,6 +315,11 @@
return m_felixResolver;
}
+ FelixResolverState getResolverState()
+ {
+ return m_resolverState;
+ }
+
URLStreamHandler getBundleStreamHandler()
{
return m_bundleStreamHandler;
@@ -1568,9 +1573,9 @@
try
{
+// REFACTOR - This adds the module to the resolver state, but should we do the
+// security check first?
bundle.revise(updateLocation, is);
-// REFACTOR - Are we adding this to the resolver state too early?
- m_resolverState.addModule(bundle.getCurrentModule());
// Create a module for the new revision; the revision is
// base zero, so subtract one from the revision count to
@@ -2051,10 +2056,6 @@
// TODO: REFACTOR - REFRESH RESOLVER STATE.
// m_factory.refreshModule(m_sbi.getCurrentModule());
}
-
- // Get the bundle's module and add it to the resolver state.
- IModule module = bundle.getCurrentModule();
- m_resolverState.addModule(module);
}
catch (Throwable ex)
{
@@ -3099,7 +3100,7 @@
try
{
// Reset the bundle object and fire UNRESOLVED event.
- ((BundleImpl) bundle).refresh(m_resolverState);
+ ((BundleImpl) bundle).refresh();
fireBundleEvent(BundleEvent.UNRESOLVED, bundle);
}
catch (Exception ex)