Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.gemini.blueprint.util.internal
Class ClassUtils

    java.lang.Object
      org.eclipse.gemini.blueprint.util.internal.ClassUtils

    public abstract class ClassUtils

extends Object

Class utility used internally. Contains mainly class inheritance mechanisms used when creating OSGi service proxies.

Author:
  Costin Leau

Nested Class Summary
`static class` | `ClassUtils.ClassSet`

Field Summary
`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 Summary
`ClassUtils()`

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### knownNonOsgiLoaders

    public static final List<ClassLoader> knownNonOsgiLoaders

  List of special class loaders, outside OSGi, that might be used by the user through boot delegation. read-only.

### knownNonOsgiLoadersSet

    public static final Set<ClassLoader> knownNonOsgiLoadersSet

  Set of special class loaders, outside OSGi, that might be used by the user through boot delegation. read-only.

Constructor Detail

### ClassUtils

    public ClassUtils()

Method Detail

### getFwkClassLoader

    public static ClassLoader getFwkClassLoader()

### getClassHierarchy

    public static Class<?>[] getClassHierarchy(Class<?> clazz,
                                               ClassUtils.ClassSet inclusion)

  Returns an array of parent classes for the given class. The mode paramater indicates whether only interfaces should be included, classes or both. This method is normally used for publishing services and determing the `Constants.OBJECTCLASS` property.

  Note: this method does class expansion returning parent as well as children classes.

  Parameters:
    `clazz` -
    `mode` -
  Returns:
    array of classes extended or implemented by the given class
  See Also:
    `#INCLUDE_ALL_CLASSES`, `#INCLUDE_CLASS_HIERARCHY`, `#INCLUDE_INTERFACES`

### getVisibleClassHierarchy

    public 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. If a null classloader, the one of the given class will be used.

  Parameters:
    `clazz` -
    `mode` -
    `loader` -
  Returns:

### getVisibleClassHierarchy

    public 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.

  Parameters:
    `clazz` - the class for which the hierarchy has to be determined
    `mode` - discovery mode
    `bundle` - bundle used for class visibility
  Returns:
    array of visible classes part of the hierarchy

### getVisibleClasses

    public static Class<?>[] getVisibleClasses(Class<?>[] classes,
                                               ClassLoader classLoader)

  Given an array of classes, eliminates the ones that cannot be loaded by the given classloader.

  Returns:

### getVisibleClasses

    public 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.

  Returns:

### getAllInterfaces

    public static Class<?>[] getAllInterfaces(Class<?> clazz)

  Gets all interfaces implemented by the given class. This method returns both parent and children interfaces (i.e. Map and SortedMap).

  Parameters:
    `clazz` -
  Returns:
    all interfaces implemented by the given class.

### isPresent

    public static boolean isPresent(String className,
                                    org.osgi.framework.Bundle bundle)

  Checks the present of a class inside a bundle. This method returns true if the given bundle can load the given class or false otherwise.

  Parameters:
    `className` -
    `bundle` -
  Returns:

### getClassLoader

    public static ClassLoader getClassLoader(Class<?> clazz)

  Returns the classloader for the given class. This method deals with JDK classes which return by default, a null classloader.

  Parameters:
    `clazz` -
  Returns:

### toStringArray

    public static String[] toStringArray(Class<?>[] array)

  Returns an array of class string names for the given classes.

  Parameters:
    `array` -
  Returns:

### containsUnrelatedClasses

    public static boolean containsUnrelatedClasses(Class<?>[] classes)

  Determines if multiple classes(not interfaces) are specified, without any relation to each other. Interfaces will simply be ignored.

  Parameters:
    `classes` - an array of classes
  Returns:
    true if at least two classes unrelated to each other are found, false otherwise

### removeParents

    public static Class<?>[] removeParents(Class<?>[] classes)

  Parses the given class array and eliminate parents of existing classes. Useful when creating proxies to minimize the number of implemented interfaces and redundant class information.

  Parameters:
    `classes` - array of classes
  Returns:
    a new array without superclasses
  See Also:
    `containsUnrelatedClasses(Class[])`, `configureFactoryForClass(ProxyFactory, Class[])`

### configureFactoryForClass

    public static void configureFactoryForClass(org.springframework.aop.framework.ProxyFactory factory,
                                                Class<?>[] classes)

  Based on the given class, properly instructs the ProxyFactory proxies. For additional sanity checks on the passed classes, check the methods below.

  Parameters:
    `factory` -
    `classes` -
  See Also:
    `containsUnrelatedClasses(Class[])`, `removeParents(Class[])`

### loadClassesIfPossible

    public static Class<?>[] loadClassesIfPossible(String[] classNames,
                                                   ClassLoader classLoader)

  Loads classes with the given name, using the given classloader. `ClassNotFoundException` exceptions are being ignored. The return class array will not contain duplicates.

  Parameters:
    `classNames` - array of classnames to load (in FQN format)
    `classLoader` - classloader used for loading the classes
  Returns:
    an array of classes (can be smaller then the array of class names) w/o duplicates

### loadClasses

    public static Class<?>[] loadClasses(String[] classNames,
                                         ClassLoader classLoader)

  Loads and returns the classes given as names, using the given class loader. Throws IllegalArgument exception if the classes cannot be loaded.

  Parameters:
    `classNames` - array of class names
    `classLoader` - class loader for loading the classes
  Returns:
    the loaded classes

### excludeClassesWithModifier

    public static Class<?>[] excludeClassesWithModifier(Class<?>[] classes,
                                                        int modifier)

  Excludes classes from the given array, which match the given modifier.

  Parameters:
    `classes` - array of classes (can be null)
    `modifier` - class modifier
  Returns:
    array of classes (w/o duplicates) which does not have the given modifier
  See Also:
    `Modifier`

### getParticularClass

    public 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. Useful for filtering OSGi services by type to prevent class cast problems.

  No sanity checks are done on the given array class.

  Parameters:
    `classes` - array of classes
  Returns:
    a 'particular' (non JDK/OSGi) class if one is found. Else the first available entry is returned.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2013. All Rights Reserved.