Switch to internal Librarywrapper instance management.
This commit is contained in:
parent
3e50a065a3
commit
492399ec82
@ -1,13 +1,24 @@
|
|||||||
package net.tomatentum.marinara;
|
package net.tomatentum.marinara;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
import net.tomatentum.marinara.registry.InteractionRegistry;
|
import net.tomatentum.marinara.registry.InteractionRegistry;
|
||||||
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
||||||
|
|
||||||
public class Marinara {
|
public class Marinara {
|
||||||
|
|
||||||
public static Marinara load(LibraryWrapper wrapper) {
|
public static <T extends LibraryWrapper> Marinara load(Class<T> clazz) {
|
||||||
InteractionRegistry registry = new InteractionRegistry(wrapper);
|
try {
|
||||||
return new Marinara(registry);
|
Constructor<T> ctor = clazz.getConstructor();
|
||||||
|
ctor.setAccessible(true);
|
||||||
|
T wrapper = ctor.newInstance();
|
||||||
|
InteractionRegistry registry = new InteractionRegistry(wrapper);
|
||||||
|
return new Marinara(registry);
|
||||||
|
}catch (Exception ex) {
|
||||||
|
System.err.println(ex);
|
||||||
|
System.exit(100);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private InteractionRegistry registry;
|
private InteractionRegistry registry;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user