org.jboss.weld.tck.ContextualsImpl Maven / Gradle / Ivy
package org.jboss.weld.tck;
import jakarta.enterprise.context.spi.Context;
import jakarta.enterprise.context.spi.CreationalContext;
import org.jboss.cdi.tck.spi.Contextuals;
public class ContextualsImpl implements Contextuals {
@Override
public Inspectable create(T instance, Context context) {
return new InspectableContextual<>(instance);
}
static class InspectableContextual implements Inspectable {
private final T instanceToReturn;
private CreationalContext createCC;
private T destroyInstance;
private CreationalContext destroyCC;
InspectableContextual(T instanceToReturn) {
this.instanceToReturn = instanceToReturn;
}
@Override
public T create(CreationalContext creationalContext) {
createCC = creationalContext;
return instanceToReturn;
}
@Override
public void destroy(T instance, CreationalContext creationalContext) {
destroyInstance = instance;
destroyCC = creationalContext;
}
@Override
public CreationalContext getCreationalContextPassedToCreate() {
return createCC;
}
@Override
public T getInstancePassedToDestroy() {
return destroyInstance;
}
@Override
public CreationalContext getCreationalContextPassedToDestroy() {
return destroyCC;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy