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.hibernate.search.util
Class PluginLoader

    java.lang.Object
      org.hibernate.search.util.PluginLoader

    public class PluginLoader

extends java.lang.Object

Utility class to load instances of other classes by using a fully qualified name, or from a class type. Uses reflection and throws SearchException(s) with proper descriptions of the error, like the target class is missing a proper constructor, is an interface, is not found...

Author:
  Sanne Grinovero

Constructor Summary
`PluginLoader()`

Method Summary
`static void` | `checkHasValidconstructor(java.lang.Class<?> classToLoad, java.lang.String componentDescription)` Verifies if target class has a no-args constructor, and that it is accessible in current security manager.
`static
`<T> T`
` | `instanceFromClass(java.lang.Class<T> targetSuperType, java.lang.Class<?> classToLoad, java.lang.String componentDescription)` Creates an instance of target class
`static
`<T> T`
` | `instanceFromName(java.lang.Class<T> targetSuperType, java.lang.String classNameToLoad, java.lang.Class<?> caller, java.lang.String componentDescription)` Creates an instance of a target class designed by fully qualified name

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

Constructor Detail

### PluginLoader

    public PluginLoader()

Method Detail

### instanceFromName

    public static <T> T instanceFromName(java.lang.Class<T> targetSuperType,
                                         java.lang.String classNameToLoad,
                                         java.lang.Class<?> caller,
                                         java.lang.String componentDescription)

  Creates an instance of a target class designed by fully qualified name

  Type Parameters:
    `T` - matches the type of targetSuperType: defines the return type
  Parameters:
    `targetSuperType` - the return type of the function, the classNameToLoad will be checked to be assignable to this type.
    `classNameToLoad` - a fully qualified class name, whose type is assignable to targetSuperType
    `caller` - the class of the caller, needed for classloading purposes
    `componentDescription` - a meaningful description of the role the instance will have, used to enrich error messages to describe the context of the error
  Returns:
    a new instance of classNameToLoad
  Throws:
    `SearchException` - wrapping other error types with a proper error message for all kind of problems, like classNotFound, missing proper constructor, wrong type, security errors.

### instanceFromClass

    public static <T> T instanceFromClass(java.lang.Class<T> targetSuperType,
                                          java.lang.Class<?> classToLoad,
                                          java.lang.String componentDescription)

  Creates an instance of target class

  Type Parameters:
    `T` - the type of targetSuperType: defines the return type
  Parameters:
    `targetSuperType` - the created instance will be checked to be assignable to this type
    `classToLoad` - the class to be instantiated
    `componentDescription` - a role name/description to contextualize error messages
  Returns:
    a new instance of classToLoad
  Throws:
    `SearchException` - wrapping other error types with a proper error message for all kind of problems, like missing proper constructor, wrong type, security errors.

### checkHasValidconstructor

    public static void checkHasValidconstructor(java.lang.Class<?> classToLoad,
                                                java.lang.String componentDescription)

  Verifies if target class has a no-args constructor, and that it is accessible in current security manager.

  Parameters:
    `classToLoad` - the class type to check
    `componentDescription` - adds a meaningful description to the type to describe in the exception message

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-2010 Hibernate. All Rights Reserved.