[jboss-cvs] JBossAS SVN: r84376 - 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 06:31:10 EST 2009
Author: alesj
Date: 2009-02-18 06:31:10 -0500 (Wed, 18 Feb 2009)
New Revision: 84376
Added:
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java
Log:
Add bootstrap deployer.
Added: 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 (rev 0)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java 2009-02-18 11:31:10 UTC (rev 84376)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.webbeans.integration.microcontainer.deployer.env;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Deploy WebBeans boostrap service.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class WebBeansBootstrapDeployer extends AbstractSimpleRealDeployer<WebBeanDiscoveryEnvironment>
+{
+ public WebBeansBootstrapDeployer()
+ {
+ super(WebBeanDiscoveryEnvironment.class);
+ setTopLevelOnly(true);
+ setStage(DeploymentStages.PRE_REAL);
+ addOutput(BeanMetaData.class);
+ }
+
+ public void deploy(DeploymentUnit unit, WebBeanDiscoveryEnvironment deployment) throws DeploymentException
+ {
+ String unitName = unit.getName();
+
+ String envName = unitName + "_JBossWebBeanDiscovery";
+ BeanMetaDataBuilder envWrapper = BeanMetaDataBuilder.createBuilder(envName, "org.jboss.webbeans.integration.jbossas.bootstrap.JBossWebBeanDiscovery");
+ envWrapper.addConstructorParameter(WebBeanDiscoveryEnvironment.class.getName(), deployment);
+ unit.addAttachment(envName + "_" + BeanMetaData.class.getSimpleName(), envWrapper.getBeanMetaData());
+
+ String bootstrapName = unitName + "_WebBeansBootstrap";
+ BeanMetaDataBuilder bootstrap = BeanMetaDataBuilder.createBuilder(bootstrapName, "org.jboss.webbeans.bootstrap.WebBeansBootstrap");
+ bootstrap.addPropertyMetaData("webBeanDiscovery", bootstrap.createInject(envName));
+ bootstrap.addPropertyMetaData("ejbDiscovery", createEjbConnector("JBossEjbDiscovery", unit));
+ bootstrap.addPropertyMetaData("ejbResolver", createEjbConnector("JBossEjbResolver", unit));
+ bootstrap.setCreate("initialize");
+ bootstrap.setStart("boot");
+/*
+ String webModuleName = ""; // TODO - get the web module name
+ bootstrap.addDemand(webModuleName, ControllerState.CREATE, ControllerState.CREATE, null);
+ bootstrap.addDemand(webModuleName, ControllerState.START, ControllerState.START, null);
+*/
+ unit.addAttachment(bootstrapName + "_" + BeanMetaData.class.getSimpleName(), bootstrap.getBeanMetaData());
+ }
+
+ /**
+ * Create ejb connector.
+ *
+ * @param name the connector name
+ * @param unit the deployment unit
+ * @return new bean metadata
+ */
+ protected ValueMetaData createEjbConnector(String name, DeploymentUnit unit)
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(unit.getName() + "_" + name);
+ builder.setFactory(name);
+ builder.setFactoryMethod("createBean");
+ builder.addPropertyMetaData("deploymentUnit", unit);
+ return builder.getBeanMetaData();
+ }
+}
More information about the jboss-cvs-commits
mailing list