[jboss-cvs] JBossAS SVN: r84387 - projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 18 10:26:55 EST 2009
Author: alesj
Date: 2009-02-18 10:26:55 -0500 (Wed, 18 Feb 2009)
New Revision: 84387
Modified:
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java
Log:
Add web module name dependency.
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java 2009-02-18 15:15:40 UTC (rev 84386)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java 2009-02-18 15:26:55 UTC (rev 84387)
@@ -21,6 +21,8 @@
*/
package org.jboss.webbeans.integration.microcontainer.deployer.env;
+import java.util.List;
+
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
@@ -28,6 +30,7 @@
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
/**
* Deploy WebBeans boostrap service.
@@ -41,11 +44,16 @@
super(WebBeanDiscoveryEnvironment.class);
setTopLevelOnly(true);
setStage(DeploymentStages.PRE_REAL);
+ addInput(JBossWebMetaData.class);
addOutput(BeanMetaData.class);
}
public void deploy(DeploymentUnit unit, WebBeanDiscoveryEnvironment deployment) throws DeploymentException
{
+ JBossWebMetaData webMetaData = findWebMetaData(unit);
+ if (webMetaData == null)
+ return;
+
String unitName = unit.getName();
String envName = unitName + "_JBossWebBeanDiscovery";
@@ -60,8 +68,9 @@
bootstrap.addPropertyMetaData("ejbResolver", createEjbConnector("JBossEjbResolver", unit));
bootstrap.setCreate("initialize");
bootstrap.setStart("boot");
+ String webModuleName = getObjectName(webMetaData);
/*
- String webModuleName = ""; // TODO - get the web module name
+ // TODO - you need MC-Kernel snapshot for this
bootstrap.addDemand(webModuleName, ControllerState.CREATE, ControllerState.CREATE, null);
bootstrap.addDemand(webModuleName, ControllerState.START, ControllerState.START, null);
*/
@@ -83,4 +92,63 @@
builder.addPropertyMetaData("deploymentUnit", unit);
return builder.getBeanMetaData();
}
+
+ /**
+ * Find web metadata.
+ *
+ * @param unit the deployment unit
+ * @return web metadata or null if not found
+ */
+ protected JBossWebMetaData findWebMetaData(DeploymentUnit unit)
+ {
+ JBossWebMetaData webMetaData = unit.getAttachment(JBossWebMetaData.class);
+ if (webMetaData != null)
+ return webMetaData;
+
+ List<DeploymentUnit> components = unit.getComponents();
+ if (components != null && components.isEmpty() == false)
+ {
+ for (DeploymentUnit component : components)
+ {
+ JBossWebMetaData result = findWebMetaData(component);
+ if (result != null)
+ return result;
+ }
+ }
+
+ List<DeploymentUnit> children = unit.getChildren();
+ if (children != null && children.isEmpty() == false)
+ {
+ for (DeploymentUnit child : children)
+ {
+ JBossWebMetaData result = findWebMetaData(child);
+ if (result != null)
+ return result;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Get web module name.
+ *
+ * @param metaData the web metadata
+ * @return web module's name
+ */
+ protected String getObjectName(JBossWebMetaData metaData)
+ {
+ // Obtain the war virtual host and context root to define a unique war name
+ String virtualHost = "";
+ List<String> hosts = metaData.getVirtualHosts();
+ if (hosts != null && hosts.size() > 0)
+ {
+ virtualHost = hosts.get(0);
+ }
+ String ctxPath = metaData.getContextRoot();
+ // The ctx path value cannot be empty in the object name
+ if (ctxPath == null || ctxPath.length() == 0)
+ ctxPath = "/";
+ return "jboss.web.deployment:war=" + virtualHost + ctxPath;
+ }
}
More information about the jboss-cvs-commits
mailing list