geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1098784 - /geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java
Date Mon, 02 May 2011 20:42:12 GMT
Author: gawor
Date: Mon May  2 20:42:11 2011
New Revision: 1098784

URL: http://svn.apache.org/viewvc?rev=1098784&view=rev
Log:
add utility function to unwrap a bundle

Modified:
    geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java

Modified: geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java?rev=1098784&r1=1098783&r2=1098784&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java
(original)
+++ geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java
Mon May  2 20:42:11 2011
@@ -105,7 +105,7 @@ public class BundleUtils {
      *
      * @param unwrap if true and if the bundle associated with the context classloader is
a
      *        {@link DelegatingBundle}, this function will return the main application bundle
-     *        backing with the {@link DelegatingBundle}. Otherwise, the bundle associated
with
+     *        backing the {@link DelegatingBundle}. Otherwise, the bundle associated with
      *        the context classloader is returned as is. See {@link BundleClassLoader#getBundle(boolean)}
      *        for more information.
      * @return The bundle associated with the current thread's context classloader. Might
be null.
@@ -122,6 +122,18 @@ public class BundleUtils {
     }
 
     /**
+     * If the given bundle is a {@link DelegatingBundle} this function will return the main

+     * application bundle backing the {@link DelegatingBundle}. Otherwise, the bundle
+     * passed in is returned as is.
+     */
+    public static Bundle unwrapBundle(Bundle bundle) {
+        if (bundle instanceof DelegatingBundle) {
+            return ((DelegatingBundle) bundle).getMainBundle();
+        }
+        return bundle;
+    }
+    
+    /**
      * Works like {@link Bundle#getEntryPaths(String)} but also returns paths
      * in attached fragment bundles.
      *



Mime
View raw message