public class MagicLoader<S>
extends java.lang.Object
Constructor and Description |
---|
MagicLoader(java.lang.Class<S> implementedInterface,
java.lang.String... optionalClasses)
Creates a new magic loader for the given class.
|
MagicLoader(java.lang.ClassLoader decorated,
java.lang.Class<S> implementedInterface,
java.lang.String... optionalClasses)
Creates a new magic loader for the given class
|
Modifier and Type | Method and Description |
---|---|
java.util.Collection<java.lang.Class<? extends S>> |
getImplementations(java.lang.String targetPackage)
Returns a list of all implementations for the given interface in the give package.
|
S |
load(java.lang.String packageName,
java.lang.Object... arguments)
Loads an implementation for the given interface in the given package.
|
public MagicLoader(java.lang.Class<S> implementedInterface, java.lang.String... optionalClasses)
this(Thread.currentThread().getContextClassLoader(), implementedInterface, className);
implementedInterface
- the implemented interface this loader should loadoptionalClasses
- optional classes to be loaded with this class loaderpublic MagicLoader(java.lang.ClassLoader decorated, java.lang.Class<S> implementedInterface, java.lang.String... optionalClasses)
decorated
- the default class loaderimplementedInterface
- the implemented interface this loader should loadpublic S load(java.lang.String packageName, java.lang.Object... arguments) throws java.lang.Exception
packageName
- the name of the packagearguments
- the the constructor arguments for the desired classjava.lang.Exception
public java.util.Collection<java.lang.Class<? extends S>> getImplementations(java.lang.String targetPackage)
targetPackage
- the target package for the implementation (reduces the search space)