Class WeldBootstrapService
- All Implemented Interfaces:
org.jboss.msc.Service
- Author:
- Stuart Douglas, Richard Opalka
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.jboss.msc.service.ServiceNameThe actual service name the bootstrap service is installed under.static final org.jboss.msc.service.ServiceNameThe service name that external services depend onFields inherited from interface org.jboss.msc.Service
NULL -
Constructor Summary
ConstructorsConstructorDescriptionWeldBootstrapService(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 TypeMethodDescription<T extends org.jboss.weld.bootstrap.api.Service>
voidaddWeldService(Class<T> type, T service) Adds aServiceto the deployment.Set<org.jboss.weld.bootstrap.spi.BeanDeploymentArchive>get all beans deployment archives in the deploymentorg.jboss.weld.manager.BeanManagerImplGets theBeanManagerlinked to the root bean deployment archive.org.jboss.weld.manager.BeanManagerImplgetBeanManager(String beanArchiveId) Gets theBeanManagerfor a given bean deployment archive id.booleanvoidstart(org.jboss.msc.service.StartContext context) Starts the weld containervoidstop(org.jboss.msc.service.StopContext context) This is a no-op ifWeldStartService.start(StartContext)completes normally and the shutdown is performed inWeldStartService.stop(org.jboss.msc.service.StopContext).
-
Field Details
-
SERVICE_NAME
public static final org.jboss.msc.service.ServiceName SERVICE_NAMEThe service name that external services depend on -
INTERNAL_SERVICE_NAME
public static final org.jboss.msc.service.ServiceName INTERNAL_SERVICE_NAMEThe 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:
startin interfaceorg.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 ifWeldStartService.start(StartContext)completes normally and the shutdown is performed inWeldStartService.stop(org.jboss.msc.service.StopContext).- Specified by:
stopin interfaceorg.jboss.msc.Service
-
getBeanManager
Gets theBeanManagerfor a given bean deployment archive id.- Throws:
IllegalStateException- if the container is not runningIllegalArgumentException- 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 aServiceto the deployment. This method must not be called after the container has started -
getBeanManager
public org.jboss.weld.manager.BeanManagerImpl getBeanManager()Gets theBeanManagerlinked 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
get all beans deployment archives in the deployment -
isStarted
public boolean isStarted()
-