org.jboss.resteasy.reactive.common.reflection.ReflectionBeanFactory Maven / Gradle / Ivy
package org.jboss.resteasy.reactive.common.reflection;
import org.jboss.resteasy.reactive.spi.BeanFactory;
public class ReflectionBeanFactory implements BeanFactory {
private final String className;
public ReflectionBeanFactory(String className) {
this.className = className;
}
@Override
public BeanInstance createInstance() {
try {
T instance = (T) Class.forName(className, false, Thread.currentThread().getContextClassLoader())
.getDeclaredConstructor()
.newInstance();
return new BeanInstance() {
@Override
public T getInstance() {
return instance;
}
@Override
public void close() {
}
};
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}