org.jboss.weld.tck.CreationalContextsImpl Maven / Gradle / Ivy
package org.jboss.weld.tck;
import jakarta.enterprise.context.spi.Contextual;
import org.jboss.cdi.tck.spi.CreationalContexts;
import org.jboss.weld.contexts.CreationalContextImpl;
public class CreationalContextsImpl implements CreationalContexts {
@Override
public Inspectable create(Contextual contextual) {
return new InspectableCreationalContext<>(contextual);
}
static class InspectableCreationalContext extends CreationalContextImpl implements Inspectable {
private Object lastBeanPushed = null;
private boolean pushCalled = false;
private boolean releaseCalled = false;
public InspectableCreationalContext(Contextual contextual) {
super(contextual);
}
public void push(T incompleteInstance) {
pushCalled = true;
lastBeanPushed = incompleteInstance;
super.push(incompleteInstance);
}
public Object getLastBeanPushed() {
return lastBeanPushed;
}
public boolean isPushCalled() {
return pushCalled;
}
public boolean isReleaseCalled() {
return releaseCalled;
}
/**
* We need to override this method because internally, Weld uses this enhanced method to release CCs so long
* as the CC is instance of {@link org.jboss.weld.contexts.WeldCreationalContext} which will hold true for
* this impl as well.
*/
public void release(Contextual contextual, T instance) {
releaseCalled = true;
super.release(contextual, instance);
}
public void release() {
releaseCalled = true;
super.release();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy