felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r736339 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: BundleImpl.java BundleProtectionDomain.java ExtensionManager.java Felix.java searchpolicy/ModuleImpl.java
Date Wed, 21 Jan 2009 16:55:18 GMT
Author: rickhall
Date: Wed Jan 21 08:55:17 2009
New Revision: 736339

URL: http://svn.apache.org/viewvc?rev=736339&view=rev
Log:
More refactoring. (FELIX-851)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=736339&r1=736338&r2=736339&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java Wed Jan
21 08:55:17 2009
@@ -34,7 +34,7 @@
 
 class BundleImpl implements Bundle
 {
-    private final Felix m_feli;
+    private final Felix m_felix;
 
     private final BundleArchive m_archive;
     private IModule[] m_modules = new IModule[0];
@@ -62,30 +62,30 @@
 
     BundleImpl(Felix felix, BundleArchive archive) throws Exception
     {
-        m_feli = felix;
+        m_felix = felix;
         m_archive = archive;
         m_state = Bundle.INSTALLED;
         m_stale = false;
         m_activator = null;
         m_context = null;
 
-        // TODO: REFACTOR - Null check is a hHack due to system bundle.
+        // TODO: REFACTOR - Null check is a hack due to system bundle.
         if (m_archive != null)
         {
-            createAndAddModule();
+            addModule(createModule());
         }
     }
 
     // TODO: REFACTOR - We need this method so the system bundle can override it.
     Felix getFramework()
     {
-        return m_feli;
+        return m_felix;
     }
 
-    void reset() throws Exception
+    synchronized void reset() throws Exception
     {
         m_modules = new IModule[0];
-        createAndAddModule();
+        addModule(createModule());
         m_state = Bundle.INSTALLED;
         m_stale = false;
         m_cachedHeaders.clear();
@@ -93,15 +93,6 @@
         m_removalPending = false;
     }
 
-    // TODO: REFACTOR - This method is sort of a hack. Since the system bundle
-    //       doesn't have an archive, it can override this method to return its
-    //       manifest.
-    Map getCurrentManifestFromArchive() throws Exception
-    {
-        return m_archive.getRevision(
-            m_archive.getRevisionCount() - 1).getManifestHeader();
-    }
-
     synchronized BundleActivator getActivator()
     {
         return m_activator;
@@ -884,7 +875,7 @@
     {
         // This operation will increase the revision count for the bundle.
         m_archive.revise(location, is);
-        createAndAddModule();
+        addModule(createModule());
     }
 
     synchronized boolean rollbackRevise() throws Exception
@@ -892,7 +883,7 @@
         return m_archive.rollbackRevise();
     }
 
-    // TODO: REFACTOR - Hack for the system bundle.
+    // TODO: REFACTOR - This module is only visible for the system bundle.
     synchronized void addModule(IModule module)
     {
         ((ModuleImpl) module).setBundle(this);
@@ -903,11 +894,12 @@
         m_modules = dest;
     }
 
-    synchronized void createAndAddModule() throws Exception
+    private synchronized IModule createModule() throws Exception
     {
         // Get and parse the manifest from the most recent revision to
         // create an associated module for it.
-        Map headerMap = getCurrentManifestFromArchive();
+        Map headerMap = m_archive.getRevision(
+            m_archive.getRevisionCount() - 1).getManifestHeader();
         ManifestParser mp = new ManifestParser(
             getFramework().getLogger(), getFramework().getConfig(), headerMap);
 
@@ -947,8 +939,6 @@
             Long.toString(getBundleId()) + "." + Integer.toString(revision),
             m_archive.getRevision(revision).getContent(),
             headerMap,
-// TODO: REFACTOR - Karl, does this work correctly if the module is updated to
-//       an extension bundle or vice versa?
             (ExtensionManager.isExtensionBundle(headerMap)) ? null : mp.getCapabilities(),
             mp.getRequirements(),
             mp.getDynamicRequirements(),
@@ -984,12 +974,7 @@
             }
         }
 
-        ((ModuleImpl) module).setBundle(this);
-
-        IModule[] dest = new IModule[m_modules.length + 1];
-        System.arraycopy(m_modules, 0, dest, 0, m_modules.length);
-        dest[m_modules.length] = module;
-        m_modules = dest;
+        return module;
     }
 
     void setProtectionDomain(ProtectionDomain pd)

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java?rev=736339&r1=736338&r2=736339&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
Wed Jan 21 08:55:17 2009
@@ -30,6 +30,7 @@
     private final Felix m_felix;
     private final BundleImpl m_bundle;
 
+    // TODO: SECURITY - This should probably take a module, not a bundle.
     BundleProtectionDomain(Felix felix, BundleImpl bundle)
         throws MalformedURLException
     {

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java?rev=736339&r1=736338&r2=736339&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java Wed
Jan 21 08:55:17 2009
@@ -122,8 +122,7 @@
     // classloader.
     private ExtensionManager()
     {
-// TODO: REFACTOR - Karl, is this correct?
-        m_module = new ExtensionManagerModule();
+        m_module = null;
         m_extensions = new ArrayList();
         m_names = new HashSet();
         m_sourceToExtensions = new HashMap();

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=736339&r1=736338&r2=736339&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Wed Jan 21 08:55:17
2009
@@ -357,14 +357,6 @@
         return this;
     }
 
-    // TODO: REFACTOR - This method is sort of a hack. Since the system bundle
-    //       doesn't have an archive, it can override this method to return its
-    //       manifest.
-    Map getCurrentManifestFromArchive() throws Exception
-    {
-        return getCurrentModule().getHeaders();
-    }
-
     public long getBundleId()
     {
         return 0;
@@ -2061,7 +2053,6 @@
 
                 addSecurity(bundle);
 
-// TODO: REFACTOR - Karl, why do we do this check so late?
                 if (!bundle.isExtension())
                 {
                     Object sm = System.getSecurityManager();
@@ -3081,13 +3072,15 @@
         return true;
     }
 
+    // TODO: SECURITY - This should probably take a module, not a bundle.
     void addSecurity(final BundleImpl bundle) throws Exception
     {
         if (m_securityProvider != null)
         {
             m_securityProvider.checkBundle(bundle);
         }
-        bundle.setProtectionDomain(new BundleProtectionDomain(this, bundle));
+        bundle.getCurrentModule().setSecurityContext(
+            new BundleProtectionDomain(this, bundle));
     }
 
     private BundleActivator createBundleActivator(BundleImpl impl)
@@ -3139,6 +3132,7 @@
             // would be incorrect, because this is a refresh operation
             // and should not trigger bundle REMOVE events.
             IModule[] modules = bundle.getModules();
+// TODO: REFACTOR - It kind of sucks we need to remember this steps.
             for (int i = 0; i < modules.length; i++)
             {
                 m_resolverState.removeModule(modules[i]);
@@ -3803,7 +3797,7 @@
                     // Add new module to resolver state.
 // TODO: REFACTOR - It is not clean to have to remember these steps.
                     m_resolverState.addModule(oldImpl.getCurrentModule());
-// TODO: REFACTOR - Seems like we don't need to repeat this.
+// TODO: REFACTOR - Could we set this when we add the module to the bundle?.
                     addSecurity(m_bundle);
                     fireBundleEvent(BundleEvent.UNRESOLVED, m_bundle);
                 }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java?rev=736339&r1=736338&r2=736339&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
Wed Jan 21 08:55:17 2009
@@ -101,7 +101,7 @@
 
         // Read the boot delegation property and parse it.
 // TODO: REFACTOR - This used to be per framework, now it is per module
-//       which doesn't really make sense.
+//       which doesn't really make sense. Maybe pass in the arrays.
         String s = (m_configMap == null)
             ? null
             : (String) m_configMap.get(Constants.FRAMEWORK_BOOTDELEGATION);



Mime
View raw message