Package tigase.osgi.util

## Class ClassUtil

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

-     public class ClassUtil
      extends java.lang.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

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

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

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

- - ### Constructor Detail

    - #### ClassUtil

          public ClassUtil()

  - ### Method Detail

    - #### getClassNameFromFileName

          public static java.lang.String getClassNameFromFileName​(java.lang.String fileName)

    - #### getClassNamesFromDir

          public static java.util.Set<java.lang.String> getClassNamesFromDir​(java.io.File dir)

    - #### getClassNamesFromJar

          public static java.util.Set<java.lang.String> getClassNamesFromJar​(java.io.File jarFile)
                                                                      throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getClassNamesFromWar

          public static java.util.Set<java.lang.String> getClassNamesFromWar​(java.io.File jarFile)
                                                                      throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getClassesAnnotated

          public static <T extends java.lang.Class,​S extends java.lang.Class> java.util.Set<S> getClassesAnnotated​(java.lang.ClassLoader loader,
                                                                                                                         java.io.File f,
                                                                                                                         T cls)
                                                                                                                  throws java.io.IOException,
                                                                                                                         java.lang.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:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`

    - #### getClassesAnnotated

          public static <T extends java.lang.Class,​S extends java.lang.Class> java.util.Set<S> getClassesAnnotated​(org.osgi.framework.Bundle bundle,
                                                                                                                         T cls)
                                                                                                                  throws java.io.IOException,
                                                                                                                         java.lang.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:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`

    - #### getClassesFromBundle

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

    - #### getClassesFromClassPath

          public static java.util.Set<java.lang.Class> getClassesFromClassPath()
                                                                        throws java.io.IOException,
                                                                               java.lang.ClassNotFoundException

      Throws:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`

    - #### getClassesFromNames

          public static java.util.Set<java.lang.Class> getClassesFromNames​(java.lang.ClassLoader loader,
                                                                           java.util.Set<java.lang.String> names)
                                                                    throws java.lang.ClassNotFoundException

      Throws:
        `java.lang.ClassNotFoundException`

    - #### getClassesImplementing

          public static <T extends java.lang.Class> java.util.Set<T> getClassesImplementing​(java.util.Collection<java.lang.Class> classes,
                                                                                            T cls)

    - #### getClassesImplementing

          public static <T extends java.lang.Class> java.util.Set<T> getClassesImplementing​(T cls)
                                                                                     throws java.io.IOException,
                                                                                            java.lang.ClassNotFoundException

      Throws:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`

    - #### getClassesImplementing

          public static <T extends java.lang.Class> java.util.Set<T> getClassesImplementing​(java.lang.ClassLoader loader,
                                                                                            java.io.File f,
                                                                                            T cls)
                                                                                     throws java.io.IOException,
                                                                                            java.lang.ClassNotFoundException

      Throws:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`

    - #### getClassesImplementing

          public static <T extends java.lang.Class> java.util.Set<T> getClassesImplementing​(org.osgi.framework.Bundle bundle,
                                                                                            T cls)
                                                                                     throws java.io.IOException,
                                                                                            java.lang.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:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`

    - #### getFileListDeep

          public static java.util.Set<java.lang.String> getFileListDeep​(java.io.File path)

    - #### getImplementations

          public static <T> java.util.Set<T> getImplementations​(java.lang.Class<T> obj)
                                                         throws java.io.IOException,
                                                                java.lang.ClassNotFoundException,
                                                                java.lang.InstantiationException,
                                                                java.lang.IllegalAccessException

      Throws:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`
        `java.lang.InstantiationException`
        `java.lang.IllegalAccessException`

    - #### walkInDirForFiles

          public static void walkInDirForFiles​(java.io.File base_dir,
                                               java.lang.String path,
                                               java.util.Set<java.lang.String> set)