public abstract class ClassUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ClassUtils.ClassSet |
Modifier and Type | Field and Description |
---|---|
static List<ClassLoader> |
knownNonOsgiLoaders
List of special class loaders, outside OSGi, that might be used by the user through boot delegation.
|
static Set<ClassLoader> |
knownNonOsgiLoadersSet
Set of special class loaders, outside OSGi, that might be used by the user through boot delegation.
|
Constructor and Description |
---|
ClassUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
configureFactoryForClass(org.springframework.aop.framework.ProxyFactory factory,
Class<?>[] classes)
Based on the given class, properly instructs the ProxyFactory proxies.
|
static boolean |
containsUnrelatedClasses(Class<?>[] classes)
Determines if multiple classes(not interfaces) are specified, without any relation to each other.
|
static Class<?>[] |
excludeClassesWithModifier(Class<?>[] classes,
int modifier)
Excludes classes from the given array, which match the given modifier.
|
static Class<?>[] |
getAllInterfaces(Class<?> clazz)
Gets all interfaces implemented by the given class.
|
static Class<?>[] |
getClassHierarchy(Class<?> clazz,
ClassUtils.ClassSet inclusion)
Returns an array of parent classes for the given class.
|
static ClassLoader |
getClassLoader(Class<?> clazz)
Returns the classloader for the given class.
|
static ClassLoader |
getFwkClassLoader() |
static Class<?> |
getParticularClass(Class<?>[] classes)
Returns the first matching class from the given array, that doens't belong to common libraries such as the JDK or
OSGi API.
|
static Class<?>[] |
getVisibleClasses(Class<?>[] classes,
org.osgi.framework.Bundle bundle)
Given an array of classes, eliminates the ones that cannot be loaded by the given bundle.
|
static Class<?>[] |
getVisibleClasses(Class<?>[] classes,
ClassLoader classLoader)
Given an array of classes, eliminates the ones that cannot be loaded by the given classloader.
|
static Class<?>[] |
getVisibleClassHierarchy(Class<?> clazz,
ClassUtils.ClassSet inclusion,
org.osgi.framework.Bundle bundle)
'Sugar' method that determines the class hierarchy of the given class, returning only the classes visible to the
given bundle.
|
static Class<?>[] |
getVisibleClassHierarchy(Class<?> clazz,
ClassUtils.ClassSet inclusion,
ClassLoader loader)
Sugar method that determines the class hierarchy of a given class and then filtering based on the given
classloader.
|
static boolean |
isPresent(String className,
org.osgi.framework.Bundle bundle)
Checks the present of a class inside a bundle.
|
static Class<?>[] |
loadClasses(String[] classNames,
ClassLoader classLoader)
Loads and returns the classes given as names, using the given class loader.
|
static Class<?>[] |
loadClassesIfPossible(String[] classNames,
ClassLoader classLoader)
Loads classes with the given name, using the given classloader.
|
static Class<?>[] |
removeParents(Class<?>[] classes)
Parses the given class array and eliminate parents of existing classes.
|
static String[] |
toStringArray(Class<?>[] array)
Returns an array of class string names for the given classes.
|
public static final List<ClassLoader> knownNonOsgiLoaders
public static final Set<ClassLoader> knownNonOsgiLoadersSet
public static ClassLoader getFwkClassLoader()
public static Class<?>[] getClassHierarchy(Class<?> clazz, ClassUtils.ClassSet inclusion)
Constants.OBJECTCLASS
property.
Note: this method does class expansion returning parent as well as children classes.
clazz
- mode
- #INCLUDE_ALL_CLASSES
,
#INCLUDE_CLASS_HIERARCHY
,
#INCLUDE_INTERFACES
public static Class<?>[] getVisibleClassHierarchy(Class<?> clazz, ClassUtils.ClassSet inclusion, ClassLoader loader)
clazz
- mode
- loader
- public static Class<?>[] getVisibleClassHierarchy(Class<?> clazz, ClassUtils.ClassSet inclusion, org.osgi.framework.Bundle bundle)
clazz
- the class for which the hierarchy has to be determinedmode
- discovery modebundle
- bundle used for class visibilitypublic static Class<?>[] getVisibleClasses(Class<?>[] classes, ClassLoader classLoader)
public static Class<?>[] getVisibleClasses(Class<?>[] classes, org.osgi.framework.Bundle bundle)
public static Class<?>[] getAllInterfaces(Class<?> clazz)
clazz
- public static boolean isPresent(String className, org.osgi.framework.Bundle bundle)
className
- bundle
- public static ClassLoader getClassLoader(Class<?> clazz)
clazz
- public static String[] toStringArray(Class<?>[] array)
array
- public static boolean containsUnrelatedClasses(Class<?>[] classes)
classes
- an array of classespublic static Class<?>[] removeParents(Class<?>[] classes)
classes
- array of classescontainsUnrelatedClasses(Class[])
,
configureFactoryForClass(ProxyFactory, Class[])
public static void configureFactoryForClass(org.springframework.aop.framework.ProxyFactory factory, Class<?>[] classes)
factory
- classes
- containsUnrelatedClasses(Class[])
,
removeParents(Class[])
public static Class<?>[] loadClassesIfPossible(String[] classNames, ClassLoader classLoader)
ClassNotFoundException
exceptions are
being ignored. The return class array will not contain duplicates.classNames
- array of classnames to load (in FQN format)classLoader
- classloader used for loading the classespublic static Class<?>[] loadClasses(String[] classNames, ClassLoader classLoader)
classNames
- array of class namesclassLoader
- class loader for loading the classespublic static Class<?>[] excludeClassesWithModifier(Class<?>[] classes, int modifier)
classes
- array of classes (can be null)modifier
- class modifierModifier
public static Class<?> getParticularClass(Class<?>[] classes)
classes
- array of classesCopyright © 2006–2014. All rights reserved.