Skip to content

Commit

Permalink
split up services between filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
lprimak committed Nov 21, 2024
1 parent 8244abc commit a283717
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void initializeFromOriginal() {
this.weldBootstrap = context.getTransientAppMetaData(WELD_BOOTSTRAP, WeldBootstrap.class);
this.moduleClasses = getOriginal().moduleClasses;
this.beanClasses = getOriginal().beanClasses;
this.simpleServiceRegistry = getOriginal().simpleServiceRegistry;
getServices().addAll(getOriginal().getServices().entrySet());
this.moduleClassLoaderForBDA = getOriginal().moduleClassLoaderForBDA;
this.ejbDescImpls = new LinkedHashSet<>(getOriginal().ejbDescImpls);
if (this.itMap == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public DeploymentImpl(ReadableArchive archive,

this.context = currentDeploymentContext.get();
this.archiveFactory = currentDeployment.get().archiveFactory;
this.simpleServiceRegistry = currentDeployment.get().simpleServiceRegistry;
getServices().addAll(currentDeployment.get().getServices().entrySet());
this.injectionManager = currentDeployment.get().injectionManager;
this.logger = currentDeployment.get().logger;
this.deployedEjbs = currentDeployment.get().deployedEjbs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,39 +368,6 @@ public WeldApplicationContainer load(WeldContainer container, DeploymentContext

BundleDescriptor bundle = (webBundleDescriptor != null) ? webBundleDescriptor : ejbBundle;
if (bundle != null) {

if (!beanDeploymentArchive.getBeansXml().getBeanDiscoveryMode().equals(NONE)) {

// Register EE injection manager at the bean deployment archive level.
// We use the generic InjectionService service to handle all EE-style
// injection instead of the per-dependency-type InjectionPoint approach.
// Each InjectionServicesImpl instance knows its associated GlassFish bundle.

InjectionServices injectionServices = new InjectionServicesImpl(deploymentImpl.injectionManager, bundle, deploymentImpl);
if (logger.isLoggable(FINE)) {
logger.log(FINE, ADDING_INJECTION_SERVICES, new Object[] { injectionServices, beanDeploymentArchive.getId() });
}

beanDeploymentArchive.getServices().add(InjectionServices.class, injectionServices);
EEModuleDescriptor eeModuleDescriptor = getEEModuleDescriptor(beanDeploymentArchive);
if (eeModuleDescriptor != null) {
beanDeploymentArchive.getServices().add(EEModuleDescriptor.class, eeModuleDescriptor);
}

// Relevant in WAR BDA - WEB-INF/lib BDA scenarios
for (BeanDeploymentArchive subBda : beanDeploymentArchive.getBeanDeploymentArchives()) {
if (logger.isLoggable(FINE)) {
logger.log(FINE, ADDING_INJECTION_SERVICES, new Object[] { injectionServices, subBda.getId() });
}

subBda.getServices().add(InjectionServices.class, injectionServices);
eeModuleDescriptor = getEEModuleDescriptor(beanDeploymentArchive); // Should not be subBda?
if (eeModuleDescriptor != null) {
beanDeploymentArchive.getServices().add(EEModuleDescriptor.class, eeModuleDescriptor);
}
}
}

bundleToBeanDeploymentArchive.put(bundle, beanDeploymentArchive);
}
}
Expand Down Expand Up @@ -495,6 +462,47 @@ private WeldBootstrap ensureWeldBootstrapCreated(DeploymentContext context, Appl
return bootstrap;
}

private void registerServices(DeploymentImpl deploymentImpl) {
for (var entry : bundleToBeanDeploymentArchive.entrySet()) {
if (deploymentImpl.getBeanDeploymentArchives().contains(entry.getValue())) {
var bundle = entry.getKey();
var beanDeploymentArchive = deploymentImpl.getRootBDAs().iterator().next().moduleBda;

if (!beanDeploymentArchive.getBeansXml().getBeanDiscoveryMode().equals(NONE)) {

// Register EE injection manager at the bean deployment archive level.
// We use the generic InjectionService service to handle all EE-style
// injection instead of the per-dependency-type InjectionPoint approach.
// Each InjectionServicesImpl instance knows its associated GlassFish bundle.

InjectionServices injectionServices = new InjectionServicesImpl(deploymentImpl.injectionManager, bundle, deploymentImpl);
if (logger.isLoggable(FINE)) {
logger.log(FINE, ADDING_INJECTION_SERVICES, new Object[] { injectionServices, beanDeploymentArchive.getId() });
}

beanDeploymentArchive.getServices().add(InjectionServices.class, injectionServices);
EEModuleDescriptor eeModuleDescriptor = getEEModuleDescriptor(beanDeploymentArchive);
if (eeModuleDescriptor != null) {
beanDeploymentArchive.getServices().add(EEModuleDescriptor.class, eeModuleDescriptor);
}

// Relevant in WAR BDA - WEB-INF/lib BDA scenarios
for (BeanDeploymentArchive subBda : beanDeploymentArchive.getBeanDeploymentArchives()) {
if (logger.isLoggable(FINE)) {
logger.log(FINE, ADDING_INJECTION_SERVICES, new Object[] { injectionServices, subBda.getId() });
}

subBda.getServices().add(InjectionServices.class, injectionServices);
eeModuleDescriptor = getEEModuleDescriptor(beanDeploymentArchive); // Should not be subBda?
if (eeModuleDescriptor != null) {
beanDeploymentArchive.getServices().add(EEModuleDescriptor.class, eeModuleDescriptor);
}
}
}
}
}
}

private void processApplicationLoaded(ApplicationInfo applicationInfo) {
DeploymentImpl deploymentImpl = applicationInfo.getTransientAppMetaData(WELD_DEPLOYMENT, DeploymentImpl.class);
if (deploymentImpl == null) {
Expand Down Expand Up @@ -556,6 +564,7 @@ private void processApplicationLoaded(ApplicationInfo applicationInfo) {
}

private void completeDeployment(DeploymentImpl deploymentImpl) {
registerServices(deploymentImpl);
deploymentImpl.buildDeploymentGraph();

Set<BeanDeploymentArchive> archives = deploymentImpl.getBeanDeploymentArchives();
Expand Down

0 comments on commit a283717

Please sign in to comment.