[jboss-cvs] JBossAS SVN: r91674 - in projects/webbeans-ri-int/trunk/deployer/src: main/java/org/jboss/webbeans/integration/deployer/env and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jul 27 10:41:48 EDT 2009
Author: alesj
Date: 2009-07-27 10:41:47 -0400 (Mon, 27 Jul 2009)
New Revision: 91674
Added:
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/AbstractDeploymentDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/AbstractServicesConnectorDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/BootstrapInfo.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DeploymentArchiveAdapter.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DeploymentUnitBeanDeploymentArchive.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/EjbServicesDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/EmptyBeanDeploymentArchive.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/FlatDeployment.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/FlatDeploymentDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossBeanDeploymentArchive.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/SecurityActions.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/StructureDeployment.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/StructureDeploymentDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/URLBeanDeploymentArchive.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/VirtualFileBeanDeploymentArchive.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WBEnvBeanDeploymentArchive.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentTestCase.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/StructureDeploymentTestCase.java
projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/deployers/test/FlatDeploymentTestCase.xml
projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/deployers/test/StructureDeploymentTestCase.xml
Removed:
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossBeanDeploymentArchive.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossDeployment.java
Modified:
projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/metadata/WebBeansFilesDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/VFSTestSuite.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/support/MockEjbServices.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/AbstractWebBeansTest.java
Log:
[WBINT-19]; initial impl of structure Deployment.
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml 2009-07-27 12:57:46 UTC (rev 91673)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml 2009-07-27 14:41:47 UTC (rev 91674)
@@ -13,6 +13,12 @@
<!-- Responsible for discovering Web Bean classes -->
<bean name="WebBeansDiscoveryDeployer" class="org.jboss.webbeans.integration.deployer.env.WebBeanDiscoveryDeployer"/>
+ <!-- Ejb Services deployer -->
+ <bean name="FlatDeploymentDeployer" class="org.jboss.webbeans.integration.deployer.env.EjbServicesDeployer"/>
+
+ <!-- Creates Flat Deployment -->
+ <bean name="FlatDeploymentDeployer" class="org.jboss.webbeans.integration.deployer.env.FlatDeploymentDeployer"/>
+
<!-- Responsible for dynamic ejb dependency creation -->
<bean name="DynamicDependencyCreator" class="org.jboss.webbeans.integration.deployer.env.DynamicDependencyCreator">
<constructor>
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/AbstractDeploymentDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/AbstractDeploymentDeployer.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/AbstractDeploymentDeployer.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,78 @@
+/*
+ * 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.deployer.env;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+
+/**
+ * Create Deployment.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class AbstractDeploymentDeployer extends AbstractServicesConnectorDeployer
+{
+ public AbstractDeploymentDeployer()
+ {
+ super(true);
+ setDisableOptional(true);
+ addInput(BootstrapInfo.EJB_SERVICES);
+ addOutput(BootstrapInfo.DEPLOYMENT);
+ }
+
+ public void deploy(DeploymentUnit unit, BootstrapInfo info) throws DeploymentException
+ {
+ if (info.getEjbServices() == null)
+ throw new DeploymentException("Missing ejb services value: " + unit);
+
+ if (isRelevant(unit) == false)
+ return;
+
+ String unitName = unit.getName();
+ String deploymentName = unitName + "_JBossDeployment";
+
+ BeanMetaData deploymentBMD = deploy(unit, info, deploymentName);
+ unit.addAttachment(deploymentName, deploymentBMD, BeanMetaData.class);
+ }
+
+ /**
+ * Is this deployer relevant.
+ *
+ * @param unit the deployment unit
+ * @return true if relevant, false otherwise
+ */
+ protected boolean isRelevant(DeploymentUnit unit)
+ {
+ return true;
+ }
+
+ /**
+ * Deploy.
+ *
+ * @param unit the deployment unit
+ * @param info the bootstrap info
+ * @param deploymentName the deployment name
+ * @return deployment's bean metadata
+ */
+ protected abstract BeanMetaData deploy(DeploymentUnit unit, BootstrapInfo info, String deploymentName);
+}
\ No newline at end of file
Copied: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/AbstractServicesConnectorDeployer.java (from rev 91411, projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java)
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/AbstractServicesConnectorDeployer.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/AbstractServicesConnectorDeployer.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,65 @@
+/*
+ * 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.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.deployer.helpers.AbstractOptionalRealDeployer;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Abstract services connector deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class AbstractServicesConnectorDeployer extends AbstractOptionalRealDeployer<BootstrapInfo>
+{
+ protected AbstractServicesConnectorDeployer(boolean isPassThroughBootstrapInfo)
+ {
+ super(BootstrapInfo.class);
+ setStage(DeploymentStages.PRE_REAL);
+ setTopLevelOnly(true);
+ if (isPassThroughBootstrapInfo)
+ addOutput(BootstrapInfo.class);
+ }
+
+ /**
+ * Create service connector.
+ *
+ * @param name the connector name
+ * @param bean the bean to create
+ * @param unit the deployment unit
+ * @return new inject metadata
+ */
+ protected ValueMetaData createServiceConnector(String name, String bean, DeploymentUnit unit)
+ {
+ String beanName = unit.getName() + "_" + name;
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(beanName, bean);
+ builder.setFactory(name);
+ builder.setFactoryMethod("createBean");
+ builder.addPropertyMetaData("deploymentUnit", unit);
+ unit.addAttachment(beanName + "_" + BeanMetaData.class.getSimpleName(), builder.getBeanMetaData());
+ return builder.createInject(beanName);
+ }
+}
\ No newline at end of file
Copied: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/BootstrapInfo.java (from rev 91411, projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java)
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/BootstrapInfo.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/BootstrapInfo.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,59 @@
+/*
+ * 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.deployer.env;
+
+import org.jboss.beans.metadata.spi.ValueMetaData;
+
+/**
+ * Simple bootstrap info class, used as attachment key.
+ * Holds inject values for deployment and various services.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class BootstrapInfo
+{
+ private ValueMetaData ejbServices;
+ public static final String EJB_SERVICES = BootstrapInfo.class.getSimpleName() + "EJB_SERVICES";
+
+ private ValueMetaData deployment;
+ public static final String DEPLOYMENT = BootstrapInfo.class.getSimpleName() + "DEPLOYMENT";
+
+ public ValueMetaData getDeployment()
+ {
+ return deployment;
+ }
+
+ public void setDeployment(ValueMetaData deployment)
+ {
+ this.deployment = deployment;
+ }
+
+ public ValueMetaData getEjbServices()
+ {
+ return ejbServices;
+ }
+
+ public void setEjbServices(ValueMetaData ejbServices)
+ {
+ this.ejbServices = ejbServices;
+ }
+}
\ No newline at end of file
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DeploymentArchiveAdapter.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DeploymentArchiveAdapter.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DeploymentArchiveAdapter.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,190 @@
+/*
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.net.URL;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.integration.deployer.DeployersUtils;
+
+/**
+ * Deployment archive adapter.
+ *
+ * @author Ales Justin
+ */
+public abstract class DeploymentArchiveAdapter
+{
+ protected VFSDeploymentUnit unit;
+ protected Module module;
+ private List<JBossBeanDeploymentArchive> archives;
+
+ public DeploymentArchiveAdapter(VFSDeploymentUnit unit)
+ {
+ this.unit = unit;
+ // find module
+ module = unit.getAttachment(Module.class);
+ if (module == null)
+ {
+ VFSDeploymentUnit parent = unit.getParent();
+ while (parent != null && module == null)
+ {
+ module = parent.getAttachment(Module.class);
+ parent = parent.getParent();
+ }
+ if (module == null)
+ throw new RuntimeException("No module in deployment unit's hierarchy: " + unit.getName());
+ }
+ }
+
+ /**
+ * Validate deployment unit.
+ *
+ * @param unit the unit
+ * @return same unit
+ */
+ protected static VFSDeploymentUnit checkDeploymentUnit(VFSDeploymentUnit unit)
+ {
+ if (unit == null)
+ throw new IllegalArgumentException("Null deployment unit");
+
+ return unit;
+ }
+
+ protected void buildDeploymentArchives()
+ {
+ List<JBossBeanDeploymentArchive> temp = new ArrayList<JBossBeanDeploymentArchive>();
+
+ JBossBeanDeploymentArchive rootBDA = null;
+
+ // handle war slightly different
+ VirtualFile warWbXml = unit.getFile("WEB-INF/beans.xml");
+ VirtualFile classes = null;
+ if (warWbXml != null)
+ {
+ classes = unit.getFile("WEB-INF/classes");
+ rootBDA = new VirtualFileBeanDeploymentArchive(module, classes, warWbXml);
+ }
+
+ @SuppressWarnings("unchecked")
+ Collection<VirtualFile> cpFiles = unit.getAttachment(DeployersUtils.WEB_BEANS_CLASSPATH, Collection.class);
+
+ VirtualFile root = unit.getRoot();
+ for (VirtualFile cpRoot : cpFiles)
+ {
+ if (classes == null || classes.equals(cpRoot) == false)
+ {
+ JBossBeanDeploymentArchive bda = new VirtualFileBeanDeploymentArchive(module, cpRoot, getChild(cpRoot, "META-INF/beans.xml"));
+ if (rootBDA == null && cpRoot.equals(root))
+ rootBDA = bda;
+ else
+ temp.add(bda);
+ }
+ }
+
+ if (rootBDA != null)
+ applyRootDeploymentArchive(rootBDA, temp);
+
+ List<VFSDeploymentUnit> children = unit.getVFSChildren();
+ if (children != null && children.isEmpty() == false)
+ {
+ for (VFSDeploymentUnit child : children)
+ {
+ temp.add(new DeploymentUnitBeanDeploymentArchive(child));
+ }
+ }
+
+ archives = temp;
+ }
+
+ /**
+ * Apply root bean deployment archive.
+ * e.g. Deployment should add it to temps,
+ * where DU based BDA should use it as a delegate.
+ *
+ * @param root the root BDA
+ * @param temps current BDA temps
+ */
+ protected abstract void applyRootDeploymentArchive(JBossBeanDeploymentArchive root, List<JBossBeanDeploymentArchive> temps);
+
+ /**
+ * Get child.
+ * Throws RE instead of IOE.
+ *
+ * @param file the file
+ * @param path the path
+ * @return child
+ */
+ static VirtualFile getChild(VirtualFile file, String path)
+ {
+ try
+ {
+ return file.getChild(path);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Get file's url.
+ * Throws RE instead of IOE.
+ *
+ * @param file the file
+ * @return file's url
+ */
+ static URL toURL(VirtualFile file)
+ {
+ try
+ {
+ return file.toURL();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Get modificable jboss bdas.
+ *
+ * @return the archives
+ */
+ protected List<JBossBeanDeploymentArchive> getJBossBeanDeploymentArchives()
+ {
+ if (archives == null)
+ buildDeploymentArchives();
+
+ return archives;
+ }
+
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ if (archives == null)
+ buildDeploymentArchives();
+
+ return Collections.<BeanDeploymentArchive>unmodifiableList(archives);
+ }
+}
\ No newline at end of file
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DeploymentUnitBeanDeploymentArchive.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DeploymentUnitBeanDeploymentArchive.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DeploymentUnitBeanDeploymentArchive.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.net.URL;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+
+/**
+ * BDA per DU.
+ *
+ * @author Ales Justin
+ */
+public class DeploymentUnitBeanDeploymentArchive extends DeploymentArchiveAdapter implements JBossBeanDeploymentArchive
+{
+ private final AtomicBoolean initialized = new AtomicBoolean(false);
+ private JBossBeanDeploymentArchive root = EmptyBeanDeploymentArchive.INSTANCE;
+
+ public DeploymentUnitBeanDeploymentArchive(VFSDeploymentUnit unit)
+ {
+ super(checkDeploymentUnit(unit));
+ }
+
+ protected void applyRootDeploymentArchive(JBossBeanDeploymentArchive root, List<JBossBeanDeploymentArchive> temps)
+ {
+ this.root = root;
+ }
+
+ private void init()
+ {
+ if (initialized.get() == false)
+ {
+ synchronized (initialized)
+ {
+ if (initialized.get() == false)
+ buildDeploymentArchives();
+ initialized.set(true);
+ }
+ }
+ }
+
+ public BeanDeploymentArchive match(URL codeSourceUrl)
+ {
+ init();
+
+ VirtualFile rootFile = unit.getRoot();
+ if (codeSourceUrl.equals(toURL(rootFile)))
+ return root;
+
+ for (JBossBeanDeploymentArchive jbda : getJBossBeanDeploymentArchives())
+ {
+ BeanDeploymentArchive bda = jbda.match(codeSourceUrl);
+ if (bda != null)
+ return bda;
+ }
+
+ return null;
+ }
+
+ public Iterable<Class<?>> getBeanClasses()
+ {
+ init();
+ return root.getBeanClasses();
+ }
+
+ public Iterable<URL> getBeansXml()
+ {
+ init();
+ return root.getBeansXml();
+ }
+
+ public Iterable<EjbDescriptor<?>> getEjbs()
+ {
+ init();
+ return root.getEjbs();
+ }
+}
\ No newline at end of file
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/EjbServicesDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/EjbServicesDeployer.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/EjbServicesDeployer.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,66 @@
+/*
+ * 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.deployer.env;
+
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Create ejb services
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class EjbServicesDeployer extends AbstractServicesConnectorDeployer
+{
+ /** The ejb services class name */
+ private String ejbServicesClassName = "org.jboss.webbeans.integration.ejb.JBossEjbServices";
+
+ public EjbServicesDeployer()
+ {
+ super(true);
+ addOutput(BootstrapInfo.EJB_SERVICES);
+ }
+
+ public void deploy(DeploymentUnit unit, BootstrapInfo info) throws DeploymentException
+ {
+ ValueMetaData ejbServicesValue = createServiceConnector("JBossEjbServices", ejbServicesClassName, unit);
+
+ if (info == null)
+ {
+ info = new BootstrapInfo();
+ // add bootstrap info
+ unit.addAttachment(BootstrapInfo.class, info);
+ }
+ info.setEjbServices(ejbServicesValue);
+ }
+
+ /**
+ * Set ejb services class name.
+ *
+ * @param ejbServicesClassName the ejb services classname
+ */
+ public void setEjbServicesClassName(String ejbServicesClassName)
+ {
+ this.ejbServicesClassName = ejbServicesClassName;
+ }
+}
\ No newline at end of file
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/EmptyBeanDeploymentArchive.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/EmptyBeanDeploymentArchive.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/EmptyBeanDeploymentArchive.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+
+/**
+ * Empty BDA.
+ *
+ * @author Ales Justin
+ */
+public class EmptyBeanDeploymentArchive implements JBossBeanDeploymentArchive
+{
+ public static final JBossBeanDeploymentArchive INSTANCE = new EmptyBeanDeploymentArchive();
+
+ public BeanDeploymentArchive match(URL codeSourceUrl)
+ {
+ return null;
+ }
+
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return Collections.emptyList();
+ }
+
+ public Iterable<Class<?>> getBeanClasses()
+ {
+ return Collections.emptySet();
+ }
+
+ public Iterable<URL> getBeansXml()
+ {
+ return Collections.emptySet();
+ }
+
+ public Iterable<EjbDescriptor<?>> getEjbs()
+ {
+ return Collections.emptySet();
+ }
+}
\ No newline at end of file
Copied: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/FlatDeployment.java (from rev 91411, projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossDeployment.java)
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/FlatDeployment.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/FlatDeployment.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.bootstrap.spi.Deployment;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+
+/**
+ * Initial (naive) implementation of Deployment for JBoss AS.
+ *
+ * This version simply flattens the entire deployment into a single
+ * BeanDeploymentArchive
+ *
+ * @author pmuir
+ * @author Ales Justin
+ */
+public class FlatDeployment implements Deployment
+{
+ private final BeanDeploymentArchive beanDeploymentArchive;
+ private final List<BeanDeploymentArchive> beanDeploymentArchives;
+
+ public FlatDeployment(WebBeanDiscoveryEnvironment environment, Iterable<EjbDescriptor<?>> ejbDescriptors)
+ {
+ this.beanDeploymentArchive = new WBEnvBeanDeploymentArchive(environment, ejbDescriptors);
+ this.beanDeploymentArchives = Collections.singletonList(beanDeploymentArchive);
+ }
+
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return beanDeploymentArchives;
+ }
+
+ public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
+ {
+ return beanDeploymentArchive;
+ }
+}
\ No newline at end of file
Property changes on: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/FlatDeployment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/FlatDeploymentDeployer.java (from rev 91411, projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeanDiscoveryDeployer.java)
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/FlatDeploymentDeployer.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/FlatDeploymentDeployer.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,55 @@
+/*
+ * 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.deployer.env;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Create flat Deployment from WB discovery env.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class FlatDeploymentDeployer extends AbstractDeploymentDeployer
+{
+ public FlatDeploymentDeployer()
+ {
+ super();
+ addInput(WebBeanDiscoveryEnvironment.class);
+ }
+
+ @Override
+ protected boolean isRelevant(DeploymentUnit unit)
+ {
+ return unit.isAttachmentPresent(WebBeanDiscoveryEnvironment.class);
+ }
+
+ protected BeanMetaData deploy(DeploymentUnit unit, BootstrapInfo info, String deploymentName)
+ {
+ WebBeanDiscoveryEnvironment env = unit.getAttachment(WebBeanDiscoveryEnvironment.class);
+ BeanMetaDataBuilder deploymentWrapper = BeanMetaDataBuilder.createBuilder(deploymentName, FlatDeployment.class.getName());
+ deploymentWrapper.addConstructorParameter(WebBeanDiscoveryEnvironment.class.getName(), env);
+ deploymentWrapper.addConstructorParameter(Iterable.class.getName(), deploymentWrapper.createInject(info.getEjbServices().getUnderlyingValue(), "ejbs"));
+ return deploymentWrapper.getBeanMetaData();
+ }
+}
\ No newline at end of file
Deleted: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossBeanDeploymentArchive.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossBeanDeploymentArchive.java 2009-07-27 12:57:46 UTC (rev 91673)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossBeanDeploymentArchive.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -1,43 +0,0 @@
-package org.jboss.webbeans.integration.deployer.env;
-
-import java.net.URL;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.webbeans.ejb.spi.EjbDescriptor;
-
-public class JBossBeanDeploymentArchive implements BeanDeploymentArchive
-{
-
- private final WebBeanDiscoveryEnvironment environment;
-
- private final Iterable<EjbDescriptor<?>> ejbDescriptors;
-
- public JBossBeanDeploymentArchive(WebBeanDiscoveryEnvironment environment, Iterable<EjbDescriptor<?>> ejbDescriptors)
- {
- this.environment = environment;
- this.ejbDescriptors = ejbDescriptors;
- }
-
- public Iterable<Class<?>> getBeanClasses()
- {
- return environment.getWebBeanClasses();
- }
-
- public List<BeanDeploymentArchive> getBeanDeploymentArchives()
- {
- return Collections.emptyList();
- }
-
- public Iterable<URL> getBeansXml()
- {
- return environment.getWebBeansXml();
- }
-
- public Iterable<EjbDescriptor<?>> getEjbs()
- {
- return ejbDescriptors;
- }
-
-}
\ No newline at end of file
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossBeanDeploymentArchive.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossBeanDeploymentArchive.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossBeanDeploymentArchive.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.net.URL;
+
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * JBoss BDA, knows how to match class.
+ * Class == Module + class name.
+ */
+public interface JBossBeanDeploymentArchive extends BeanDeploymentArchive
+{
+ /**
+ * Find bean deployment archive that matches.
+ *
+ * @param codeSourceUrl the url of the class's code source location
+ * @return matching bda or null if no match
+ */
+ BeanDeploymentArchive match(URL codeSourceUrl);
+}
\ No newline at end of file
Deleted: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossDeployment.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossDeployment.java 2009-07-27 12:57:46 UTC (rev 91673)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossDeployment.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -1,58 +0,0 @@
-/*
- * 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.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.integration.deployer.env;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.webbeans.bootstrap.spi.Deployment;
-import org.jboss.webbeans.ejb.spi.EjbDescriptor;
-
-/**
- * Initial (naive) implementation of Deployment for JBoss AS.
- *
- * This version simply flattens the entire deployment into a single
- * BeanDeploymentArchive
- *
- * @author pmuir
- *
- */
-public class JBossDeployment implements Deployment
-{
-
- private final BeanDeploymentArchive beanDeploymentArchive;
- private final List<BeanDeploymentArchive> beanDeploymentArchives;
-
- public JBossDeployment(WebBeanDiscoveryEnvironment environment, Iterable<EjbDescriptor<?>> ejbDescriptors)
- {
- this.beanDeploymentArchive = new JBossBeanDeploymentArchive(environment, ejbDescriptors);
- this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
- this.beanDeploymentArchives.add(beanDeploymentArchive);
- }
-
- public List<BeanDeploymentArchive> getBeanDeploymentArchives()
- {
- return beanDeploymentArchives;
- }
-
- public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
- {
- return beanDeploymentArchive;
- }
-
-}
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/SecurityActions.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/SecurityActions.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/SecurityActions.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.dependency.Module;
+
+/**
+ * Security actions
+ *
+ * @author Ales Justin
+ */
+class SecurityActions
+{
+ /**
+ * Get code source location.
+ *
+ * @param clazz the class
+ * @return class' code source location
+ */
+ static URL getCodeSourceLocation(final Class<?> clazz)
+ {
+ PrivilegedAction<URL> urlAction = new PrivilegedAction<URL>()
+ {
+ public URL run()
+ {
+ ProtectionDomain pd = clazz.getProtectionDomain();
+ CodeSource cs = pd.getCodeSource();
+ return cs.getLocation();
+ }
+ };
+ return AccessController.doPrivileged(urlAction);
+ }
+
+ /**
+ * Get module for class.
+ *
+ * @param clazz the class
+ * @return class' module
+ */
+ static Module getModuleForClass(final Class<?> clazz)
+ {
+ PrivilegedAction<Module> moduleAction = new PrivilegedAction<Module>()
+ {
+ public Module run()
+ {
+ ClassLoader cl = clazz.getClassLoader();
+ return ClassLoading.getModuleForClassLoader(cl);
+ }
+ };
+ return AccessController.doPrivileged(moduleAction);
+ }
+}
\ No newline at end of file
Copied: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/StructureDeployment.java (from rev 91411, projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossDeployment.java)
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/StructureDeployment.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/StructureDeployment.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.bootstrap.spi.Deployment;
+
+/**
+ * Structure based deployment.
+ *
+ * @author Ales Justin
+ */
+public class StructureDeployment extends DeploymentArchiveAdapter implements Deployment
+{
+ public StructureDeployment(VFSDeploymentUnit unit)
+ {
+ // make sure it's top
+ super(checkDeploymentUnit(unit).getTopLevel());
+ }
+
+ protected void applyRootDeploymentArchive(JBossBeanDeploymentArchive root, List<JBossBeanDeploymentArchive> temps)
+ {
+ temps.add(root);
+ }
+
+ public BeanDeploymentArchive loadBeanDeploymentArchive(final Class<?> beanClass)
+ {
+ URL codeSourceURL = SecurityActions.getCodeSourceLocation(beanClass);
+ List<JBossBeanDeploymentArchive> jbdas = getJBossBeanDeploymentArchives();
+ for (JBossBeanDeploymentArchive jbda : jbdas)
+ {
+ BeanDeploymentArchive bda = jbda.match(codeSourceURL);
+ if (bda != null)
+ return bda;
+ }
+
+ Module module = SecurityActions.getModuleForClass(beanClass);
+ JBossBeanDeploymentArchive newJBDA = new URLBeanDeploymentArchive(module, codeSourceURL);
+ jbdas.add(newJBDA);
+ return newJBDA;
+ }
+}
\ No newline at end of file
Property changes on: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/StructureDeployment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/StructureDeploymentDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/StructureDeploymentDeployer.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/StructureDeploymentDeployer.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,42 @@
+/*
+ * 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.deployer.env;
+
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+
+/**
+ * Create Structure Deployment from WB discovery env.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class StructureDeploymentDeployer extends AbstractDeploymentDeployer
+{
+ protected BeanMetaData deploy(DeploymentUnit unit, BootstrapInfo info, String deploymentName)
+ {
+ BeanMetaDataBuilder deploymentWrapper = BeanMetaDataBuilder.createBuilder(deploymentName, StructureDeployment.class.getName());
+ deploymentWrapper.addConstructorParameter(VFSDeploymentUnit.class.getName(), unit);
+ return deploymentWrapper.getBeanMetaData();
+ }
+}
\ No newline at end of file
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/URLBeanDeploymentArchive.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/URLBeanDeploymentArchive.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/URLBeanDeploymentArchive.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.visitor.ClassFilter;
+import org.jboss.classloading.spi.visitor.ResourceContext;
+import org.jboss.classloading.spi.visitor.ResourceFilter;
+import org.jboss.classloading.spi.visitor.ResourceVisitor;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+
+/**
+ * URL based BeanDeploymentArchive.
+ *
+ * @author Ales Justin
+ */
+public class URLBeanDeploymentArchive implements JBossBeanDeploymentArchive
+{
+ private Module module;
+ private URL url;
+ private volatile Iterable<Class<?>> classes;
+
+ public URLBeanDeploymentArchive(Module module, URL url)
+ {
+ if (module == null)
+ throw new IllegalArgumentException("Null module");
+ if (url == null)
+ throw new IllegalArgumentException("Null url");
+
+ this.module = module;
+ this.url = url;
+ }
+
+ public BeanDeploymentArchive match(URL codeSourceUrl)
+ {
+ return codeSourceUrl.equals(url) ? this : null;
+ }
+
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return Collections.emptyList();
+ }
+
+ public Iterable<Class<?>> getBeanClasses()
+ {
+ if (classes == null)
+ {
+ ClassesVisitor visitor = new ClassesVisitor();
+ module.visit(visitor, ClassFilter.INSTANCE, null, url);
+ classes = visitor.getResult();
+ }
+
+ return classes;
+ }
+
+ public Iterable<URL> getBeansXml()
+ {
+ return Collections.emptySet();
+ }
+
+ public Iterable<EjbDescriptor<?>> getEjbs()
+ {
+ return null; // TODO
+ }
+
+ private static class ClassesVisitor implements ResourceVisitor
+ {
+ private List<Class<?>> result = new ArrayList<Class<?>>();
+
+ public ResourceFilter getFilter()
+ {
+ return ClassFilter.INSTANCE;
+ }
+
+ public void visit(ResourceContext resource)
+ {
+ result.add(resource.loadClass());
+ }
+
+ public List<Class<?>> getResult()
+ {
+ return result;
+ }
+ }
+}
\ No newline at end of file
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/VirtualFileBeanDeploymentArchive.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/VirtualFileBeanDeploymentArchive.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/VirtualFileBeanDeploymentArchive.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.net.URL;
+import java.util.Collections;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VFS based BeanDeploymentArchive.
+ *
+ * @author Ales Justin
+ */
+public class VirtualFileBeanDeploymentArchive extends URLBeanDeploymentArchive
+{
+ private Iterable<URL> xmls;
+
+ public VirtualFileBeanDeploymentArchive(Module module, VirtualFile root, VirtualFile wbXml)
+ {
+ super(module, DeploymentArchiveAdapter.toURL(root));
+ if (wbXml == null)
+ xmls = Collections.emptySet();
+ else
+ xmls = Collections.singleton(DeploymentArchiveAdapter.toURL(wbXml));
+ }
+
+ public Iterable<URL> getBeansXml()
+ {
+ return xmls;
+ }
+}
\ No newline at end of file
Copied: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WBEnvBeanDeploymentArchive.java (from rev 91411, projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/JBossBeanDeploymentArchive.java)
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WBEnvBeanDeploymentArchive.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WBEnvBeanDeploymentArchive.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,41 @@
+package org.jboss.webbeans.integration.deployer.env;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+
+public class WBEnvBeanDeploymentArchive implements BeanDeploymentArchive
+{
+ private final WebBeanDiscoveryEnvironment environment;
+
+ private final Iterable<EjbDescriptor<?>> ejbDescriptors;
+
+ public WBEnvBeanDeploymentArchive(WebBeanDiscoveryEnvironment environment, Iterable<EjbDescriptor<?>> ejbDescriptors)
+ {
+ this.environment = environment;
+ this.ejbDescriptors = ejbDescriptors;
+ }
+
+ public Iterable<Class<?>> getBeanClasses()
+ {
+ return environment.getWebBeanClasses();
+ }
+
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return Collections.emptyList();
+ }
+
+ public Iterable<URL> getBeansXml()
+ {
+ return environment.getWebBeansXml();
+ }
+
+ public Iterable<EjbDescriptor<?>> getEjbs()
+ {
+ return ejbDescriptors;
+ }
+}
\ No newline at end of file
Property changes on: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WBEnvBeanDeploymentArchive.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java 2009-07-27 12:57:46 UTC (rev 91673)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -27,8 +27,6 @@
import org.jboss.beans.metadata.spi.builder.ParameterMetaDataBuilder;
import org.jboss.dependency.spi.ControllerState;
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;
import org.jboss.webbeans.bootstrap.api.Bootstrap;
import org.jboss.webbeans.bootstrap.api.Environments;
@@ -41,38 +39,27 @@
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public class WebBeansBootstrapDeployer extends AbstractSimpleRealDeployer<WebBeanDiscoveryEnvironment>
+public class WebBeansBootstrapDeployer extends AbstractServicesConnectorDeployer
{
public WebBeansBootstrapDeployer()
{
- super(WebBeanDiscoveryEnvironment.class);
- setTopLevelOnly(true);
- setStage(DeploymentStages.PRE_REAL);
+ super(false);
addOutput(BeanMetaData.class);
}
@Override
- public void deploy(DeploymentUnit unit, WebBeanDiscoveryEnvironment env) throws DeploymentException
+ public void deploy(DeploymentUnit unit, BootstrapInfo info) throws DeploymentException
{
- String unitName = unit.getName();
- String envName = unitName + "_JBossDeployment";
-
- ValueMetaData ejbServicesValue = createEjbConnector("JBossEjbServices", "org.jboss.webbeans.integration.ejb.JBossEjbServices", unit);
-
+ ValueMetaData ejbServicesValue = info.getEjbServices();
+
String bootstrapName = DeployersUtils.getBootstrapBeanName(unit);
BeanMetaDataBuilder bootstrap = BeanMetaDataBuilder.createBuilder(bootstrapName, "org.jboss.webbeans.bootstrap.api.helpers.BootstrapBean");
- BeanMetaDataBuilder envWrapper = BeanMetaDataBuilder.createBuilder(envName, "org.jboss.webbeans.integration.deployer.env.JBossDeployment");
- envWrapper.addConstructorParameter(WebBeanDiscoveryEnvironment.class.getName(), env);
- envWrapper.addConstructorParameter(Iterable.class.getName(), bootstrap.createInject(ejbServicesValue.getUnderlyingValue(), "ejbs"));
- unit.addAttachment(envName + "_" + BeanMetaData.class.getSimpleName(), envWrapper.getBeanMetaData());
-
-
bootstrap.addConstructorParameter(Bootstrap.class.getName(), createBootstrap(unit));
- bootstrap.addPropertyMetaData("deployment", bootstrap.createInject(envName));
-
+ bootstrap.addPropertyMetaData("deployment", info.getDeployment());
+
bootstrap.addPropertyMetaData("ejbServices", ejbServicesValue);
- bootstrap.addPropertyMetaData("jpaServices", createEjbConnector("JBossJpaServices", "org.jboss.webbeans.integration.persistence.JBossJpaServices", unit));
+ bootstrap.addPropertyMetaData("jpaServices", createServiceConnector("JBossJpaServices", "org.jboss.webbeans.integration.persistence.JBossJpaServices", unit));
bootstrap.addPropertyMetaData("resourceServices", bootstrap.createInject("JBossResourceServices"));
bootstrap.addPropertyMetaData("webServices", bootstrap.createInject("JBossWebServices"));
bootstrap.addPropertyMetaData("jmsServices", bootstrap.createInject("JBossJmsServices"));
@@ -105,25 +92,6 @@
}
/**
- * Create ejb connector.
- *
- * @param name the connector name
- * @param bean the bean to create
- * @param unit the deployment unit
- * @return new inject metadata
- */
- protected ValueMetaData createEjbConnector(String name, String bean, DeploymentUnit unit)
- {
- String beanName = unit.getName() + "_" + name;
- BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(beanName, bean);
- builder.setFactory(name);
- builder.setFactoryMethod("createBean");
- builder.addPropertyMetaData("deploymentUnit", unit);
- unit.addAttachment(beanName + "_" + BeanMetaData.class.getSimpleName(), builder.getBeanMetaData());
- return builder.createInject(beanName);
- }
-
- /**
* Create bootstrap bean.
*
* @param unit the deployment unit
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/metadata/WebBeansFilesDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/metadata/WebBeansFilesDeployer.java 2009-07-27 12:57:46 UTC (rev 91673)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/metadata/WebBeansFilesDeployer.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -95,7 +95,6 @@
{
throw DeploymentException.rethrowAsDeploymentException("Cannot WBD files/classpath.", e);
}
-
}
/**
Modified: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/VFSTestSuite.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/VFSTestSuite.java 2009-07-27 12:57:46 UTC (rev 91673)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/VFSTestSuite.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -28,6 +28,8 @@
import org.jboss.test.deployers.test.PostDeployersTestCase;
import org.jboss.test.deployers.test.WBDiscoveryEnvTestCase;
import org.jboss.test.deployers.test.CLIsolationTestCase;
+import org.jboss.test.deployers.test.FlatDeploymentTestCase;
+import org.jboss.test.deployers.test.StructureDeploymentTestCase;
/**
* VFS deployers tests.
@@ -46,6 +48,9 @@
TestSuite suite = new TestSuite("Deployers WebBeans Tests");
suite.addTest(WBDiscoveryEnvTestCase.suite());
+ suite.addTest(FlatDeploymentTestCase.suite());
+ suite.addTest(StructureDeploymentTestCase.suite());
+
suite.addTest(PostDeployersTestCase.suite());
suite.addTest(BootDeployerTestCase.suite());
suite.addTest(CLIsolationTestCase.suite());
Modified: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/support/MockEjbServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/support/MockEjbServices.java 2009-07-27 12:57:46 UTC (rev 91673)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/support/MockEjbServices.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -62,13 +62,13 @@
{
return null;
}
-
- public Iterable<EjbDescriptor<?>> discoverEjbs()
+
+ public Iterable<EjbDescriptor<?>> getEjbs()
{
return Collections.emptySet();
}
- public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
+ public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
{
return null;
}
Copied: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java (from rev 91411, projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/WBDiscoveryEnvTestCase.java)
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,158 @@
+/*
+ * 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.test.deployers.test;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.deployers.support.MockEjbServices;
+import org.jboss.test.deployers.support.crm.CrmWebBean;
+import org.jboss.test.deployers.support.ejb.BusinessInterface;
+import org.jboss.test.deployers.support.ejb.MySLSBean;
+import org.jboss.test.deployers.support.ext.ExternalWebBean;
+import org.jboss.test.deployers.support.jar.PlainJavaBean;
+import org.jboss.test.deployers.support.ui.UIWebBean;
+import org.jboss.test.deployers.support.web.ServletWebBean;
+import org.jboss.virtual.AssembledDirectory;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.bootstrap.spi.Deployment;
+
+/**
+ * Abstract Deployment test case.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class AbstractDeploymentTest extends AbstractWebBeansTest
+{
+ protected AbstractDeploymentTest(String name)
+ {
+ super(name);
+ }
+
+ protected void getArchives(List<BeanDeploymentArchive> result, List<BeanDeploymentArchive> archives)
+ {
+ for (BeanDeploymentArchive bda : archives)
+ {
+ result.add(bda);
+ getArchives(result, bda.getBeanDeploymentArchives());
+ }
+ }
+
+ protected abstract int getExpectedArchives();
+
+ public void testSimpleUsage() throws Exception
+ {
+ AssembledDirectory ear = createBasicEar(MockEjbServices.class);
+ VFSDeploymentUnit topUnit = assertDeploy(ear);
+ try
+ {
+ Object bean = getBean(Deployment.class);
+ Deployment deployment = assertInstanceOf(bean, Deployment.class, false);
+
+ List<BeanDeploymentArchive> archives = new ArrayList<BeanDeploymentArchive>();
+ getArchives(archives, deployment.getBeanDeploymentArchives());
+ assertEquals(getExpectedArchives(), archives.size());
+
+ List<URL> urls = new ArrayList<URL>();
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ for (BeanDeploymentArchive bad : archives)
+ {
+ for (URL url : bad.getBeansXml())
+ urls.add(url);
+ for (Class<?> clazz : bad.getBeanClasses())
+ classes.add(clazz);
+ }
+
+ Set<String> expected = new HashSet<String>();
+ addExpectedResource(expected, "ejbs.jar");
+ addExpectedResource(expected, "ext.jar");
+ addExpectedResource(expected, "simple.jar");
+ addExpectedResource(expected, "ui.jar");
+ addExpectedResource(expected, "crm.jar");
+ addExpectedResource(expected, "simple.war", "/WEB-INF/beans.xml");
+
+ assertEquals("Illegal size or urls.", urls.size(), expected.size());
+
+ for (URL url : urls)
+ {
+ boolean found = false;
+ Iterator<String> iter = expected.iterator();
+ while (iter.hasNext())
+ {
+ String expectedURL = iter.next();
+ if (url.toExternalForm().contains(expectedURL))
+ {
+ iter.remove();
+ found = true;
+ break;
+ }
+ }
+ assertTrue("Unexpected wb url: " + url, found);
+ }
+
+ addExpectedClass(expected, BusinessInterface.class);
+ addExpectedClass(expected, MySLSBean.class);
+ addExpectedClass(expected, ExternalWebBean.class);
+ addExpectedClass(expected, PlainJavaBean.class);
+ addExpectedClass(expected, UIWebBean.class);
+ addExpectedClass(expected, ServletWebBean.class);
+ addExpectedClass(expected, CrmWebBean.class);
+
+ assertEquals("Illegal size or classes.", classes.size(), expected.size());
+
+ for (Class<?> clazz : classes)
+ assertTrue(expected.remove(clazz.getName()));
+
+ assertEmpty("Should be emtpy, missing " + expected, expected);
+
+ Class<?> newBeanClass = topUnit.getClassLoader().loadClass("org.jboss.test.deployers.support.MockTransactionServices");
+ BeanDeploymentArchive newBAD = deployment.loadBeanDeploymentArchive(newBeanClass);
+ assertNewBeanDeploymentArchive(archives, newBAD);
+ }
+ finally
+ {
+ undeploy(topUnit);
+ }
+ }
+
+ protected abstract void assertNewBeanDeploymentArchive(List<BeanDeploymentArchive> archives, BeanDeploymentArchive newBAD);
+
+ private static void addExpectedResource(Set<String> expected, String unit)
+ {
+ addExpectedResource(expected, unit, "/META-INF/beans.xml");
+ }
+
+ private static void addExpectedResource(Set<String> expected, String unit, String suffix)
+ {
+ expected.add(unit + suffix);
+ }
+
+ private static void addExpectedClass(Set<String> expected, Class<?> clazz)
+ {
+ expected.add(clazz.getName());
+ }
+}
\ No newline at end of file
Modified: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/AbstractWebBeansTest.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/AbstractWebBeansTest.java 2009-07-27 12:57:46 UTC (rev 91673)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/AbstractWebBeansTest.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -73,8 +73,13 @@
protected AssembledDirectory createBasicEar() throws Exception
{
- AssembledDirectory ear = createTopLevelWithUtil();
+ return createBasicEar(SomeUtil.class);
+ }
+ protected AssembledDirectory createBasicEar(Class<?> utilClass) throws Exception
+ {
+ AssembledDirectory ear = createTopLevelWithUtil(utilClass);
+
AssembledDirectory jar = ear.mkdir("simple.jar");
addPackage(jar, PlainJavaBean.class);
addPath(jar, "/webbeans/simple/jar", "META-INF");
@@ -118,15 +123,25 @@
return createTopLevelWithUtil("/webbeans/simple");
}
+ protected AssembledDirectory createTopLevelWithUtil(Class<?> utilClass) throws Exception
+ {
+ return createTopLevelWithUtil("/webbeans/simple", utilClass);
+ }
+
protected AssembledDirectory createTopLevelWithUtil(String path) throws Exception
{
+ return createTopLevelWithUtil(path, SomeUtil.class);
+ }
+
+ protected AssembledDirectory createTopLevelWithUtil(String path, Class<?> utilClass) throws Exception
+ {
AssembledDirectory topLevel = createAssembledDirectory("top-level.ear", "top-level.ear");
addPath(topLevel, path, "META-INF");
AssembledDirectory earLib = topLevel.mkdir("lib");
AssembledDirectory util = earLib.mkdir("util.jar");
- addPackage(util, SomeUtil.class);
+ addPackage(util, utilClass);
AssembledDirectory ext = earLib.mkdir("ext.jar");
addPackage(ext, ExternalWebBean.class);
Added: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentTestCase.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentTestCase.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentTestCase.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,55 @@
+/*
+ * 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.test.deployers.test;
+
+import java.util.List;
+
+import junit.framework.Test;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * Flat Deployment test case.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class FlatDeploymentTestCase extends AbstractDeploymentTest
+{
+ public FlatDeploymentTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(FlatDeploymentTestCase.class);
+ }
+
+ protected int getExpectedArchives()
+ {
+ return 1; // flat only
+ }
+
+ protected void assertNewBeanDeploymentArchive(List<BeanDeploymentArchive> archives, BeanDeploymentArchive newBAD)
+ {
+ assertSame(newBAD, archives.iterator().next());
+ }
+}
\ No newline at end of file
Added: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/StructureDeploymentTestCase.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/StructureDeploymentTestCase.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/deployers/test/StructureDeploymentTestCase.java 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,55 @@
+/*
+ * 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.test.deployers.test;
+
+import java.util.List;
+
+import junit.framework.Test;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * Structure Deployment test case.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class StructureDeploymentTestCase extends AbstractDeploymentTest
+{
+ public StructureDeploymentTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(StructureDeploymentTestCase.class);
+ }
+
+ protected int getExpectedArchives()
+ {
+ return 7; // whole structure
+ }
+
+ protected void assertNewBeanDeploymentArchive(List<BeanDeploymentArchive> archives, BeanDeploymentArchive newBAD)
+ {
+ assertFalse("New BAD [" + newBAD + "] already exists: " + archives, archives.contains(newBAD));
+ }
+}
\ No newline at end of file
Copied: projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/deployers/test/FlatDeploymentTestCase.xml (from rev 91411, projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/deployers/test/WBDiscoveryEnvTestCase.xml)
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/deployers/test/FlatDeploymentTestCase.xml (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/deployers/test/FlatDeploymentTestCase.xml 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,17 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+ <bean name="WarStructure" class="org.jboss.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>
+
+ <bean name="JWBMDDeployer" class="org.jboss.webbeans.integration.deployer.ext.JBossWebBeansMetaDataDeployer"/>
+ <bean name="WBFilesDeployer" class="org.jboss.webbeans.integration.deployer.metadata.WebBeansFilesDeployer"/>
+ <bean name="WBDiscoveryDeployer" class="org.jboss.webbeans.integration.deployer.env.WebBeanDiscoveryDeployer"/>
+
+ <beanfactory name="JBossEjbServices" class="org.jboss.test.deployers.support.MockEjbServices"/>
+
+ <bean name="EjbServicesDeployer" class="org.jboss.webbeans.integration.deployer.env.EjbServicesDeployer">
+ <property name="ejbServicesClassName">org.jboss.test.deployers.support.MockEjbServices</property>
+ </bean>
+
+ <bean name="DeploymentDeployer" class="org.jboss.webbeans.integration.deployer.env.FlatDeploymentDeployer"/>
+</deployment>
Added: projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/deployers/test/StructureDeploymentTestCase.xml
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/deployers/test/StructureDeploymentTestCase.xml (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/deployers/test/StructureDeploymentTestCase.xml 2009-07-27 14:41:47 UTC (rev 91674)
@@ -0,0 +1,16 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+ <bean name="WarStructure" class="org.jboss.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>
+
+ <bean name="JWBMDDeployer" class="org.jboss.webbeans.integration.deployer.ext.JBossWebBeansMetaDataDeployer"/>
+ <bean name="WBFilesDeployer" class="org.jboss.webbeans.integration.deployer.metadata.WebBeansFilesDeployer"/>
+
+ <beanfactory name="JBossEjbServices" class="org.jboss.test.deployers.support.MockEjbServices"/>
+
+ <bean name="EjbServicesDeployer" class="org.jboss.webbeans.integration.deployer.env.EjbServicesDeployer">
+ <property name="ejbServicesClassName">org.jboss.test.deployers.support.MockEjbServices</property>
+ </bean>
+
+ <bean name="DeploymentDeployer" class="org.jboss.webbeans.integration.deployer.env.StructureDeploymentDeployer"/>
+</deployment>
More information about the jboss-cvs-commits
mailing list