Skip to content

Commit

Permalink
Merge pull request #6664 from jGauravGupta/FISH-8309
Browse files Browse the repository at this point in the history
FISH-8309 Persistence Context is NULL on CDI Injected beans into MDB
  • Loading branch information
jGauravGupta authored May 13, 2024
2 parents 3afdc5b + ffd0e6c commit 1e0a33e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2024] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.deployment;

Expand Down Expand Up @@ -603,6 +603,14 @@ public void print(StringBuilder toStringBuilder) {
*/
@Override
public abstract ArchiveType getModuleType();

/**
* Processes the bundle descriptor.
* This method should be overridden in subclasses to provide specific processing logic
* for the bundle descriptor.
*/
public void processBundleDescriptor() {
}

/**
* @return the visitor for this bundle descriptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2020-2021] [Payara Foundation and/or its affiliates.]
// Portions Copyright [2020-2024] [Payara Foundation and/or its affiliates.]

package com.sun.enterprise.deployment.archivist;

Expand Down Expand Up @@ -375,6 +375,7 @@ public void postRuntimeDDsRead(T descriptor,
*/
protected void postOpen(T descriptor, ReadableArchive archive)
throws IOException {
descriptor.processBundleDescriptor();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2024] [Payara Foundation and/or its affiliates]

package org.glassfish.ejb.deployment.descriptor;

Expand Down Expand Up @@ -355,6 +355,16 @@ public Collection<Long> getDescriptorIds() {
return ejbIDs;
}

/**
* Processes the bundle descriptor by invoking the processing of each EjbDescriptor.
* It is assumed that the ejbs collection is already populated with EjbDescriptor instances.
*/
public void processBundleDescriptor() {
for (EjbDescriptor ejbDescriptor : ejbs) {
ejbDescriptor.processDescriptor();
}
}

public void addEjb(EjbDescriptor ejbDescriptor) {
ejbDescriptor.setEjbBundleDescriptor(this);
ejbs.add(ejbDescriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2019-2021] [Payara Foundation and/or its affiliates]
// Portions Copyright [2019-2024] [Payara Foundation and/or its affiliates]

package org.glassfish.ejb.deployment.descriptor;

Expand Down Expand Up @@ -2373,6 +2373,47 @@ public void setEjbBundleDescriptor(EjbBundleDescriptorImpl bundleDescriptor) {
this.bundleDescriptor = bundleDescriptor;
}

/**
* Processes the descriptor by adding various descriptors and properties
* from the root bundle descriptor.
* It is expected that the bundle descriptor is already set before calling this method.
*/
public void processDescriptor() {
if (this.bundleDescriptor != null) {
for (Object ejbRefObj : this.bundleDescriptor.getEjbReferenceDescriptors()) {
addEjbReferenceDescriptor((EjbReference) ejbRefObj);
}

for (Object msgDestRefObj : this.bundleDescriptor.getMessageDestinationReferenceDescriptors()) {
addMessageDestinationReferenceDescriptor((MessageDestinationReferenceDescriptor) msgDestRefObj);
}

for (Object envPropObj : this.bundleDescriptor.getEnvironmentProperties()) {
addOrMergeEnvironmentProperty((EnvironmentProperty) envPropObj);
}

for (Object servRefObj : this.bundleDescriptor.getServiceReferenceDescriptors()) {
addServiceReferenceDescriptor((ServiceReferenceDescriptor) servRefObj);
}

for (Object resRefObj : this.bundleDescriptor.getResourceReferenceDescriptors()) {
addResourceReferenceDescriptor((ResourceReferenceDescriptor) resRefObj);
}

for (Object resourceEnvRefObj : this.bundleDescriptor.getResourceEnvReferenceDescriptors()) {
addResourceEnvReferenceDescriptor((ResourceEnvReferenceDescriptor) resourceEnvRefObj);
}

for (EntityManagerFactoryReferenceDescriptor entMgrFacRef : this.bundleDescriptor.getEntityManagerFactoryReferenceDescriptors()) {
addEntityManagerFactoryReferenceDescriptor(entMgrFacRef);
}

for (EntityManagerReferenceDescriptor entMgrRef : this.bundleDescriptor.getEntityManagerReferenceDescriptors()) {
addEntityManagerReferenceDescriptor(entMgrRef);
}
}
}

/**
* Called by WebArchivist to notify this EjbDescriptor that it has been associated with a web bundle.
*
Expand Down

0 comments on commit 1e0a33e

Please sign in to comment.