WebBundleUtil

public final class WebBundleUtil

Utility class for easing bundle related operations/searches.

Methods

findBundleByName

public static Bundle findBundleByName(BundleContext bundleContext, String name)

Does a search for a bundle with a matching Bundle-Name header in its manifest. Note that if there two bundles installed with the same name, the first one found will be returned.

Parameters:
  • bundleContext – the bundle context used for the search
  • name – the Bundle-Name header value of the bundle we are searching for
Returns:

the matching bundle, or null if there is no such bundle

findBundleBySymbolicName

public static Bundle findBundleBySymbolicName(BundleContext bundleContext, String symbolicName)

Does a search for a bundle with a matching symbolic name. Note that if there two bundles installed with the same symbolic name, the first one found will be returned.

Parameters:
  • bundleContext – the bundle context used for the search
  • symbolicName – symbolic name of the bundle we are looking for
Returns:

the matching bundle, or null if no such bundle exists

getContextLocation

public static String getContextLocation(Bundle bundle)

Returns the context file location for the bundle, by using reading its Context-File header.

Parameters:
  • bundle – the bundle for which we want to retrieve the context file location for
Returns:

the location of the context file, or null if it is not defined

getContextPath

public static String getContextPath(Bundle bundle)

Returns the HTTP context path for the bundle, by using reading its Context-Path header.

Parameters:
  • bundle – the bundle for which we want to retrieve the context path for
Returns:

the context path file, or null if it is not defined

getModuleId

public static String getModuleId(Bundle bundle)

Returns an id for a given bundle for internal use. This is the context-path header value, or the symbolic name if the former is not defined.

Parameters:
  • bundle – the bundle for which we need an id
Returns:

the id for the bundle

getSymbolicNames

public static List<String> getSymbolicNames(BundleContext context)

Returns the list of bundles symbolic names.

Parameters:
  • context – the context of the bundle, not null
Returns:

the list of the bundles symbolic names