public final class BundleUtils extends Object
| Constructor and Description |
|---|
BundleUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
bundleEventToString(int eventType)
Returns a String representation for the given bundle event.
|
static ClassLoader |
createBundleClassLoader(org.osgi.framework.Bundle bundle)
Creates an instance of the
BundleDelegatingClassLoader baked by the provided bundle and having Jahia root Spring context's
class loader as a parent. |
static org.osgi.framework.Bundle |
getBundle(long id)
Returns the bundle with the specified identifier.
|
static org.osgi.framework.Bundle |
getBundle(String location)
Finds bundle by its location.
|
static org.osgi.framework.Bundle |
getBundle(String moduleId,
String version)
Find the bundle that is represented by the specified module and version.
|
static org.osgi.framework.Bundle |
getBundleBySymbolicName(String symbolicName,
String version)
Finds the bundle by its symbolic name.
|
static Throwable |
getContextStartException(String key) |
static org.springframework.context.support.AbstractApplicationContext |
getContextToStartForModule(org.osgi.framework.Bundle bundle) |
static String |
getDisplayName(org.osgi.framework.Bundle bundle)
Returns the bundle display name containing module name (ID) and the version.
|
static JahiaTemplatesPackage |
getModule(org.osgi.framework.Bundle bundle)
Returns the module instance that corresponds to the provided OSGi bundle.
|
static String |
getModuleGroupId(org.osgi.framework.Bundle bundle)
Returns the groupId of the module read from the provided bundle.
|
static String |
getModuleId(org.osgi.framework.Bundle bundle)
Returns the module name read from the provided bundle.
|
static String |
getModuleVersion(org.osgi.framework.Bundle bundle)
Returns a version of the module read from the provided bundle.
|
static <S> S |
getOsgiService(Class<S> serviceClass,
String filter)
Looks up an OSGi service for the specified class and filter.
|
static <S> S |
getOsgiService(String serviceClass)
Looks up an OSGi service for the specified class and filter.
|
static Object |
getOsgiService(String serviceClassName,
String filter)
Looks up an OSGi service for the specified class name and filter.
|
static int |
getPersistentState(org.osgi.framework.Bundle bundle)
This method deduce and return the persistent state value of a bundle
|
static boolean |
isFragment(org.osgi.framework.Bundle bundle)
Checks if the provided bundle is a fragment bundle.
|
static boolean |
isJahiaBundle(org.osgi.framework.Bundle bundle)
Returns
true if the provided bundle represents Jahia-related bundle (either a module or a service). |
static boolean |
isJahiaModuleBundle(org.osgi.framework.Bundle bundle)
Returns
true if the provided bundle represents Jahia module. |
static Class<?> |
loadModuleClass(String className)
Performs lookup of the specified class in classloaders of all modules, which are in state Resolved or Active.
|
static Class<?> |
loadModuleClass(String className,
int requiredModuleStatus)
Performs lookup of the specified class in classloaders of all modules, which are at least in the requested state.
|
static void |
setContextStartException(String key,
Throwable exception) |
static void |
setContextToStartForModule(org.osgi.framework.Bundle bundle,
org.springframework.context.support.AbstractApplicationContext context) |
static void |
unregisterModule(org.osgi.framework.Bundle bundle)
Removes the module instance that corresponds to the provided OSGi bundle from internal registry.
|
public static String bundleEventToString(int eventType)
eventType - OSGi BundleEvent given as an intorg.eclipse.gemini.blueprint.util.OsgiStringUtilspublic static ClassLoader createBundleClassLoader(org.osgi.framework.Bundle bundle)
BundleDelegatingClassLoader baked by the provided bundle and having Jahia root Spring context's
class loader as a parent.bundle - the bundle to create class loader forBundleDelegatingClassLoader baked by the provided bundle and having Jahia root Spring context's
class loader as a parentpublic static org.osgi.framework.Bundle getBundleBySymbolicName(String symbolicName, String version)
symbolicName - the bundle symbolic nameversion - the bundle version; or null to get the first matching bundle, foundnull if the corresponding bundle is not presentpublic static org.osgi.framework.Bundle getBundle(long id)
id - The identifier of the bundle to retrieve.Bundle object or null if the identifier does
not match any installed bundle.public static org.osgi.framework.Bundle getBundle(String location)
location - the location of the bundle to be foundnull if there is no matching bundle installedpublic static org.osgi.framework.Bundle getBundle(String moduleId, String version)
moduleId - the module Idversion - the module versionnull if the corresponding bundle is not presentpublic static String getDisplayName(org.osgi.framework.Bundle bundle)
bundle - the bundle to get display name forpublic static JahiaTemplatesPackage getModule(org.osgi.framework.Bundle bundle)
bundle - the corresponding OSGi bundlepublic static String getModuleId(org.osgi.framework.Bundle bundle)
bundle - the bundle to read module name frompublic static String getModuleVersion(org.osgi.framework.Bundle bundle)
bundle - the bundle to read the module version frompublic static String getModuleGroupId(org.osgi.framework.Bundle bundle)
bundle - the bundle to read the module groupId frompublic static boolean isJahiaBundle(org.osgi.framework.Bundle bundle)
true if the provided bundle represents Jahia-related bundle (either a module or a service).bundle - the OSGi bundle to checktrue if the provided bundle represents Jahia-related bundle (either a module or a service)public static boolean isJahiaModuleBundle(org.osgi.framework.Bundle bundle)
true if the provided bundle represents Jahia module.bundle - the OSGi bundle to checktrue if the provided bundle represents Jahia modulepublic static Class<?> loadModuleClass(String className) throws ClassNotFoundException
className - the fully qualified class name to look upClassNotFoundException - in case the corresponding class cannot be foundpublic static Class<?> loadModuleClass(String className, int requiredModuleStatus) throws ClassNotFoundException
className - the fully qualified class name to look uprequiredModuleStatus - the minimal required state of the bundle to be considered for class lookupClassNotFoundException - in case the corresponding class cannot be foundpublic static void unregisterModule(org.osgi.framework.Bundle bundle)
bundle - the corresponding OSGi bundlepublic static org.springframework.context.support.AbstractApplicationContext getContextToStartForModule(org.osgi.framework.Bundle bundle)
public static void setContextToStartForModule(org.osgi.framework.Bundle bundle,
org.springframework.context.support.AbstractApplicationContext context)
public static void setContextStartException(String key, Throwable exception)
public static <S> S getOsgiService(String serviceClass)
null.serviceClass - the class of the service to be looked upnull if no match was foundpublic static <S> S getOsgiService(Class<S> serviceClass, String filter)
null.serviceClass - the class of the service to be looked upfilter - the filter expression or null for all services of the specified typenull if no match was foundIllegalArgumentException - in case the filter expression is syntactically invalidpublic static Object getOsgiService(String serviceClassName, String filter)
null.serviceClassName - the class name of the service to be looked upfilter - the filter expression or null for all services of the specified typenull if no match was foundIllegalArgumentException - in case the filter expression is syntactically invalidpublic static boolean isFragment(org.osgi.framework.Bundle bundle)
bundle - the bundle to be checkedtrue in case the supplied bundle is a fragment bundle; false otherwisepublic static int getPersistentState(org.osgi.framework.Bundle bundle)
bundle - the bundle to get the persistent state fromCopyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.