switch to user create wrapper instances

This commit is contained in:
tueem 2024-11-01 16:07:10 +01:00
parent 7888819f6e
commit 9d81522429
No known key found for this signature in database
GPG Key ID: 819A0F7C36B9CF07

@ -1,24 +1,13 @@
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 <T extends LibraryWrapper> Marinara load(Class<T> clazz) { public static <T extends LibraryWrapper> Marinara load(LibraryWrapper wrapper) {
try { InteractionRegistry registry = new InteractionRegistry(wrapper);
Constructor<T> ctor = clazz.getConstructor(); return new Marinara(registry);
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;