-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: fix EAR deployment failure when multiple WARs use multible CD…
…I-enabled library JARs
- Loading branch information
Showing
11 changed files
with
290 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,15 @@ | |
* only if the new code is made subject to such option by the copyright | ||
* holder. | ||
*/ | ||
// Portions Copyright [2024] [Payara Foundation and/or its affiliates] | ||
|
||
package org.glassfish.weld; | ||
|
||
import com.sun.enterprise.deployment.BundleDescriptor; | ||
import com.sun.enterprise.deployment.EjbDescriptor; | ||
import com.sun.enterprise.deployment.WebBundleDescriptor; | ||
import org.glassfish.api.invocation.InvocationManager; | ||
import org.glassfish.internal.api.Globals; | ||
import org.jboss.weld.Container; | ||
import org.jboss.weld.SimpleCDI; | ||
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive; | ||
|
@@ -54,7 +60,16 @@ | |
* @author <a href="mailto:[email protected]">JJ Snyder</a> | ||
*/ | ||
public class GlassFishWeldProvider implements CDIProvider { | ||
private static final WeldDeployer weldDeployer = Globals.get(WeldDeployer.class); | ||
private static final InvocationManager invocationManager = Globals.get(InvocationManager.class); | ||
|
||
private static class GlassFishEnhancedWeld extends SimpleCDI { | ||
GlassFishEnhancedWeld() { | ||
} | ||
|
||
GlassFishEnhancedWeld(String contextId) { | ||
super(contextId == null ? Container.instance() : Container.instance(contextId)); | ||
} | ||
|
||
@Override | ||
protected BeanManagerImpl unsatisfiedBeanManager(String callerClassName) { | ||
|
@@ -92,15 +107,30 @@ protected BeanManagerImpl unsatisfiedBeanManager(String callerClassName) { | |
|
||
@Override | ||
public CDI<Object> getCDI() { | ||
try { | ||
return new GlassFishEnhancedWeld(); | ||
} catch ( Throwable throwable ) { | ||
Throwable cause = throwable.getCause(); | ||
if ( cause instanceof IllegalStateException ) { | ||
return null; | ||
try { | ||
BundleDescriptor bundle = null; | ||
Object componentEnv = invocationManager.getCurrentInvocation().getJNDIEnvironment(); | ||
if( componentEnv instanceof EjbDescriptor) { | ||
bundle = (BundleDescriptor) | ||
((EjbDescriptor) componentEnv).getEjbBundleDescriptor(). | ||
getModuleDescriptor().getDescriptor(); | ||
|
||
} else if( componentEnv instanceof WebBundleDescriptor) { | ||
bundle = (BundleDescriptor) componentEnv; | ||
} | ||
|
||
BeanDeploymentArchive bda = weldDeployer.getBeanDeploymentArchiveForBundle(bundle); | ||
if (bda == null) { | ||
return new GlassFishEnhancedWeld(); | ||
} else { | ||
return new GlassFishEnhancedWeld(weldDeployer.getContextIdForArchive(bda)); | ||
} | ||
} catch ( Throwable throwable ) { | ||
Throwable cause = throwable.getCause(); | ||
if ( cause instanceof IllegalStateException ) { | ||
return null; | ||
} | ||
throw throwable; | ||
} | ||
throw throwable; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.