Class WeldBootstrapService

java.lang.Object
org.jboss.as.weld.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 Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.jboss.msc.service.ServiceName
    The actual service name the bootstrap service is installed under.
    static final org.jboss.msc.service.ServiceName
    The service name that external services depend on

    Fields inherited from interface org.jboss.msc.Service

    NULL
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 Summary

    Modifier and Type
    Method
    Description
    <T extends org.jboss.weld.bootstrap.api.Service>
    void
    addWeldService(Class<T> type, T service)
    Adds a Service to the deployment.
    Set<org.jboss.weld.bootstrap.spi.BeanDeploymentArchive>
    get all beans deployment archives in the deployment
    org.jboss.weld.manager.BeanManagerImpl
    Gets the BeanManager linked to the root bean deployment archive.
    org.jboss.weld.manager.BeanManagerImpl
    getBeanManager(String beanArchiveId)
    Gets the BeanManager for a given bean deployment archive id.
    boolean
     
    void
    start(org.jboss.msc.service.StartContext context)
    Starts the weld container
    void
    stop(org.jboss.msc.service.StopContext context)
    This is a no-op if WeldStartService.start(StartContext) completes normally and the shutdown is performed in WeldStartService.stop(org.jboss.msc.service.StopContext).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 Details

    • 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 Details

    • 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
    • stop

      public void stop(org.jboss.msc.service.StopContext context)
      This is a no-op if WeldStartService.start(StartContext) completes normally and the shutdown is performed in WeldStartService.stop(org.jboss.msc.service.StopContext).
      Specified by:
      stop in interface org.jboss.msc.Service
    • 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()