Class WeldBootstrapService

  • All Implemented Interfaces:
    org.jboss.msc.Service

    public class WeldBootstrapService
    extends Object
    implements org.jboss.msc.Service
    Provides the initial bootstrap of the Weld container. This does not actually finish starting the container, merely gets it to the point that the bean manager is available.
    Author:
    Stuart Douglas, Richard Opalka
    • Field Detail

      • SERVICE_NAME

        public static final org.jboss.msc.service.ServiceName SERVICE_NAME
        The service name that external services depend on
      • INTERNAL_SERVICE_NAME

        public static final org.jboss.msc.service.ServiceName INTERNAL_SERVICE_NAME
        The actual service name the bootstrap service is installed under.

        The reasons for this dual service name setup is kinda complex, and relates to https://issues.redhat.com/browse/JBEAP-18634 Because Weld cannot be restarted if an attempt is made to restart the service then we need to bail out and restart the whole deployment.

        If we just do a check in the start method that looks like: if (restartRequired) { doRestart(); return; } Then the service startup will technically complete successfully, and dependent services can still start before the restart actually takes effect (as MSC is directional, it keep starting services that have all their dependencies met before it start to take services down).

        To get around this we use two different service names, with the service that other services depend on only being installed at the end of the start() method. This means that in the case of a restart this will not be installed, so no dependent services will be started as they are missing their dependency.

    • Constructor Detail

      • WeldBootstrapService

        public WeldBootstrapService​(WeldDeployment deployment,
                                    org.jboss.weld.bootstrap.api.Environment environment,
                                    String deploymentName,
                                    Consumer<WeldBootstrapService> weldBootstrapServiceConsumer,
                                    Supplier<org.jboss.weld.manager.api.ExecutorServices> executorServicesSupplier,
                                    Supplier<ExecutorService> serverExecutorSupplier,
                                    Supplier<org.jboss.weld.security.spi.SecurityServices> securityServicesSupplier,
                                    Supplier<org.jboss.weld.transaction.spi.TransactionServices> weldTransactionServicesSupplier,
                                    org.jboss.msc.service.ServiceName deploymentServiceName,
                                    org.jboss.msc.service.ServiceName weldBootstrapServiceName)
    • Method Detail

      • start

        public void start​(org.jboss.msc.service.StartContext context)
        Starts the weld container
        Specified by:
        start in interface org.jboss.msc.Service
        Throws:
        IllegalStateException - if the container is already running
      • getBeanManager

        public org.jboss.weld.manager.BeanManagerImpl getBeanManager​(String beanArchiveId)
        Gets the BeanManager for a given bean deployment archive id.
        Throws:
        IllegalStateException - if the container is not running
        IllegalArgumentException - if the bean deployment archive id is not found
      • addWeldService

        public <T extends org.jboss.weld.bootstrap.api.Service> void addWeldService​(Class<T> type,
                                                                                    T service)
        Adds a Service to the deployment. This method must not be called after the container has started
      • getBeanManager

        public org.jboss.weld.manager.BeanManagerImpl getBeanManager()
        Gets the BeanManager linked to the root bean deployment archive. This BeanManager has access to all beans in a deployment
        Throws:
        IllegalStateException - if the container is not running
      • getBeanDeploymentArchives

        public Set<org.jboss.weld.bootstrap.spi.BeanDeploymentArchive> getBeanDeploymentArchives()
        get all beans deployment archives in the deployment
      • isStarted

        public boolean isStarted()