public class BundleEvaluator
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
boolean |
addBundleClassFilter(AbstractBundleClassFilter bundleClassFilter)
Adds the specified bundle class filter and executes the needed, filter-specific search.
|
boolean |
addBundleClassFilter(AbstractBundleClassFilter bundleClassFilter,
boolean doBundleEvaluation)
Adds the specified bundle class filter and executes the needed, filter-specific search.
|
void |
addBusyMarkerToAllFilter(java.rmi.server.UID busyMarker)
Adds the specified busy marker to all filter.
|
void |
evaluateAllBundles()
Searches in all current bundles with all class filters defined in
evaluationFilterResults . |
void |
evaluateAllBundles(AbstractBundleClassFilter bundleClassFilterToUse)
Searches all current bundles for specific classes.
|
void |
evaluateBundle(org.osgi.framework.Bundle bundle,
AbstractBundleClassFilter bundleClassFilterToUse)
Searches / filters in the specified bundle for specific classes.
|
void |
evaluateBundleInThread(org.osgi.framework.Bundle bundle,
AbstractBundleClassFilter bundleClassFilterToUse)
Searches / filters in the specified bundle for the classes that are specified by the bundle class filter.
|
java.lang.Class<?> |
findClass(org.osgi.framework.Bundle bundle,
java.lang.String className)
Tries to find the specified class in the bundle.
|
AbstractBundleClassFilter |
getBundleClassFilterByClass(java.lang.Class<?> classOfBundleFilter)
Returns the bundle class filter by the class to search for.
|
org.osgi.framework.BundleContext |
getBundleContext()
Returns the current bundle context.
|
java.lang.String |
getBundleDirectory(org.osgi.framework.Bundle bundle)
Return the bundle directory.
|
org.osgi.framework.Bundle[] |
getBundles()
Returns all bundles that are currently loaded.
|
java.net.URL |
getBundleURL(org.osgi.framework.Bundle bundle)
Returns the bundle URL resolved by the
FileLocator . |
java.util.List<java.lang.Class<?>> |
getClasses(org.osgi.framework.Bundle bundle)
Returns the class references of the specified bundle (maybe quite time consuming).
|
java.util.List<java.lang.Class<?>> |
getClasses(org.osgi.framework.Bundle bundle,
java.lang.String packageFilter)
Returns the class references of the specified bundle (may be quite time consuming, especially without package filter).
|
java.util.List<java.lang.Class<?>> |
getClasses(org.osgi.framework.Bundle bundle,
java.lang.String packageFilter,
int options)
Returns the class references of the specified bundle (may be quite time consuming, especially without package filter).
|
ClassLocaton |
getClassLocation(java.lang.String className)
Returns the ClassLocaton for the specified class name.
|
java.util.List<java.lang.String> |
getClassReferences(org.osgi.framework.Bundle bundle)
Returns the class references of the specified bundle (maybe quite time consuming).
|
java.util.List<java.lang.String> |
getClassReferences(org.osgi.framework.Bundle bundle,
java.lang.String packageFilter)
Returns the class references of the specified bundle (maybe quite time consuming, especially without package filter).
|
java.lang.String |
getFilePathFromURL(java.net.URL url)
Returns the file path from the URL.
|
static BundleEvaluator |
getInstance()
Gets the single instance of BundleEvaluator.
|
java.util.List<java.lang.Class<?>> |
getJarClasses(org.osgi.framework.Bundle bundle,
java.io.File file)
Loads and returns the classes from a jar file into the specified bundle.
|
java.util.List<java.lang.Class<?>> |
getJarClasses(org.osgi.framework.Bundle bundle,
java.net.URL jarFileURL)
Loads and returns the classes from a jar file into the specified bundle.
|
java.util.List<java.lang.Class<?>> |
getJarClassesByClassInstance(org.osgi.framework.Bundle bundle,
java.lang.Class<?> classInstance)
Loads and return the classes of a jar file that contains the specified class.
|
java.util.List<java.lang.String> |
getJarClassReferences(org.osgi.framework.Bundle bundle,
java.io.File file)
Loads and returns the class references from a jar file into the specified bundle.
|
java.util.List<java.lang.String> |
getJarClassReferences(org.osgi.framework.Bundle bundle,
java.net.URL jarFileURL)
Loads and returns the class references from a jar file into the specified bundle.
|
java.util.List<java.lang.String> |
getPackages(org.osgi.framework.Bundle bundle)
Returns the package names of the specified bundle.
|
java.util.List<java.lang.String> |
getPackages(java.util.List<java.lang.Class<?>> classesList)
Return the packages from the specified class list.
|
java.util.List<java.lang.String> |
getPackagesOfClassNames(java.util.List<java.lang.String> classNameList)
Return the packages from the specified class name list.
|
org.osgi.framework.Bundle |
getSourceBundleOfClass(java.lang.Class<?> clazz)
Returns the source bundle that loaded the specified class by using
FrameworkUtil.getBundle(clazz); . |
boolean |
isJarBundle(org.osgi.framework.Bundle bundle)
Checks if the specified
Bundle is packed in a jar. |
boolean |
registerSearchThread(BundleEvaluatorThread bundleEvaluatorThread)
Registers the specified BundleEvaluatorThread.
|
boolean |
removeBundleClassFilter(AbstractBundleClassFilter bundleClassFilter)
Removes the specified bundle class filter.
|
void |
removeBusyMarkerFromAllFilter(java.rmi.server.UID busyMarker)
Removes the specified busy marker from all filter.
|
void |
removeEvaluationFilterResults(org.osgi.framework.Bundle bundle)
Removes the evaluation filter results of the specified bundle.
|
void |
setBundleAdded(org.osgi.framework.Bundle bundle)
Sets that the specified bundle was added.
|
void |
setBundleRemoved(org.osgi.framework.Bundle bundle)
Sets that the specified bundle was removed.
|
void |
unregisterSearchThread(BundleEvaluatorThread bundleEvaluatorThread)
Unregister the specified BundleEvaluatorThread.
|
public static BundleEvaluator getInstance()
public void setBundleAdded(org.osgi.framework.Bundle bundle)
bundle
- the new bundle addedpublic void setBundleRemoved(org.osgi.framework.Bundle bundle)
bundle
- the new bundle removedpublic boolean addBundleClassFilter(AbstractBundleClassFilter bundleClassFilter)
bundleClassFilter
- the bundle class filterpublic boolean addBundleClassFilter(AbstractBundleClassFilter bundleClassFilter, boolean doBundleEvaluation)
bundleClassFilter
- the bundle class filterdoBundleEvaluation
- set true, if you want to directly evaluate all bundles with the current filterpublic boolean removeBundleClassFilter(AbstractBundleClassFilter bundleClassFilter)
bundleClassFilter
- the bundle class filterpublic AbstractBundleClassFilter getBundleClassFilterByClass(java.lang.Class<?> classOfBundleFilter)
classOfBundleFilter
- the class of bundle filterpublic void removeEvaluationFilterResults(org.osgi.framework.Bundle bundle)
bundle
- the bundle from which the results have to be removedpublic ClassLocaton getClassLocation(java.lang.String className)
className
- the class namepublic void addBusyMarkerToAllFilter(java.rmi.server.UID busyMarker)
busyMarker
- the busy markerpublic void removeBusyMarkerFromAllFilter(java.rmi.server.UID busyMarker)
busyMarker
- the busy markerpublic org.osgi.framework.BundleContext getBundleContext()
public org.osgi.framework.Bundle[] getBundles()
public void evaluateAllBundles()
evaluationFilterResults
.public void evaluateAllBundles(AbstractBundleClassFilter bundleClassFilterToUse)
bundleClassFilterToUse
is specified, only this
filter will be used. If this parameter is null
, all class filters
defined in evaluationFilterResults
will be applied.bundleClassFilterToUse
- the bundle class filter to exclusively search with (null
IS permitted).public void evaluateBundleInThread(org.osgi.framework.Bundle bundle, AbstractBundleClassFilter bundleClassFilterToUse)
bundle
- the bundle to search in (null
is NOT permitted)bundleClassFilterToUse
- the bundle class filter to exclusively search with (null
IS permitted).getEvaluationFilterResults()
public boolean registerSearchThread(BundleEvaluatorThread bundleEvaluatorThread)
bundleEvaluatorThread
- the bundle evaluator threadpublic void unregisterSearchThread(BundleEvaluatorThread bundleEvaluatorThread)
bundleEvaluatorThread
- the bundle evaluator threadpublic void evaluateBundle(org.osgi.framework.Bundle bundle, AbstractBundleClassFilter bundleClassFilterToUse)
bundleClassFilterToUse
is specified, only this
filter will be used. If this parameter is null
, all class filters
defined in evaluationFilterResults
will be applied.bundle
- the bundle to search in (null
is NOT permitted)bundleClassFilterToUse
- the bundle class filter to exclusively search with (null
IS permitted).getEvaluationFilterResults()
public java.util.List<java.lang.Class<?>> getClasses(org.osgi.framework.Bundle bundle)
bundle
- the bundle to evaluatepublic java.util.List<java.lang.Class<?>> getClasses(org.osgi.framework.Bundle bundle, java.lang.String packageFilter)
bundle
- the bundle to evaluatepackageFilter
- the package filter; maybe null
, which will return all classes from the bundleoptions
- the options according to the BundleWiring
that are BundleWiring.LISTRESOURCES_RECURSE
, BundleWiring.LISTRESOURCES_LOCAL
or BundleWiring.FINDENTRIES_RECURSE
public java.util.List<java.lang.Class<?>> getClasses(org.osgi.framework.Bundle bundle, java.lang.String packageFilter, int options)
bundle
- the bundle to evaluatepackageFilter
- the package filter; maybe null
, which will return all classes from the bundleoptions
- the options according to the BundleWiring
that are BundleWiring.LISTRESOURCES_RECURSE
, BundleWiring.LISTRESOURCES_LOCAL
or BundleWiring.FINDENTRIES_RECURSE
public java.util.List<java.lang.String> getClassReferences(org.osgi.framework.Bundle bundle)
bundle
- the bundlepublic java.util.List<java.lang.String> getClassReferences(org.osgi.framework.Bundle bundle, java.lang.String packageFilter)
bundle
- the bundlepackageFilter
- the package filter; maybe null
, which will return all classes from the bundlepublic java.util.List<java.lang.String> getPackages(org.osgi.framework.Bundle bundle)
bundle
- the bundlepublic java.util.List<java.lang.String> getPackages(java.util.List<java.lang.Class<?>> classesList)
classList
- the class listpublic java.util.List<java.lang.String> getPackagesOfClassNames(java.util.List<java.lang.String> classNameList)
classList
- the class listpublic java.util.List<java.lang.Class<?>> getJarClassesByClassInstance(org.osgi.framework.Bundle bundle, java.lang.Class<?> classInstance)
bundle
- the bundleclassInstance
- the instancepublic java.util.List<java.lang.Class<?>> getJarClasses(org.osgi.framework.Bundle bundle, java.io.File file)
bundle
- the bundlefile
- the filepublic java.util.List<java.lang.Class<?>> getJarClasses(org.osgi.framework.Bundle bundle, java.net.URL jarFileURL)
bundle
- the bundlefile
- the filepublic java.util.List<java.lang.String> getJarClassReferences(org.osgi.framework.Bundle bundle, java.io.File file)
bundle
- the bundlefile
- the filepublic java.util.List<java.lang.String> getJarClassReferences(org.osgi.framework.Bundle bundle, java.net.URL jarFileURL)
bundle
- the bundlefile
- the filepublic java.lang.String getFilePathFromURL(java.net.URL url)
url
- the URLpublic java.net.URL getBundleURL(org.osgi.framework.Bundle bundle)
FileLocator
.bundle
- the bundlepublic boolean isJarBundle(org.osgi.framework.Bundle bundle)
Bundle
is packed in a jar.bundle
- the bundlepublic java.lang.String getBundleDirectory(org.osgi.framework.Bundle bundle)
bundle
- the bundlepublic org.osgi.framework.Bundle getSourceBundleOfClass(java.lang.Class<?> clazz)
FrameworkUtil.getBundle(clazz);
.clazz
- the class instancepublic java.lang.Class<?> findClass(org.osgi.framework.Bundle bundle, java.lang.String className)
null
.bundle
- the bundle in which the class should be locatedclassName
- the class namenull