|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limitless.util.GroupClassLoader
public class GroupClassLoader
This loads a group of classes by regex pattern in a directory that share a common interface.
It's meant to be used as follows:
GroupClassLoader gcl = new GroupClassLoader();
Class[] matching = gcl.loadClasses(
new File( directoryName ),
"org.limiitless.",
interfaceExpected.class );
The loader can be re-used as often as desired, even threaded, as it uses no stateful data.
The path specifier is required because it is prepended to each name found in the directory, which ensures that no hanky-panky takes place (the class loader used to do the loading is the standard loader, and it looks for things by full package naming, and in their proper places).
| Nested Class Summary | |
|---|---|
private static class |
GroupClassLoader.Worker
Objects of this class will populate the destination list. |
| Field Summary | |
|---|---|
private static FileVisitor |
fileVisitor
This is used freely by any threads as needed without harm. |
private static org.apache.log4j.Logger |
logger
Log4J Logger for the class |
| Constructor Summary | |
|---|---|
GroupClassLoader()
The object has no protected state. |
|
| Method Summary | |
|---|---|
java.lang.Class[] |
loadClasses(java.io.File startingDirectory,
java.lang.String packagePreface,
java.lang.Class expectedInterface)
Cause all classes in the package (directory) with a given interface to be loaded and their Class objects returned. |
static void |
main(java.lang.String[] args)
Testing main. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static org.apache.log4j.Logger logger
private static final FileVisitor fileVisitor
| Constructor Detail |
|---|
public GroupClassLoader()
| Method Detail |
|---|
public java.lang.Class[] loadClasses(java.io.File startingDirectory,
java.lang.String packagePreface,
java.lang.Class expectedInterface)
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||