[jboss-cvs] JBossAS SVN: r73590 - in projects/jboss-deployers/trunk/deployers-vfs/src: tests/org/jboss/test/deployers/vfs/deployer/bean and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 22 10:07:47 EDT 2008
Author: alesj
Date: 2008-05-22 10:07:47 -0400 (Thu, 22 May 2008)
New Revision: 73590
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataFactoryDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/CustomBMDF.java
projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/TestComponentCheckerDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractBeanMetaDataFactoryDeployerTest.java
projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/BeanMetaDataFactoryDeployerUnitTestCase.java
Modified:
projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java
Log:
Add generic BeanMetaDataFactory deployer.
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataFactoryDeployer.java (from rev 72857, projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/BeanDeployer.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataFactoryDeployer.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataFactoryDeployer.java 2008-05-22 14:07:47 UTC (rev 73590)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* 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.deployers.vfs.deployer.kernel;
+
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * BeanMetaDataFactoryDeployer.<p>
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @param <T> exact attachment type
+ */
+public class BeanMetaDataFactoryDeployer<T extends BeanMetaDataFactory> extends AbstractSimpleRealDeployer<T>
+{
+ public BeanMetaDataFactoryDeployer(Class<T> clazz)
+ {
+ super(clazz);
+ setOutput(BeanMetaData.class);
+ }
+
+ public void deploy(DeploymentUnit unit, T deployment) throws DeploymentException
+ {
+ List<BeanMetaData> beans = deployment.getBeans();
+ if (beans != null && beans.isEmpty() == false)
+ {
+ for (BeanMetaData bean : beans)
+ KernelDeploymentDeployer.addBeanComponent(unit, bean);
+ }
+ }
+
+ public void undeploy(DeploymentUnit unit, T deployment)
+ {
+ List<BeanMetaData> beans = deployment.getBeans();
+ if (beans != null && beans.isEmpty() == false)
+ {
+ for (BeanMetaData bean : beans)
+ KernelDeploymentDeployer.removeBeanComponent(unit, bean);
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java 2008-05-22 13:38:36 UTC (rev 73589)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java 2008-05-22 14:07:47 UTC (rev 73590)
@@ -27,6 +27,7 @@
import org.jboss.test.deployers.vfs.deployer.bean.test.AliasDeployerUnitTestCase;
import org.jboss.test.deployers.vfs.deployer.bean.test.BeanScanningUnitTestCase;
import org.jboss.test.deployers.vfs.deployer.bean.test.BeanManagedDeploymentUnitTestCase;
+import org.jboss.test.deployers.vfs.deployer.bean.test.BeanMetaDataFactoryDeployerUnitTestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -36,6 +37,7 @@
* BeanDeployerTestSuite.
*
* @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
public class BeanDeployerTestSuite extends TestSuite
@@ -55,6 +57,7 @@
suite.addTest(BeanDeployerClassLoaderUnitTestCase.suite());
suite.addTest(BeanManagedDeploymentUnitTestCase.suite());
suite.addTest(BeanScanningUnitTestCase.suite());
+ suite.addTest(BeanMetaDataFactoryDeployerUnitTestCase.suite());
return suite;
}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/CustomBMDF.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/CustomBMDF.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/CustomBMDF.java 2008-05-22 14:07:47 UTC (rev 73590)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* 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.test.deployers.vfs.deployer.bean.support;
+
+import java.util.List;
+import java.util.Collections;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CustomBMDF implements BeanMetaDataFactory
+{
+ private String name;
+
+ public CustomBMDF(String name)
+ {
+ this.name = name;
+ }
+
+ public List<BeanMetaData> getBeans()
+ {
+ BeanMetaData bmd = new AbstractBeanMetaData(name, Object.class.getName());
+ return Collections.singletonList(bmd);
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/TestComponentCheckerDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/TestComponentCheckerDeployer.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/TestComponentCheckerDeployer.java 2008-05-22 14:07:47 UTC (rev 73590)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* 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.test.deployers.vfs.deployer.bean.support;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestComponentCheckerDeployer extends AbstractDeployer
+{
+ private String name;
+
+ public TestComponentCheckerDeployer(String name)
+ {
+ setStage(DeploymentStages.PARSE);
+ this.name = name;
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ boolean result = unit.removeComponent(name);
+ if (result)
+ throw new IllegalArgumentException("Someone forgot to clean-up component: " + name);
+ }
+}
\ No newline at end of file
Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractBeanMetaDataFactoryDeployerTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractBeanMetaDataFactoryDeployerTest.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractBeanMetaDataFactoryDeployerTest.java 2008-05-22 14:07:47 UTC (rev 73590)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* 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.test.deployers.vfs.deployer.bean.test;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.test.deployers.vfs.deployer.AbstractDeployerUnitTest;
+import org.jboss.test.deployers.vfs.deployer.bean.support.CustomBMDF;
+
+/**
+ * AbstractBeanMetaDataFactoryDeployerTest.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractBeanMetaDataFactoryDeployerTest extends AbstractDeployerUnitTest
+{
+ protected AbstractBeanMetaDataFactoryDeployerTest(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public void testCustomBeanMetaData() throws Throwable
+ {
+ Deployment context = createSimpleDeployment(getClass().getName());
+ MutableAttachments attachments = (MutableAttachments)context.getPredeterminedManagedObjects();
+ attachments.addAttachment(CustomBMDF.class, new CustomBMDF("Test"));
+
+ assertDeploy(context);
+
+ ControllerContext testCC = controller.getInstalledContext("Test");
+ assertNotNull(testCC);
+
+ assertUndeploy(context);
+ assertNull(controller.getContext("Test", null));
+ }
+}
\ No newline at end of file
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/BeanMetaDataFactoryDeployerUnitTestCase.java (from rev 73493, projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/BeanScanningUnitTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/BeanMetaDataFactoryDeployerUnitTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/BeanMetaDataFactoryDeployerUnitTestCase.java 2008-05-22 14:07:47 UTC (rev 73590)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* 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.test.deployers.vfs.deployer.bean.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer;
+import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryDeployer;
+import org.jboss.kernel.Kernel;
+import org.jboss.test.deployers.vfs.deployer.bean.support.CustomBMDF;
+import org.jboss.test.deployers.vfs.deployer.bean.support.TestComponentCheckerDeployer;
+
+/**
+ * BeanMetaDataFactoryDeployerUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanMetaDataFactoryDeployerUnitTestCase extends AbstractBeanMetaDataFactoryDeployerTest
+{
+ public static Test suite()
+ {
+ return new TestSuite(BeanMetaDataFactoryDeployerUnitTestCase.class);
+ }
+
+ public BeanMetaDataFactoryDeployerUnitTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ protected void addDeployers(Kernel kernel)
+ {
+ TestComponentCheckerDeployer tccd = new TestComponentCheckerDeployer("Test");
+ BeanMetaDataFactoryDeployer<CustomBMDF> bmdfd = new BeanMetaDataFactoryDeployer<CustomBMDF>(CustomBMDF.class);
+ BeanMetaDataDeployer beanMetaDataDeployer = new BeanMetaDataDeployer(kernel);
+
+ addDeployer(main, tccd);
+ addDeployer(main, bmdfd);
+ addDeployer(main, beanMetaDataDeployer);
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list