Class AbstractWeldInitiator

  • All Implemented Interfaces:
    jakarta.enterprise.inject.Instance<Object>, jakarta.inject.Provider<Object>, Iterable<Object>, org.jboss.weld.environment.ContainerInstance

    public abstract class AbstractWeldInitiator
    extends Object
    implements jakarta.enterprise.inject.Instance<Object>, org.jboss.weld.environment.ContainerInstance
    Author:
    Matej Novotny
    • Field Detail

      • weld

        protected final org.jboss.weld.environment.se.Weld weld
      • beans

        protected final Set<jakarta.enterprise.inject.spi.Bean<?>> beans
      • extension

        protected final org.jboss.weld.junit.WeldCDIExtension extension
      • container

        protected volatile org.jboss.weld.environment.se.WeldContainer container
    • Constructor Detail

      • AbstractWeldInitiator

        protected AbstractWeldInitiator​(org.jboss.weld.environment.se.Weld weld,
                                        List<Object> instancesToInject,
                                        Set<Class<? extends Annotation>> scopesToActivate,
                                        Set<jakarta.enterprise.inject.spi.Bean<?>> beans,
                                        Map<String,​Object> resources,
                                        Function<jakarta.enterprise.inject.spi.InjectionPoint,​Object> ejbFactory,
                                        Function<jakarta.enterprise.inject.spi.InjectionPoint,​Object> persistenceUnitFactory,
                                        Function<jakarta.enterprise.inject.spi.InjectionPoint,​Object> persistenceContextFactory)
    • Method Detail

      • createWeld

        public static org.jboss.weld.environment.se.Weld createWeld()
        The returned Weld instance has:
        • automatic discovery disabled
        • concurrent deployment disabled
        Returns:
        a new Weld instance suitable for testing
      • injectNonContextual

        public AutoCloseable injectNonContextual​(Object target)
        Injects the given non-contextual instance immediately. The returned AutoCloseable should 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 AutoCloseable to release the creational context
      • get

        public Object get()
        Specified by:
        get in interface jakarta.inject.Provider<Object>
      • select

        public org.jboss.weld.inject.WeldInstance<Object> select​(Annotation... qualifiers)
        Specified by:
        select in interface jakarta.enterprise.inject.Instance<Object>
      • select

        public <U> org.jboss.weld.inject.WeldInstance<U> select​(Class<U> subtype,
                                                                Annotation... qualifiers)
        Specified by:
        select in interface jakarta.enterprise.inject.Instance<Object>
      • select

        public <U> org.jboss.weld.inject.WeldInstance<U> select​(jakarta.enterprise.util.TypeLiteral<U> subtype,
                                                                Annotation... qualifiers)
        Specified by:
        select in interface jakarta.enterprise.inject.Instance<Object>
      • isUnsatisfied

        public boolean isUnsatisfied()
        Specified by:
        isUnsatisfied in interface jakarta.enterprise.inject.Instance<Object>
      • isAmbiguous

        public boolean isAmbiguous()
        Specified by:
        isAmbiguous in interface jakarta.enterprise.inject.Instance<Object>
      • destroy

        public void destroy​(Object instance)
        Specified by:
        destroy in interface jakarta.enterprise.inject.Instance<Object>
      • event

        public jakarta.enterprise.event.Event<Object> event()
        Allows to fire events.
        Returns:
        an event object
      • getBeanManager

        public jakarta.enterprise.inject.spi.BeanManager getBeanManager()
        Specified by:
        getBeanManager in interface org.jboss.weld.environment.ContainerInstance
      • getId

        public String getId()
        Specified by:
        getId in interface org.jboss.weld.environment.ContainerInstance
      • shutdown

        public void shutdown()
        Note that any container-based operation will result in IllegalStateException after shutdown.
        Specified by:
        shutdown in interface org.jboss.weld.environment.ContainerInstance
      • isRunning

        public boolean isRunning()
        Returns:
        true if the container was initialized completely and is not shut down yet, false otherwise
      • container

        public org.jboss.weld.environment.se.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 org.jboss.weld.environment.se.WeldContainer initWeldContainer​(org.jboss.weld.environment.se.Weld weld)
      • shutdownWeldContainer

        protected void shutdownWeldContainer()