Package tigase.osgi.util

# Class ClassUtil

java.lang.Object
tigase.osgi.util.ClassUtil

public class ClassUtil extends Object
`ClassUtil` file contains code used for loading all implementations of specified interface or abstract class found in classpath. As a result of calling some functions you can have `Set` containing all required classes.

Created: Wed Oct 6 08:25:52 2004

Version:
  $Rev: 609 $
Author:
  Artur Hefczyc

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClassUtil()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T extends Class, S extends Class>
  Set<S>`
  `getClassesAnnotated(ClassLoader loader, File f, T cls)`
  Scans file for classes annotated with annotation T * * @param loader class loader used to load classes
  `static <T extends Class, S extends Class>
  Set<S>`
  `getClassesAnnotated(org.osgi.framework.Bundle bundle, T cls)`
  Scans OSGI bundle for classes annotated with annotation T * * @param bundle bundle to scan for annotated classes
  `static Set<Class<?>>`
  `getClassesFromBundle(org.osgi.framework.Bundle bundle)`
  `static Set<Class>`
  `getClassesFromClassPath()`
  `static Set<Class>`
  `getClassesFromNames(ClassLoader loader, Set<String> names)`
  `static <T extends Class>
  Set<T>`
  `getClassesImplementing(ClassLoader loader, File f, T cls)`
  `static <T extends Class>
  Set<T>`
  `getClassesImplementing(Collection<Class> classes, T cls)`
  `static <T extends Class>
  Set<T>`
  `getClassesImplementing(org.osgi.framework.Bundle bundle, T cls)`
  Scans OSGI bundle for classes implementing class T
  `static <T extends Class>
  Set<T>`
  `getClassesImplementing(T cls)`
  `static String`
  `getClassNameFromFileName(String fileName)`
  `static Set<String>`
  `getClassNamesFromDir(File dir)`
  `static Set<String>`
  `getClassNamesFromJar(File jarFile)`
  `static Set<String>`
  `getClassNamesFromWar(File jarFile)`
  `static Set<String>`
  `getFileListDeep(File path)`
  `static <T> Set<T>`
  `getImplementations(Class<T> obj)`
  `static void`
  `walkInDirForFiles(File base_dir, String path, Set<String> set)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ClassUtil

    public ClassUtil()

- ## Method Details

  - ### getClassNameFromFileName

    public static String getClassNameFromFileName(String fileName)

  - ### getClassNamesFromDir

    public static Set<String> getClassNamesFromDir(File dir)

  - ### getClassNamesFromJar

    public static Set<String> getClassNamesFromJar(File jarFile) throws IOException
    Throws:
      `IOException`

  - ### getClassNamesFromWar

    public static Set<String> getClassNamesFromWar(File jarFile) throws IOException
    Throws:
      `IOException`

  - ### getClassesAnnotated

    public static <T extends Class, S extends Class> Set<S> getClassesAnnotated(ClassLoader loader, File f, T cls) throws IOException, ClassNotFoundException
    Scans file for classes annotated with annotation T * * @param loader class loader used to load classes
    Parameters:
      `f` - file to scan for classes
      `cls` - annotation class
    Returns:
      set of annotated classes
    Throws:
      `IOException`
      `ClassNotFoundException`

  - ### getClassesAnnotated

    public static <T extends Class, S extends Class> Set<S> getClassesAnnotated(org.osgi.framework.Bundle bundle, T cls) throws IOException, ClassNotFoundException
    Scans OSGI bundle for classes annotated with annotation T * * @param bundle bundle to scan for annotated classes
    Parameters:
      `cls` - annotation class
    Returns:
      set of annotated classes
    Throws:
      `IOException`
      `ClassNotFoundException`

  - ### getClassesFromBundle

    public static Set<Class<?>> getClassesFromBundle(org.osgi.framework.Bundle bundle)

  - ### getClassesFromClassPath

    public static Set<Class> getClassesFromClassPath() throws IOException, ClassNotFoundException
    Throws:
      `IOException`
      `ClassNotFoundException`

  - ### getClassesFromNames

    public static Set<Class> getClassesFromNames(ClassLoader loader, Set<String> names) throws ClassNotFoundException
    Throws:
      `ClassNotFoundException`

  - ### getClassesImplementing

    public static <T extends Class> Set<T> getClassesImplementing(Collection<Class> classes, T cls)

  - ### getClassesImplementing

    public static <T extends Class> Set<T> getClassesImplementing(T cls) throws IOException, ClassNotFoundException
    Throws:
      `IOException`
      `ClassNotFoundException`

  - ### getClassesImplementing

    public static <T extends Class> Set<T> getClassesImplementing(ClassLoader loader, File f, T cls) throws IOException, ClassNotFoundException
    Throws:
      `IOException`
      `ClassNotFoundException`

  - ### getClassesImplementing

    public static <T extends Class> Set<T> getClassesImplementing(org.osgi.framework.Bundle bundle, T cls) throws IOException, ClassNotFoundException
    Scans OSGI bundle for classes implementing class T
    Type Parameters:
      `T` - return type param
    Parameters:
      `bundle` - bundle to scan
      `cls` - base class
    Returns:
      returns set of implementations
    Throws:
      `IOException`
      `ClassNotFoundException`

  - ### getFileListDeep

    public static Set<String> getFileListDeep(File path)

  - ### getImplementations

    public static <T> Set<T> getImplementations(Class<T> obj) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
    Throws:
      `IOException`
      `ClassNotFoundException`
      `InstantiationException`
      `IllegalAccessException`

  - ### walkInDirForFiles

    public static void walkInDirForFiles(File base_dir, String path, Set<String> set)