Created
May 17, 2012 02:38
-
-
Save anonymous/2715803 to your computer and use it in GitHub Desktop.
Container with access to module via Java API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContainerUsingInterface implements IContainer | |
{ | |
private final Collection<IModule> modules = new HashSet<IModule>(); | |
public synchronized void loadModule(ClassLoader moduleLoader, String moduleClass) throws ClassNotFoundException, InstantiationException, IllegalAccessException | |
{ | |
Class<? extends IModule> clazz = (Class<? extends IModule>) moduleLoader.loadClass(moduleClass); | |
IModule module = clazz.newInstance(); | |
// keep a reference to the module interface; we can communicate with it via the java api | |
modules.add(module); | |
} | |
public synchronized void clearModules() | |
{ | |
modules.clear(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment