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 ClassesModifier and TypeClassDescriptionprotected static classAbstractWeldInitiator.AbstractBuilder<I extends AbstractWeldInitiator,T extends AbstractWeldInitiator.AbstractBuilder<I, T>> protected classNested classes/interfaces inherited from interface jakarta.enterprise.inject.Instance
Instance.Handle<T extends Object> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected WeldContainerprotected final org.jboss.weld.junit.WeldCDIExtensionprotected final List<AbstractWeldInitiator.ToInject>protected final Set<Class<? extends Annotation>>protected final Weld -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractWeldInitiator(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
Modifier and TypeMethodDescriptionThis method should be used when a Weld-specific API is needed.protected AbstractWeldInitiator.ToInjectcreateToInject(Object instanceToInject) static WeldThe returnedWeldinstance has: automatic discovery disabled concurrent deployment disabledvoidevent()Allows to fire events.get()getId()Iterable<? extends Instance.Handle<Object>>handles()protected WeldContainerinitWeldContainer(Weld weld) protected voidinjectNonContextual(Object target) Injects the given non-contextual instance immediately.booleanbooleanbooleaniterator()protected void<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 voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.enterprise.inject.Instance
handlesStream, isResolvable, streamMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
weld
-
instancesToInject
-
scopesToActivate
-
beans
-
extension
protected final org.jboss.weld.junit.WeldCDIExtension extension -
container
-
-
Constructor Details
-
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 Details
-
createWeld
The returnedWeldinstance has:- automatic discovery disabled
- concurrent deployment disabled
- Returns:
- a new
Weldinstance suitable for testing
-
createToInject
-
injectNonContextual
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
-
iterator
-
get
-
select
-
select
-
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>
-
destroy
-
getHandle
-
handles
-
event
Allows to fire events.- Returns:
- an event object
-
getBeanManager
- Specified by:
getBeanManagerin interfaceContainerInstance
-
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
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
-
shutdownWeldContainer
protected void shutdownWeldContainer()
-