felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r750065 - in /felix/trunk/framework: ./ src/main/java/org/apache/felix/framework/ src/main/java/org/apache/felix/framework/searchpolicy/ src/main/java/org/osgi/framework/launch/ src/main/resources/META-INF/ src/main/resources/META-INF/servi...
Date Wed, 04 Mar 2009 16:26:24 GMT
Author: rickhall
Date: Wed Mar  4 16:26:23 2009
New Revision: 750065

URL: http://svn.apache.org/viewvc?rev=750065&view=rev
Log:
Modified Felix' constructor so that it no longer throws an exception so
it aligns better with the OSGi META-INF/services framework factory.

Added:
    felix/trunk/framework/src/main/resources/META-INF/
    felix/trunk/framework/src/main/resources/META-INF/services/
    felix/trunk/framework/src/main/resources/META-INF/services/org.osgi.framework.launch.FrameworkFactory
      - copied unchanged from r749794, felix/trunk/framework/org.osgi.framework.launch.FrameworkFactory
Removed:
    felix/trunk/framework/org.osgi.framework.launch.FrameworkFactory
Modified:
    felix/trunk/framework/pom.xml
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.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/FrameworkFactory.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
    felix/trunk/framework/src/main/java/org/osgi/framework/launch/FrameworkFactory.java

Modified: felix/trunk/framework/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/framework/pom.xml?rev=750065&r1=750064&r2=750065&view=diff
==============================================================================
--- felix/trunk/framework/pom.xml (original)
+++ felix/trunk/framework/pom.xml Wed Mar  4 16:26:23 2009
@@ -65,7 +65,7 @@
             <Export-Package>org.osgi.framework;-split-package:=merge-first,org.osgi.framework.launch,org.osgi.framework.hooks.service,org.osgi.service.packageadmin,org.osgi.service.url,org.osgi.service.startlevel,org.osgi.util.tracker</Export-Package>
             <Private-Package>org.apache.felix.moduleloader.*,org.apache.felix.framework.*</Private-Package>
             <Import-Package>!*</Import-Package>
-            <Include-Resource>META-INF/services/org.osgi.framework.launch.FrameworkFactory=org.osgi.framework.launch.FrameworkFactory,META-INF/LICENSE=LICENSE,META-INF/NOTICE=NOTICE,{src/main/resources/},org/osgi/framework/=target/classes/org/osgi/framework/</Include-Resource>

+            <Include-Resource>META-INF/LICENSE=LICENSE,META-INF/NOTICE=NOTICE,{src/main/resources/},org/osgi/framework/=target/classes/org/osgi/framework/</Include-Resource>

           </instructions>
         </configuration>
       </plugin>

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=750065&r1=750064&r2=750065&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 Mar
 4 16:26:23 2009
@@ -59,6 +59,20 @@
     private int m_lockCount = 0;
     private Thread m_lockThread = null;
 
+    /**
+     * This constructor is used by the system bundle (i.e., the framework),
+     * since it needs a constructor that does not throw an exception.
+    **/
+    BundleImpl()
+    {
+        __m_felix = null;
+        m_archive = null;
+        m_state = Bundle.INSTALLED;
+        m_stale = false;
+        m_activator = null;
+        m_context = null;
+    }
+
     BundleImpl(Felix felix, BundleArchive archive) throws Exception
     {
         __m_felix = felix;
@@ -68,13 +82,8 @@
         m_activator = null;
         m_context = null;
 
-        // We have to check for null here because the framework/system bundle
-        // extends BundleImpl and it doesn't have an archive.
-        if (m_archive != null)
-        {
-            IModule module = createModule();
-            addModule(module);
-        }
+        IModule module = createModule();
+        addModule(module);
     }
 
     // This method exists because the system bundle extends BundleImpl

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=750065&r1=750064&r2=750065&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
Mar  4 16:26:23 2009
@@ -139,7 +139,7 @@
      * @param config the configuration to read properties from.
      * @param systemBundleInfo the info to change if we need to add exports.
      */
-    ExtensionManager(Logger logger, Felix felix) throws BundleException
+    ExtensionManager(Logger logger, Felix felix)
     {
         m_module = new ExtensionManagerModule(felix);
         m_extensions = null;
@@ -614,9 +614,9 @@
     class ExtensionManagerModule extends ModuleImpl
     {
         private final Version m_version;
-        ExtensionManagerModule(Felix felix) throws BundleException
+        ExtensionManagerModule(Felix felix)
         {
-            super(m_logger, null, null, felix, "0", null, null, null,
+            super(m_logger, felix, "0",
                 felix.getBootPackages(), felix.getBootPackageWildcards());
             m_version = new Version((String)
                 felix.getConfig().get(FelixConstants.FELIX_VERSION_PROPERTY));

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=750065&r1=750064&r2=750065&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 Mar  4 16:26:23
2009
@@ -246,9 +246,9 @@
      * @param configMap A map for obtaining configuration properties,
      *        may be <tt>null</tt>.
     **/
-    public Felix(Map configMap) throws Exception
+    public Felix(Map configMap)
     {
-        super(null, null);
+        super();
         // Copy the configuration properties; convert keys to strings.
         m_configMutableMap = new StringMap(false);
         if (configMap != null)
@@ -299,7 +299,16 @@
         // Create the extension manager, which we will use as the module
         // definition for creating the system bundle module.
         m_extensionManager = new ExtensionManager(m_logger, this);
-        addModule(m_extensionManager.getModule());
+        try
+        {
+            addModule(m_extensionManager.getModule());
+        }
+        catch (Exception ex)
+        {
+            // This should not throw an exception, but if so, lets convert it to
+            // a runtime exception.
+            throw new RuntimeException(ex.getMessage());
+        }
 
 
         // Read the boot delegation property and parse it.

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/FrameworkFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/FrameworkFactory.java?rev=750065&r1=750064&r2=750065&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/FrameworkFactory.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/FrameworkFactory.java Wed
Mar  4 16:26:23 2009
@@ -23,7 +23,7 @@
 
 public class FrameworkFactory implements org.osgi.framework.launch.FrameworkFactory
 {
-    public Framework newFramework(Map configuration) throws Exception
+    public Framework newFramework(Map configuration)
     {
         return new Felix(configuration);
     }

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=750065&r1=750064&r2=750065&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 Mar  4 16:26:23 2009
@@ -99,6 +99,39 @@
     // Thread local to detect class loading cycles.
     private final ThreadLocal m_cycleCheck = new ThreadLocal();
 
+    /**
+     * This constructor is used by the extension manager, since it needs
+     * a constructor that does not throw an exception.
+     * @param logger
+     * @param bundle
+     * @param id
+     * @param bootPkgs
+     * @param bootPkgWildcards
+     * @throws org.osgi.framework.BundleException
+     */
+    public ModuleImpl(
+        Logger logger, Bundle bundle, String id,
+        String[] bootPkgs, boolean[] bootPkgWildcards)
+    {
+        m_logger = logger;
+        m_configMap = null;
+        m_resolver = null;
+        m_bundle = bundle;
+        m_id = id;
+        m_headerMap = null;
+        m_content = null;
+        m_streamHandler = null;
+        m_bootPkgs = bootPkgs;
+        m_bootPkgWildcards = bootPkgWildcards;
+        m_manifestVersion = null;
+        m_symbolicName = null;
+        m_version = null;
+        m_capabilities = null;
+        m_requirements = null;
+        m_dynamicRequirements = null;
+        m_nativeLibraries = null;
+    }
+
     public ModuleImpl(
         Logger logger, Map configMap, FelixResolver resolver,
         Bundle bundle, String id, Map headerMap, IContent content,
@@ -117,76 +150,61 @@
         m_bootPkgs = bootPkgs;
         m_bootPkgWildcards = bootPkgWildcards;
 
-        // We need to special case the system bundle module, which does not
-        // have a content.
-        if (m_content != null)
-        {
-            ManifestParser mp = new ManifestParser(m_logger, m_configMap, m_headerMap);
-
-            // Record some of the parsed metadata. Note, if this is an extension
-            // bundle it's exports are removed, since they will be added to the
-            // system bundle directly later on.
-            m_manifestVersion = mp.getManifestVersion();
-            m_version = mp.getBundleVersion();
-            m_capabilities = (Util.isExtensionBundle(m_headerMap))
-                ? null : mp.getCapabilities();
-            m_requirements = mp.getRequirements();
-            m_dynamicRequirements = mp.getDynamicRequirements();
-            m_nativeLibraries = mp.getLibraries();
-
-            // Get symbolic name.
-            String symName = null;
-            for (int capIdx = 0;
-                (m_capabilities != null) && (capIdx < m_capabilities.length);
-                capIdx++)
-            {
-                if (m_capabilities[capIdx].getNamespace().equals(ICapability.MODULE_NAMESPACE))
-                {
-                    symName = (String) m_capabilities[capIdx].getProperties().get(
-                        Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
-                    break;
-                }
+        ManifestParser mp = new ManifestParser(m_logger, m_configMap, m_headerMap);
+
+        // Record some of the parsed metadata. Note, if this is an extension
+        // bundle it's exports are removed, since they will be added to the
+        // system bundle directly later on.
+        m_manifestVersion = mp.getManifestVersion();
+        m_version = mp.getBundleVersion();
+        m_capabilities = (Util.isExtensionBundle(m_headerMap))
+            ? null : mp.getCapabilities();
+        m_requirements = mp.getRequirements();
+        m_dynamicRequirements = mp.getDynamicRequirements();
+        m_nativeLibraries = mp.getLibraries();
+
+        // Get symbolic name.
+        String symName = null;
+        for (int capIdx = 0;
+            (m_capabilities != null) && (capIdx < m_capabilities.length);
+            capIdx++)
+        {
+            if (m_capabilities[capIdx].getNamespace().equals(ICapability.MODULE_NAMESPACE))
+            {
+                symName = (String) m_capabilities[capIdx].getProperties().get(
+                    Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
+                break;
             }
-            m_symbolicName = symName;
+        }
+        m_symbolicName = symName;
 
-            // Verify that all native libraries exist in advance; this will
-            // throw an exception if the native library does not exist.
-            try
+        // Verify that all native libraries exist in advance; this will
+        // throw an exception if the native library does not exist.
+        try
+        {
+            for (int i = 0;
+                (m_nativeLibraries != null) && (i < m_nativeLibraries.length);
+                i++)
             {
-                for (int i = 0;
-                    (m_nativeLibraries != null) && (i < m_nativeLibraries.length);
-                    i++)
+                String entryName = m_nativeLibraries[i].getEntryName();
+                if (entryName != null)
                 {
-                    String entryName = m_nativeLibraries[i].getEntryName();
-                    if (entryName != null)
+                    if (m_content.getEntryAsNativeLibrary(entryName) == null)
                     {
-                        if (m_content.getEntryAsNativeLibrary(entryName) == null)
-                        {
-                            throw new BundleException("Native library does not exist: " +
entryName);
-                        }
+                        throw new BundleException("Native library does not exist: " + entryName);
                     }
                 }
             }
-            finally
-            {
-                // We close the module content here to make sure it is closed
-                // to avoid having to close it if there is an exception during
-                // the entire module creation process.
+        }
+        finally
+        {
+            // We close the module content here to make sure it is closed
+            // to avoid having to close it if there is an exception during
+            // the entire module creation process.
 // TODO: REFACTOR - If we do the above check here, then we open the module's content
 //       immediately every time, which means we must close it here so we don't have
 //       to remember to close it if there are other failures during module init.
-                m_content.close();
-            }
-        }
-        else
-        {
-            m_manifestVersion = null;
-            m_version = null;
-            m_capabilities = null;
-            m_requirements = null;
-            m_dynamicRequirements = null;
-            m_nativeLibraries = null;
-            m_symbolicName = null;
+            m_content.close();
         }
     }
 

Modified: felix/trunk/framework/src/main/java/org/osgi/framework/launch/FrameworkFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/launch/FrameworkFactory.java?rev=750065&r1=750064&r2=750065&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/launch/FrameworkFactory.java (original)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/launch/FrameworkFactory.java Wed
Mar  4 16:26:23 2009
@@ -68,5 +68,5 @@
 	 *         <code>AllPermission</code>, and the Java Runtime Environment
 	 *         supports permissions.
 	 */
-	Framework newFramework(Map configuration) throws Exception;
+	Framework newFramework(Map configuration);
 }



Mime
View raw message