org.springframework.osgi.util
Class OsgiBundleUtils

java.lang.Object
  extended by org.springframework.osgi.util.OsgiBundleUtils

public abstract class OsgiBundleUtils
extends Object

Utility class for OSGi Bundles. Provides convenience methods for interacting with a Bundle object.

Author:
Adrian Colyer, Costin Leau
See Also:
OsgiStringUtils

Constructor Summary
OsgiBundleUtils()
           
 
Method Summary
static Bundle findBundleBySymbolicName(BundleContext bundleContext, String symbolicName)
          Finds an install bundle based by its symbolic name.
static BundleContext getBundleContext(Bundle bundle)
          Returns the underlying BundleContext for the given Bundle.
static Version getBundleVersion(Bundle bundle)
          Returns the given bundle version.
static Version getHeaderAsVersion(Bundle bundle, String header)
          Returns the version for a given bundle manifest header.
static boolean isBundleActive(Bundle bundle)
          Indicates if the given bundle is active or not.
static boolean isBundleResolved(Bundle bundle)
          Indicates if the given bundle is resolved or not.
static boolean isFragment(Bundle bundle)
          Indicates if the given bundle is a fragment or not.
static boolean isSystemBundle(Bundle bundle)
          Indicates if the given bundle is the system bundle or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OsgiBundleUtils

public OsgiBundleUtils()
Method Detail

getBundleContext

public static BundleContext getBundleContext(Bundle bundle)
Returns the underlying BundleContext for the given Bundle. This uses reflection and highly dependent of the OSGi implementation. Should not be used if OSGi 4.1 is being used.

Parameters:
bundle - OSGi bundle
Returns:
the bundle context for this bundle

isBundleActive

public static boolean isBundleActive(Bundle bundle)
Indicates if the given bundle is active or not.

Parameters:
bundle - OSGi bundle
Returns:
true if the given bundle is active, false otherwise
See Also:
Bundle.ACTIVE

isBundleResolved

public static boolean isBundleResolved(Bundle bundle)
Indicates if the given bundle is resolved or not.

Parameters:
bundle - OSGi bundle
Returns:
true if the given bundle is resolved, false otherwise
See Also:
Bundle.RESOLVED

isFragment

public static boolean isFragment(Bundle bundle)
Indicates if the given bundle is a fragment or not.

Parameters:
bundle - OSGi bundle
Returns:
true if the given bundle is a fragment, false otherwise
See Also:
Constants.FRAGMENT_HOST

isSystemBundle

public static boolean isSystemBundle(Bundle bundle)
Indicates if the given bundle is the system bundle or not.

Parameters:
bundle - OSGi bundle
Returns:
true if the given bundle is a fragment, false otherwise

getBundleVersion

public static Version getBundleVersion(Bundle bundle)
Returns the given bundle version.

Parameters:
bundle - OSGi bundle
Returns:
bundle version
See Also:
Constants.BUNDLE_VERSION

findBundleBySymbolicName

public static Bundle findBundleBySymbolicName(BundleContext bundleContext,
                                              String symbolicName)
Finds an install bundle based by its symbolic name.

Parameters:
bundleContext - OSGi bundle context
symbolicName - bundle symbolic name
Returns:
bundle matching the symbolic name (null if none is found)

getHeaderAsVersion

public static Version getHeaderAsVersion(Bundle bundle,
                                         String header)
Returns the version for a given bundle manifest header.

Parameters:
bundle - OSGi bundle
header - bundle manifest header
Returns:
the header value


Copyright © 2006-2009 Spring Framework. All Rights Reserved.