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 org.jboss.msc.service.ServiceName
INTERNAL_SERVICE_NAME
The actual service name the bootstrap service is installed under.static org.jboss.msc.service.ServiceName
SERVICE_NAME
The service name that external services depend on
-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends org.jboss.weld.bootstrap.api.Service>
voidaddWeldService(Class<T> type, T service)
Adds aService
to the deployment.Set<org.jboss.weld.bootstrap.spi.BeanDeploymentArchive>
getBeanDeploymentArchives()
get all beans deployment archives in the deploymentorg.jboss.weld.manager.BeanManagerImpl
getBeanManager()
Gets theBeanManager
linked to the root bean deployment archive.org.jboss.weld.manager.BeanManagerImpl
getBeanManager(String beanArchiveId)
Gets theBeanManager
for a given bean deployment archive id.boolean
isStarted()
void
start(org.jboss.msc.service.StartContext context)
Starts the weld containervoid
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)
.
-
-
-
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 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:
stop
in interfaceorg.jboss.msc.Service
-
getBeanManager
public org.jboss.weld.manager.BeanManagerImpl getBeanManager(String beanArchiveId)
Gets theBeanManager
for 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 aService
to the deployment. This method must not be called after the container has started
-
getBeanManager
public org.jboss.weld.manager.BeanManagerImpl getBeanManager()
Gets theBeanManager
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()
-
-