[jboss-cvs] JBossAS SVN: r104542 - projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 6 20:00:35 EDT 2010


Author: marius.bogoevici
Date: 2010-05-06 20:00:34 -0400 (Thu, 06 May 2010)
New Revision: 104542

Modified:
   projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/SimpleCompJndiBinder.java
   projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/WebJndiBinderDeployer.java
Log:
WELDINT-19 fix: BeanManager is correctly registered for a WAR in an EAR

Modified: projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/SimpleCompJndiBinder.java
===================================================================
--- projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/SimpleCompJndiBinder.java	2010-05-06 21:57:36 UTC (rev 104541)
+++ projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/SimpleCompJndiBinder.java	2010-05-07 00:00:34 UTC (rev 104542)
@@ -25,22 +25,38 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
 /**
  * @author Marius Bogoevici
  */
 public class SimpleCompJndiBinder extends JavaCompJndiBinder
 {
-   public SimpleCompJndiBinder(String deploymentUnitName)
+   private DeploymentUnit deploymentUnit;
+
+   public SimpleCompJndiBinder(DeploymentUnit deploymentUnit)
    {
-      super(deploymentUnitName);
+      super(deploymentUnit.getName());
+      this.deploymentUnit = deploymentUnit;
    }
 
    @Override
    protected Context getJavaCompContext() throws NamingException
    {
-      return ((Context) new InitialContext().lookup("java:comp"));
+      ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         Thread.currentThread().setContextClassLoader(deploymentUnit.getClassLoader());
+         return ((Context) new InitialContext().lookup("java:comp"));
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(originalClassLoader);
+         this.deploymentUnit = null;
+      }
    }
 
+
    @Override
    protected String getJavaContextDescription()
    {

Modified: projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/WebJndiBinderDeployer.java
===================================================================
--- projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/WebJndiBinderDeployer.java	2010-05-06 21:57:36 UTC (rev 104541)
+++ projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/WebJndiBinderDeployer.java	2010-05-07 00:00:34 UTC (rev 104542)
@@ -54,9 +54,10 @@
       if (bbBMD != null && informer.getModuleType(deploymentUnit).equals(JavaEEModuleInformer.ModuleType.WEB))
       {
          BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(deploymentUnit.getName() + "_WebCompJndiBinder", SimpleCompJndiBinder.class.getName());
-         builder.addConstructorParameter(String.class.getName(), deploymentUnit.getName());
+         builder.addConstructorParameter(DeploymentUnit.class.getName(), deploymentUnit);
          builder.addInstall("bindToJavaComp");
-         builder.addUninstall("unbind");
+         // no uninstall method for SimpleCompJndiBinder (context will be destroyed by Tomcat)
+         //builder.addUninstall("unbind");
          deploymentUnit.getTopLevel().addAttachment(deploymentUnit.getName() + "_WebCompJndiBinder", builder.getBeanMetaData());
 
          BeanMetaDataBuilder moduleBinderBuilder = BeanMetaDataBuilder.createBuilder(deploymentUnit.getName() + "_JavaModuleJndiBinder", JavaEEModuleJndiBinder.class.getName());




More information about the jboss-cvs-commits mailing list