Package org.jboss.weld.junit
Class AbstractWeldInitiator
- java.lang.Object
-
- org.jboss.weld.junit.AbstractWeldInitiator
-
public abstract class AbstractWeldInitiator extends Object implements Instance<Object>, ContainerInstance
- Author:
- Matej Novotny
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractWeldInitiator.AbstractBuilder<I extends AbstractWeldInitiator,T extends AbstractWeldInitiator.AbstractBuilder<I,T>>protected classAbstractWeldInitiator.ToInject-
Nested classes/interfaces inherited from interface jakarta.enterprise.inject.Instance
Instance.Handle<T extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<Bean<?>>beansprotected WeldContainercontainerprotected org.jboss.weld.junit.WeldCDIExtensionextensionprotected List<AbstractWeldInitiator.ToInject>instancesToInjectprotected Set<Class<? extends Annotation>>scopesToActivateprotected Weldweld
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractWeldInitiator(Weld weld, List<Object> instancesToInject, Set<Class<? extends Annotation>> scopesToActivate, Set<Bean<?>> beans, Map<String,Object> resources, Function<InjectionPoint,Object> ejbFactory, Function<InjectionPoint,Object> persistenceUnitFactory, Function<InjectionPoint,Object> persistenceContextFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WeldContainercontainer()This method should be used when a Weld-specific API is needed.protected AbstractWeldInitiator.ToInjectcreateToInject(Object instanceToInject)static WeldcreateWeld()The returnedWeldinstance has: automatic discovery disabled concurrent deployment disabledvoiddestroy(Object instance)Event<Object>event()Allows to fire events.Objectget()BeanManagergetBeanManager()Instance.Handle<Object>getHandle()StringgetId()Iterable<? extends Instance.Handle<Object>>handles()protected WeldContainerinitWeldContainer(Weld weld)protected voidinjectInstances()AutoCloseableinjectNonContextual(Object target)Injects the given non-contextual instance immediately.booleanisAmbiguous()booleanisRunning()booleanisUnsatisfied()Iterator<Object>iterator()protected voidreleaseInstances()<U> org.jboss.weld.inject.WeldInstance<U>select(TypeLiteral<U> subtype, Annotation... qualifiers)org.jboss.weld.inject.WeldInstance<Object>select(Annotation... qualifiers)<U> org.jboss.weld.inject.WeldInstance<U>select(Class<U> subtype, Annotation... qualifiers)voidshutdown()Note that any container-based operation will result inIllegalStateExceptionafter shutdown.protected voidshutdownWeldContainer()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.enterprise.inject.Instance
handlesStream, isResolvable, stream
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
weld
protected final Weld weld
-
instancesToInject
protected final List<AbstractWeldInitiator.ToInject> instancesToInject
-
scopesToActivate
protected final Set<Class<? extends Annotation>> scopesToActivate
-
extension
protected final org.jboss.weld.junit.WeldCDIExtension extension
-
container
protected volatile WeldContainer container
-
-
Constructor Detail
-
AbstractWeldInitiator
protected AbstractWeldInitiator(Weld weld, List<Object> instancesToInject, Set<Class<? extends Annotation>> scopesToActivate, Set<Bean<?>> beans, Map<String,Object> resources, Function<InjectionPoint,Object> ejbFactory, Function<InjectionPoint,Object> persistenceUnitFactory, Function<InjectionPoint,Object> persistenceContextFactory)
-
-
Method Detail
-
createWeld
public static Weld createWeld()
The returnedWeldinstance has:- automatic discovery disabled
- concurrent deployment disabled
- Returns:
- a new
Weldinstance suitable for testing
-
createToInject
protected AbstractWeldInitiator.ToInject createToInject(Object instanceToInject)
-
injectNonContextual
public AutoCloseable injectNonContextual(Object target)
Injects the given non-contextual instance immediately. The returnedAutoCloseableshould be used to release the creational context once the injected beans are no longer needed.Example:
try (AutoCloseable contextReleaser = injectNonContextual(this)) { // do some things with the injected instances }- Parameters:
target- the target to inject- Returns:
- an
AutoCloseableto release the creational context
-
select
public org.jboss.weld.inject.WeldInstance<Object> select(Annotation... qualifiers)
-
select
public <U> org.jboss.weld.inject.WeldInstance<U> select(Class<U> subtype, Annotation... qualifiers)
-
select
public <U> org.jboss.weld.inject.WeldInstance<U> select(TypeLiteral<U> subtype, Annotation... qualifiers)
-
isUnsatisfied
public boolean isUnsatisfied()
- Specified by:
isUnsatisfiedin interfaceInstance<Object>
-
isAmbiguous
public boolean isAmbiguous()
- Specified by:
isAmbiguousin interfaceInstance<Object>
-
getHandle
public Instance.Handle<Object> getHandle()
-
handles
public Iterable<? extends Instance.Handle<Object>> handles()
-
getBeanManager
public BeanManager getBeanManager()
- Specified by:
getBeanManagerin interfaceContainerInstance
-
getId
public String getId()
- Specified by:
getIdin interfaceContainerInstance
-
shutdown
public void shutdown()
Note that any container-based operation will result inIllegalStateExceptionafter shutdown.- Specified by:
shutdownin interfaceContainerInstance
-
isRunning
public boolean isRunning()
- Returns:
trueif the container was initialized completely and is not shut down yet,falseotherwise
-
container
public WeldContainer container()
This method should be used when a Weld-specific API is needed.- Returns:
- the underlying container instance
-
injectInstances
protected void injectInstances()
-
releaseInstances
protected void releaseInstances()
-
initWeldContainer
protected WeldContainer initWeldContainer(Weld weld)
-
shutdownWeldContainer
protected void shutdownWeldContainer()
-
-