io.quarkus.undertow.runtime.QuarkusInstanceFactory Maven / Gradle / Ivy
package io.quarkus.undertow.runtime;
import io.quarkus.arc.runtime.BeanContainer;
import io.undertow.servlet.api.InstanceFactory;
import io.undertow.servlet.api.InstanceHandle;
public class QuarkusInstanceFactory implements InstanceFactory {
private final BeanContainer.Factory factory;
public QuarkusInstanceFactory(BeanContainer.Factory factory) {
this.factory = factory;
}
@Override
public InstanceHandle createInstance() throws InstantiationException {
BeanContainer.Instance instance = factory.create();
return new InstanceHandle() {
@Override
public T getInstance() {
return instance.get();
}
@Override
public void release() {
instance.close();
}
};
}
}