[jboss-cvs] JBossAS SVN: r72779 - in trunk/server/src/main/org/jboss/ejb: deployers and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 28 07:51:45 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-04-28 07:51:45 -0400 (Mon, 28 Apr 2008)
New Revision: 72779

Added:
   trunk/server/src/main/org/jboss/ejb/Ejb2xMCContainer.java
Modified:
   trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployer.java
Log:
Register the ejb2x container jndi supplies with the mc

Added: trunk/server/src/main/org/jboss/ejb/Ejb2xMCContainer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/Ejb2xMCContainer.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/ejb/Ejb2xMCContainer.java	2008-04-28 11:51:45 UTC (rev 72779)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb;
+
+/**
+ * An empty pojo class used to register the ejb2 container jndi name supplies
+ * with the mc. Will be expanded in the future.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class Ejb2xMCContainer
+{
+
+}

Modified: trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployer.java	2008-04-28 11:43:48 UTC (rev 72778)
+++ trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployer.java	2008-04-28 11:51:45 UTC (rev 72779)
@@ -25,6 +25,7 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.management.MalformedObjectNameException;
@@ -32,12 +33,20 @@
 
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
 import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.MappedReferenceMetaDataResolverDeployer;
+import org.jboss.deployment.dependency.ContainerDependencyMetaData;
+import org.jboss.ejb.Ejb2xMCContainer;
 import org.jboss.ejb.EjbModule;
 import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
 import org.jboss.kernel.spi.deployment.KernelDeployment;
@@ -89,7 +98,7 @@
       super(JBossMetaData.class);
       setOutput(ServiceMetaData.class);
       setOutput(EjbDeployment.class);
-      setOutput(AbstractKernelDeployment.class);
+      setOutput(KernelDeployment.class);
    }
 
    public String getTransactionManagerServiceName()
@@ -266,6 +275,13 @@
       Iterator<JBossEnterpriseBeanMetaData> beansIter = beans.iterator();
       HashSet<String> invokerNames = new HashSet<String>();
       HashSet<String> beanDepends = new HashSet<String>();
+      // Process ContainerDependencyMetaData
+      VFSDeploymentUnit topUnit = unit.getTopLevel();
+      Map<String, ContainerDependencyMetaData> endpoints = (Map<String, ContainerDependencyMetaData>) topUnit.getAttachment(MappedReferenceMetaDataResolverDeployer.ENDPOINT_MAP_KEY);
+      if(endpoints == null)
+         log.warn(unit+" has no ContainerDependencyMetaData attachment");
+      String vfsPath = unit.getRelativePath();
+      ArrayList<BeanMetaData> mcBeanMD = new ArrayList<BeanMetaData>();
       while( beansIter.hasNext() )
       {
          JBossEnterpriseBeanMetaData bmd = beansIter.next();
@@ -295,6 +311,34 @@
                dependencies.add(invoker);
             }
          }
+
+         // Create mc beans that declare the container ejb jndi name supplies
+         if(endpoints != null)
+         {
+            String ejbKey = "ejb/" + vfsPath + "#" + bmd.getEjbName();
+            ContainerDependencyMetaData cdmd = endpoints.get(ejbKey);
+            if(cdmd != null)
+            {
+               // Create the metadata for the bean to install
+               String mcname = ejbKey + ",uid"+System.identityHashCode(bmd);
+               BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(mcname, Ejb2xMCContainer.class.getName());
+               for(String jndiName : cdmd.getJndiNames())
+               {
+                  String supplyName = "jndi:" + jndiName;
+                  builder.addSupply(supplyName);
+               }
+
+               BeanMetaData mcbmd = builder.getBeanMetaData();
+               log.info("installing bean: " + mcname);
+               log.info("  with dependencies:");
+               log.info("  and supplies:");
+               for(SupplyMetaData smd : mcbmd.getSupplies())
+               {
+                  log.info("\t" + smd.getSupply());
+               }
+               mcBeanMD.add(mcbmd);
+            }
+         }
       }
 
       // Add any declared dependencies
@@ -319,14 +363,11 @@
       ejbModule.setDependencies(dependencies);
 
       unit.addAttachment("EjbServiceMetaData", ejbModule, ServiceMetaData.class);
-      
-      /*
+      // Create a kernel deployment for the module mc beans
       AbstractKernelDeployment akd = new AbstractKernelDeployment();
       akd.setName(ejbModule.getObjectName().getCanonicalName()+"Beans");
-      beanFactories.add(abmd);
-      akd.setBeanFactories(beanFactories);
+      akd.setBeans(mcBeanMD);
       unit.addAttachment(KernelDeployment.class, akd);
-      */
 
       // Pass the ejb callByValue setting
       if (callByValue)




More information about the jboss-cvs-commits mailing list