[jboss-cvs] JBossAS SVN: r99114 - in projects/ejb3/trunk/singleton: src/main and 17 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 7 09:23:36 EST 2010
Author: jaikiran
Date: 2010-01-07 09:23:36 -0500 (Thu, 07 Jan 2010)
New Revision: 99114
Added:
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/deployer/
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/deployer/SingletonContainerDeployer.java
projects/ejb3/trunk/singleton/src/main/resources/
projects/ejb3/trunk/singleton/src/main/resources/META-INF/
projects/ejb3/trunk/singleton/src/main/resources/META-INF/ejb3-singleton-jboss-beans.xml
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockEjb3DeploymentDeployer.java
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/SimpleClassLoaderDeployer.java
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/VDFServer.java
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/VDFServerImpl.java
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/deployer/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/deployer/unit/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/deployer/unit/SingletonContainerDeployerTestCase.java
projects/ejb3/trunk/singleton/src/test/resources/classloader.xml
projects/ejb3/trunk/singleton/src/test/resources/org/
projects/ejb3/trunk/singleton/src/test/resources/org/jboss/
projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/
projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/
projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/
projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/
projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/unit/
projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/unit/ejb3-test-deployers-jboss-beans.xml
projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/unit/singleton-container-aop.xml
Removed:
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/
Modified:
projects/ejb3/trunk/singleton/pom.xml
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonContainer.java
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/unit/SimpleSingletonTestCase.java
projects/ejb3/trunk/singleton/src/test/resources/log4j.xml
Log:
EJBTHREE-1518 Implemented a deployer for creating the SingletonContainer if a deployment unit has the singleton component metadata
Modified: projects/ejb3/trunk/singleton/pom.xml
===================================================================
--- projects/ejb3/trunk/singleton/pom.xml 2010-01-07 12:59:11 UTC (rev 99113)
+++ projects/ejb3/trunk/singleton/pom.xml 2010-01-07 14:23:36 UTC (rev 99114)
@@ -24,6 +24,18 @@
<url>http://labs.jboss.com/jbossejb3</url>
<description>
</description>
+
+ <properties>
+ <version.org.jboss.deployers>2.0.8.GA</version.org.jboss.deployers>
+ <version.org.jboss.ejb3_deployers>1.1.0-SNAPSHOT</version.org.jboss.ejb3_deployers>
+ <version.org.jboss.microcontainer>2.0.9.GA</version.org.jboss.microcontainer>
+ <version.org.jboss_jbossxb>2.0.1.GA</version.org.jboss_jbossxb>
+ <version.javassist>3.7.1.GA</version.javassist>
+ <version.org.jboss.ejb3_jboss-ejb3-test>1.0.0</version.org.jboss.ejb3_jboss-ejb3-test>
+ <version.metadata_ejb>2.0.0-SNAPSHOT</version.metadata_ejb>
+ <version.metadata_ear>2.0.0.Alpha</version.metadata_ear>
+ <version.org.jboss.bootstrap>2.0.0-alpha-3</version.org.jboss.bootstrap>
+ </properties>
<build>
<plugins>
@@ -61,6 +73,7 @@
<configuration>
<forkMode>once</forkMode>
<jvm>${JDK6_HOME}/bin/java</jvm>
+ <argLine>-Dxb.builder.useUnorderedSequence=true</argLine>
</configuration>
</plugin>
</plugins>
@@ -73,42 +86,200 @@
<scope>test</scope>
</dependency>
+ <!-- MC -->
<dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>${version.org.jboss.microcontainer}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-mdr</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- javax.ejb.* -->
+ <dependency>
+ <groupId>org.jboss.javaee</groupId>
+ <artifactId>jboss-ejb-api_3.1</artifactId>
+ <version>1.0-alpha-1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-core</artifactId>
+ <version>1.1.22</version>
+ <!-- I hate to add these exclusions everywhere -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-mdr</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Get rid of this! it's required for ServiceMBeanSupport class
+ which is being extended by EJB3Deployment -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-system-jmx</artifactId>
+ <version>5.0.0.CR2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- EJB metadata -->
+ <dependency>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata-ejb</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+
+
+
+ <!-- JBoss deployers -->
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-core-spi</artifactId>
+ <version>${version.org.jboss.deployers}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-structure-spi</artifactId>
+ <version>${version.org.jboss.deployers}</version>
+ </dependency>
+
+
+
+ <!-- **************************** -->
+ <!-- Test dependencies -->
+ <!-- **************************** -->
+
+ <!--
+ VDF support
+ -->
+ <dependency>
<groupId>org.jboss.bootstrap</groupId>
- <artifactId>jboss-bootstrap</artifactId>
- <version>1.0.0-Beta-1</version>
+ <artifactId>jboss-bootstrap-impl-mc</artifactId>
+ <version>${version.org.jboss.bootstrap}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ <version>1.0.0-alpha-2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- **************************** -->
+ <!-- Runtime dependencies -->
+ <!-- **************************** -->
+
<dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-api</artifactId>
- <version>3.1.0-SNAPSHOT</version>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-impl</artifactId>
+ <version>${version.org.jboss.deployers}</version>
+ <scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs</artifactId>
+ <version>${version.org.jboss.deployers}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs-spi</artifactId>
+ <version>${version.org.jboss.deployers}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb</artifactId>
+ <version>${version.org.jboss_jbossxb}</version>
+ <scope>runtime</scope>
+ </dependency>
+
<dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-core</artifactId>
- <version>1.1.3-SNAPSHOT</version>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.14.GA</version>
+ <scope>runtime</scope>
</dependency>
+
<dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-test</artifactId>
- <version>1.0.0</version>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ <version>2.0.2.GA</version>
+ <scope>runtime</scope>
</dependency>
<!-- this needs to be removed - EJBTHREE-1343 -->
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-server</artifactId>
- <version>5.0.1.GA</version>
+ <version>5.0.0.CR2</version>
<exclusions>
<exclusion>
<groupId>jboss</groupId>
<artifactId>jboss-remoting</artifactId>
</exclusion>
+ <!-- jboss-as-server must not dictate the JPA API -->
<exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>ejb3-persistence</artifactId>
+ </exclusion>
+ <exclusion>
<groupId>org.jboss</groupId>
<artifactId>jboss-metadata</artifactId>
</exclusion>
@@ -126,13 +297,15 @@
<artifactId>jbossws-native-jaxws</artifactId>
</exclusion>
</exclusions>
- <scope>provided</scope>
+ <scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jmx-mc-int</artifactId>
- <version>2.2.0-SNAPSHOT</version>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-deployers</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>runtime</scope>
</dependency>
+
</dependencies>
</project>
Modified: projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonContainer.java
===================================================================
--- projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonContainer.java 2010-01-07 12:59:11 UTC (rev 99113)
+++ projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonContainer.java 2010-01-07 14:23:36 UTC (rev 99114)
@@ -37,6 +37,8 @@
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
/**
+ * TODO: Experiment on moving away from AOP
+ *
* @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
* @version $Revision: $
*/
@@ -44,6 +46,12 @@
{
private BeanContext<SingletonContainer> instance;
+ /**
+ * Represents the AOP domain name for a singleton container
+ */
+ // TODO: Will be removed when AOP usage is removed
+ public static final String SINGLETON_CONTAINER_AOP_DOMAIN = "Singleton Bean";
+
public SingletonContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBeanMetaData beanMetaData)
throws ClassNotFoundException
Added: projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/deployer/SingletonContainerDeployer.java
===================================================================
--- projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/deployer/SingletonContainerDeployer.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/deployer/SingletonContainerDeployer.java 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,214 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ejb3.singleton.deployer;
+
+import java.util.Hashtable;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.DomainDefinition;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
+import org.jboss.ejb3.singleton.SingletonContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
+
+/**
+ * SingleContainerDeployer
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class SingletonContainerDeployer extends AbstractSimpleRealDeployer<JBossEnterpriseBeanMetaData>
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(SingletonContainerDeployer.class);
+
+ /**
+ * Constructor
+ */
+ public SingletonContainerDeployer()
+ {
+ super(JBossEnterpriseBeanMetaData.class);
+
+ setComponentsOnly(true);
+ addOutput(BeanMetaData.class);
+
+ // ordering
+ addInput(Ejb3Deployment.class);
+ addInput(AttachmentNames.PROCESSED_METADATA);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer#deploy(org.jboss.deployers.structure.spi.DeploymentUnit, java.lang.Object)
+ */
+ @Override
+ public void deploy(DeploymentUnit unit, JBossEnterpriseBeanMetaData beanMetaData) throws DeploymentException
+ {
+ if (!(beanMetaData instanceof JBossSessionBeanMetaData))
+ {
+ return;
+ }
+ // we are only interested in EJB3.1
+ if (!beanMetaData.getJBossMetaData().isEJB31())
+ {
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Ignoring non-EJB3.1 bean " + beanMetaData.getName());
+ }
+ return;
+ }
+ JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) beanMetaData;
+ // we are only concerned with Singleton beans
+ if (!sessionBean.isSingleton())
+ {
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Ignoring non-singleton bean " + sessionBean.getName());
+ }
+ return;
+ }
+
+ // Create a singleton container
+ ClassLoader classLoader = unit.getClassLoader();
+ // TODO: Once we move away from AOP, remove this.
+ // Note that we intentionally do NOT allow overriding the domain name
+ // through the bean metadata (annotation/xml) for singleton beans, since
+ // we are moving away from AOP stuff, for new components
+ DomainDefinition singletonContainerAOPDomain = AspectManager.instance().getContainer(
+ SingletonContainer.SINGLETON_CONTAINER_AOP_DOMAIN);
+ if (singletonContainerAOPDomain == null)
+ {
+ throw new DeploymentException(SingletonContainer.SINGLETON_CONTAINER_AOP_DOMAIN
+ + " AOP domain not configured - cannot deploy EJB named " + beanMetaData.getEjbName() + " in unit "
+ + unit);
+ }
+ Hashtable<String, String> ctxProperties = new Hashtable<String, String>();
+ Ejb3Deployment ejb3Deployment = unit.getAttachment(Ejb3Deployment.class);
+ if (ejb3Deployment == null)
+ {
+ throw new DeploymentException("Could not find " + Ejb3Deployment.class + " for creating singleton container for bean "
+ + sessionBean.getEjbName() + " in unit " + unit);
+ }
+ SingletonContainer singletonContainer = null;
+ try
+ {
+ singletonContainer = new SingletonContainer(classLoader, sessionBean.getEjbClass(), sessionBean.getEjbName(),
+ (Domain) singletonContainerAOPDomain.getManager(), ctxProperties, ejb3Deployment, sessionBean);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new DeploymentException("Could not find class during deployment of bean named "
+ + sessionBean.getEjbName() + " in unit " + unit, cnfe);
+ }
+ // deploy the singleton container as a MC bean
+ String singletonContainerMCBeanName = sessionBean.getContainerName();
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(singletonContainerMCBeanName,
+ SingletonContainer.class.getName());
+ builder.setConstructorValue(singletonContainer);
+
+ // Add the singleton container MC bean as an attachment
+ unit.addAttachment(BeanMetaData.class + ":" + singletonContainerMCBeanName, builder.getBeanMetaData());
+
+ }
+
+ // /**
+ // * Ultimately, the container name should come from the <code>sessionBeanMetadata</code>.
+ // * However because of the current behaviour where the container on its start sets the containername
+ // * in the metadata, its not possible to get this information even before the container is started.
+ // *
+ // * Hence let's for the time being create the container name from all the information that we have
+ // * in the <code>unit</code>
+ // *
+ // * @param unit The deployment unit
+ // * @param sessionBeanMetadata Session bean metadata
+ // * @return Returns the container name for the bean corresponding to the <code>sessionBeanMetadata</code> in the <code>unit</code>
+ // *
+ // * @throws MalformedObjectNameException
+ // */
+ // private String getContainerName(DeploymentUnit unit, JBossSessionBeanMetaData sessionBeanMetadata)
+ // throws MalformedObjectNameException
+ // {
+ // // TODO the base ejb3 jmx object name comes from Ejb3Module.BASE_EJB3_JMX_NAME, but
+ // // we don't need any reference to ejb3-core. Right now just hard code here, we need
+ // // a better way/place for this later
+ // StringBuilder containerName = new StringBuilder("jboss.j2ee:service=EJB3" + ",");
+ //
+ // // Get the top level unit for this unit (ex: the top level might be an ear and this unit might be the jar
+ // // in that ear
+ // DeploymentUnit toplevelUnit = unit.getTopLevel();
+ // if (toplevelUnit != null)
+ // {
+ // // if top level is an ear, then create the name with the ear reference
+ // if (isEar(toplevelUnit))
+ // {
+ // containerName.append("ear=");
+ // containerName.append(toplevelUnit.getSimpleName());
+ // containerName.append(",");
+ //
+ // }
+ // }
+ // // now work on the passed unit, to get the jar name
+ // if (unit.getSimpleName() == null)
+ // {
+ // containerName.append("*");
+ // }
+ // else
+ // {
+ // containerName.append("jar=");
+ // containerName.append(unit.getSimpleName());
+ // }
+ // // now the ejbname
+ // containerName.append(",name=");
+ // containerName.append(sessionBeanMetadata.getEjbName());
+ //
+ // if (logger.isTraceEnabled())
+ // {
+ // logger.trace("Container name generated for ejb = " + sessionBeanMetadata.getEjbName() + " in unit " + unit
+ // + " is " + containerName);
+ // }
+ // ObjectName containerJMXName = new ObjectName(containerName.toString());
+ // return containerJMXName.getCanonicalName();
+ // }
+ //
+ // /**
+ // * Returns true if this <code>unit</code> represents an .ear deployment
+ // *
+ // * @param unit
+ // * @return
+ // */
+ // private boolean isEar(DeploymentUnit unit)
+ // {
+ // return unit.getSimpleName().endsWith(".ear") || unit.getAttachment(JBossAppMetaData.class) != null;
+ // }
+}
Added: projects/ejb3/trunk/singleton/src/main/resources/META-INF/ejb3-singleton-jboss-beans.xml
===================================================================
--- projects/ejb3/trunk/singleton/src/main/resources/META-INF/ejb3-singleton-jboss-beans.xml (rev 0)
+++ projects/ejb3/trunk/singleton/src/main/resources/META-INF/ejb3-singleton-jboss-beans.xml 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- We don't want the AOPDependencyBuilder -->
+ <annotation>@org.jboss.aop.microcontainer.annotations.DisableAOP</annotation>
+
+ <!-- EJB3.1 Singleton bean container deployer -->
+ <bean name="SingletonContainerDeployer" class="org.jboss.ejb3.singleton.deployer.SingletonContainerDeployer"/>
+
+</deployment>
\ No newline at end of file
Added: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockEjb3DeploymentDeployer.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockEjb3DeploymentDeployer.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockEjb3DeploymentDeployer.java 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ejb3.singleton.test.common;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+
+/**
+ * MockEjb3DeploymentDeployer
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class MockEjb3DeploymentDeployer extends AbstractSimpleVFSRealDeployer<JBossMetaData>
+{
+
+ public MockEjb3DeploymentDeployer()
+ {
+ super(JBossMetaData.class);
+ addInput(AttachmentNames.PROCESSED_METADATA);
+ setOutput(Ejb3Deployment.class);
+ }
+
+ /**
+ * @see org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer#deploy(org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit, java.lang.Object)
+ */
+ @Override
+ public void deploy(VFSDeploymentUnit unit, JBossMetaData metadata) throws DeploymentException
+ {
+ // Ideally, this check shouldn't be there, but VDF
+ // for some reason passes null in some cases (needs more investigation later)
+ if (metadata != null)
+ {
+ unit.addAttachment(Ejb3Deployment.class, new MockEjb3Deployment());
+ }
+
+ }
+
+
+}
Added: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/SimpleClassLoaderDeployer.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/SimpleClassLoaderDeployer.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/SimpleClassLoaderDeployer.java 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,40 @@
+/*
+ * 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.ejb3.singleton.test.common;
+
+import org.jboss.deployers.spi.deployer.helpers.AbstractTopLevelClassLoaderDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ *
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleClassLoaderDeployer extends AbstractTopLevelClassLoaderDeployer
+{
+ @Override
+ protected ClassLoader createTopLevelClassLoader(DeploymentUnit unit) throws Exception
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+}
Property changes on: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/SimpleClassLoaderDeployer.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/VDFServer.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/VDFServer.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/VDFServer.java 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ejb3.singleton.test.common;
+
+import java.net.URL;
+
+import org.jboss.deployers.client.spi.main.MainDeployer;
+
+/**
+ * VDFServer
+ *
+ * TODO: This is WIP. A simple server which boots up
+ * a MC based server, which has Virtual Deployment Framework (VDF)
+ * installed. This server can be used in tests which test the deployers.
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface VDFServer
+{
+
+ void startServer() throws Exception;
+
+ void stopServer() throws Exception;
+
+ void deploy(URL deployURL) throws Exception;
+
+ public void deploy(String deploymentName, Package... testArtifactPackages) throws Exception;
+
+ public void deploy(String deploymentName, Class<?>... classes) throws Exception;
+
+ MainDeployer getMainDeployer();
+}
Added: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/VDFServerImpl.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/VDFServerImpl.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/VDFServerImpl.java 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,372 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ejb3.singleton.test.common;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.plugins.deployers.DeployersImpl;
+import org.jboss.deployers.plugins.main.MainDeployerImpl;
+import org.jboss.deployers.plugins.managed.DefaultManagedDeploymentCreator;
+import org.jboss.deployers.spi.deployer.helpers.DefaultManagedObjectCreator;
+import org.jboss.deployers.spi.deployer.managed.ManagedDeploymentCreator;
+import org.jboss.deployers.structure.spi.StructureBuilder;
+import org.jboss.deployers.vfs.deployer.kernel.BeanDeployer;
+import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer;
+import org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
+import org.jboss.deployers.vfs.plugins.structure.explicit.DeclaredStructure;
+import org.jboss.deployers.vfs.plugins.structure.file.FileStructure;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.deployers.vfs.spi.structure.helpers.DefaultCandidateStructureVisitorFactory;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.AbstractBootstrap;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
+
+/**
+ * VDFServerImpl
+ * An implementation of {@link VDFServer}. Boots up a MC based server
+ * with VDF installed in it
+ * TODO: This is work in progress.
+ *
+ * @see VDFServer
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class VDFServerImpl implements VDFServer
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(VDFServerImpl.class);
+
+ /**
+ * Bootstrap
+ */
+ private AbstractBootstrap bootstrap;
+
+ /**
+ * basedir (set through Maven)
+ */
+ protected static final File BASEDIR = new File(System.getProperty("basedir"));
+
+ /**
+ * Target directory
+ */
+ protected static final File TARGET_DIRECTORY = new File(BASEDIR, "target");
+
+ /**
+ * The directory into which the deployments required by the tests will be placed
+ */
+ protected static final File TEST_DEPLOYMENTS_FOLDER = new File(TARGET_DIRECTORY, "test-lib");
+
+ private static final String MAIN_DEPLOYER_MC_BEAN_NAME = "MainDeployer";
+
+ private static final String JAR_FILE_SUFFIX = ".jar";
+
+ static
+ {
+ TEST_DEPLOYMENTS_FOLDER.mkdirs();
+ }
+
+ public VDFServerImpl()
+ {
+ this.bootstrap = new BasicBootstrap();
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.singleton.test.common.VDFServer#getMainDeployer()
+ */
+ @Override
+ public MainDeployer getMainDeployer()
+ {
+
+ // Get the MainDeployer
+ MainDeployer mainDeployer = (MainDeployer) this.bootstrap.getKernel().getController().getInstalledContext(MAIN_DEPLOYER_MC_BEAN_NAME).getTarget();
+
+ return mainDeployer;
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.singleton.test.common.VDFServer#startServer()
+ */
+ @Override
+ public void startServer() throws Exception
+ {
+ bootstrap.run();
+ Kernel kernel = bootstrap.getKernel();
+
+ // Get controller
+ final KernelController controller = kernel.getController();
+
+ /*
+ * Now manually install stuff needed to boot VDF
+ */
+ try
+ {
+ // could have installed this through the kernel controller too
+ URL classLoaderDeployersXml = Thread.currentThread().getContextClassLoader().getResource("classloader.xml");
+ BasicXMLDeployer basicDeployer = new BasicXMLDeployer(this.bootstrap.getKernel());
+ basicDeployer.deploy(classLoaderDeployersXml);
+ basicDeployer.validate();
+
+ // ManagedObjectFactory
+ final ManagedObjectFactory managedObjectFactory = ManagedObjectFactory.getInstance();
+ final BeanMetaDataBuilder managedObjectFactoryBmdb = BeanMetaDataBuilderFactory.createBuilder(
+ "ManagedObjectFactory", managedObjectFactory.getClass().getName()).addMethodInstallCallback(
+ "addInstanceClassFactory").addMethodUninstallCallback("removeInstanceClassFactory");
+ controller.install(managedObjectFactoryBmdb.getBeanMetaData(), managedObjectFactory);
+
+ // ManagedObjectCreator
+ final DefaultManagedObjectCreator managedObjectCreator = new DefaultManagedObjectCreator();
+ managedObjectCreator.setMof(managedObjectFactory);
+ final BeanMetaDataBuilder managedObjectCreatorBmdb = BeanMetaDataBuilderFactory.createBuilder(
+ "ManagedObjectCreator", managedObjectCreator.getClass().getName());
+ controller.install(managedObjectCreatorBmdb.getBeanMetaData(), managedObjectCreator);
+
+ // Deployers
+ final DeployersImpl deployers = new DeployersImpl(controller);
+ deployers.setMgtObjectCreator(managedObjectCreator);
+ final BeanMetaDataBuilder deployersBmdb = BeanMetaDataBuilderFactory.createBuilder("Deployers",
+ deployers.getClass().getName()).addMethodInstallCallback("addDeployer").addMethodUninstallCallback(
+ "removeDeployer");
+ controller.install(deployersBmdb.getBeanMetaData(), deployers);
+
+ // StructureBuilder
+ final StructureBuilder structureBuilder = new VFSStructureBuilder();
+ final BeanMetaDataBuilder structureBuilderBmdb = BeanMetaDataBuilderFactory.createBuilder("StructureBuilder",
+ structureBuilder.getClass().getName());
+ controller.install(structureBuilderBmdb.getBeanMetaData(), structureBuilder);
+
+ // StructuralDeployers
+ final VFSStructuralDeployersImpl structuralDeployers = new VFSStructuralDeployersImpl();
+ structuralDeployers.setStructureBuilder(structureBuilder);
+ final BeanMetaDataBuilder structuralDeployersBmdb = BeanMetaDataBuilderFactory.createBuilder(
+ "StructuralDeployers", structuralDeployers.getClass().getName()).addMethodInstallCallback("addDeployer")
+ .addMethodUninstallCallback("removeDeployer");
+ controller.install(structuralDeployersBmdb.getBeanMetaData(), structuralDeployers);
+
+ // MainDeployer
+ final MainDeployerImpl mainDeployer = new MainDeployerImpl();
+ mainDeployer.setDeployers(deployers);
+ mainDeployer.setStructuralDeployers(structuralDeployers);
+ final BeanMetaDataBuilder mainDeployerBmdb = BeanMetaDataBuilderFactory.createBuilder(MAIN_DEPLOYER_MC_BEAN_NAME, mainDeployer.getClass().getName());
+ controller.install(mainDeployerBmdb.getBeanMetaData(), mainDeployer);
+
+ // ManagedDeploymentCreator
+ final ManagedDeploymentCreator defaultMananagedDeploymentCreator = new DefaultManagedDeploymentCreator();
+ final BeanMetaDataBuilder defaultMananagedDeploymentCreatorBmdb = BeanMetaDataBuilderFactory.createBuilder(
+ "ManagedDeploymentCreator", defaultMananagedDeploymentCreator.getClass().getName());
+ controller.install(defaultMananagedDeploymentCreatorBmdb.getBeanMetaData(), defaultMananagedDeploymentCreator);
+
+ // DeclaredStructure
+ final DeclaredStructure declaredStructure = new DeclaredStructure();
+ final BeanMetaDataBuilder declaredStructureBmdb = BeanMetaDataBuilderFactory.createBuilder("DeclaredStructure",
+ declaredStructure.getClass().getName());
+ controller.install(declaredStructureBmdb.getBeanMetaData(), declaredStructure);
+
+ // JARFilter
+ final List<String> excludes = new ArrayList<String>();
+ excludes.add(".class");
+ final SuffixesExcludeFilter jarFilter = new SuffixesExcludeFilter(excludes);
+ final BeanMetaDataBuilder jarFilterBmdb = BeanMetaDataBuilderFactory.createBuilder("JARFilter", jarFilter
+ .getClass().getName());
+ controller.install(jarFilterBmdb.getBeanMetaData(), jarFilter);
+
+ // JARStructureCandidates
+ final DefaultCandidateStructureVisitorFactory jarStructureCandidates = new DefaultCandidateStructureVisitorFactory();
+ jarStructureCandidates.setFilter(jarFilter);
+ final BeanMetaDataBuilder jarStructureCandidatesBmdb = BeanMetaDataBuilderFactory.createBuilder(
+ "JARStructureCandidates", jarStructureCandidates.getClass().getName());
+ controller.install(jarStructureCandidatesBmdb.getBeanMetaData(), jarStructureCandidates);
+
+ // JARStructure
+ final JARStructure jarStructure = new JARStructure();
+ jarStructure.setCandidateStructureVisitorFactory(jarStructureCandidates);
+ final BeanMetaDataBuilder jarStructureBmdb = BeanMetaDataBuilderFactory.createBuilder("JARStructure",
+ jarStructure.getClass().getName());
+ controller.install(jarStructureBmdb.getBeanMetaData(), jarStructure);
+
+ // FileStructure
+ final Set<String> fileStructureSuffixes = new HashSet<String>();
+ fileStructureSuffixes.add("-service.xml");
+ fileStructureSuffixes.add("-ds.xml");
+ fileStructureSuffixes.add("-beans.xml");
+ fileStructureSuffixes.add("-aop.xml");
+ final FileStructure fileStructure = new FileStructure(fileStructureSuffixes);
+ final BeanMetaDataBuilder fileStructureBmdb = BeanMetaDataBuilderFactory.createBuilder("FileStructure",
+ fileStructure.getClass().getName());
+ controller.install(fileStructureBmdb.getBeanMetaData(), fileStructure);
+
+ // BeanDeployer
+ final BeanDeployer beanDeployer = new BeanDeployer();
+ final BeanMetaDataBuilder beanDeployerBmdb = BeanMetaDataBuilderFactory.createBuilder("BeanDeployer",
+ beanDeployer.getClass().getName());
+ controller.install(beanDeployerBmdb.getBeanMetaData(), beanDeployer);
+
+ // KernelDeploymentDeployer
+ final KernelDeploymentDeployer kernelDeploymentDeployer = new KernelDeploymentDeployer();
+ final BeanMetaDataBuilder kernelDeploymentDeployerBmdb = BeanMetaDataBuilderFactory.createBuilder(
+ "KernelDeploymentDeployer", kernelDeploymentDeployer.getClass().getName());
+ controller.install(kernelDeploymentDeployerBmdb.getBeanMetaData(), kernelDeploymentDeployer);
+
+ // BeanMetaDataDeployer
+ final BeanMetaDataDeployer beanMetaDataDeployer = new BeanMetaDataDeployer(controller);
+ final BeanMetaDataBuilder beanMetaDataDeployerBmdb = BeanMetaDataBuilderFactory.createBuilder(
+ "BeanMetaDataDeployer", beanMetaDataDeployer.getClass().getName());
+ controller.install(beanMetaDataDeployerBmdb.getBeanMetaData(), beanMetaDataDeployer);
+
+
+ }
+ catch (Throwable t)
+ {
+ throw new Exception(t);
+ }
+
+
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.singleton.test.common.VDFServer#stopServer()
+ */
+ @Override
+ public void stopServer() throws Exception
+ {
+ // TODO
+ }
+
+ public void deploy(URL deployURL) throws Exception
+ {
+ if (deployURL == null)
+ {
+ throw new IllegalArgumentException("Null URL passed to deploy");
+ }
+ logger.debug("Deploying " + deployURL);
+ MainDeployer mainDeployer = getMainDeployer();
+ VirtualFile root = VFS.getRoot(deployURL);
+ VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(root);
+ mainDeployer.deploy(deployment);
+ mainDeployer.checkComplete(deployment);
+ logger.debug("Completely deployed " + deployURL);
+
+ }
+
+ /**
+ * Deploys a set of classes contained in the passed package <code>testArtifactPackages</code>
+ *
+ * @param deploymentName The name to be used for this deployment
+ */
+ public void deploy(String deploymentName, Package...testArtifactPackages) throws Exception
+ {
+ JavaArchive jar = Archives.create(deploymentName + JAR_FILE_SUFFIX, JavaArchive.class);
+ jar.addPackages(false, testArtifactPackages);
+ URL deployment = writeToFileSystem(jar);
+ this.deploy(deployment);
+ }
+
+ /**
+ * Deploys a set of classes passed as the <code>classes</code> param
+ *
+ * @param deploymentName The name to be used for this deployment
+ */
+ public void deploy(String deploymentName, Class<?>...classes) throws Exception
+ {
+ JavaArchive jar = Archives.create(deploymentName + JAR_FILE_SUFFIX, JavaArchive.class);
+ jar.addClasses(classes);
+ URL deployment = writeToFileSystem(jar);
+ this.deploy(deployment);
+ }
+
+
+ /**
+ * Writes out to {@link File}, the ShrinkWrap {@link JavaArchive}
+ * @param javaArchive
+ * @return
+ * @throws IOException
+ */
+ protected URL writeToFileSystem(JavaArchive javaArchive) throws IOException
+ {
+ InputStream inputStream = javaArchive.as(ZipExporter.class).exportZip();
+ String jarFileName = javaArchive.getName();
+
+ File jarFile = new File(TEST_DEPLOYMENTS_FOLDER, jarFileName);
+ logger.debug("Writing out jar " + jarFile.getAbsolutePath() + " : " + javaArchive.toString(true));
+ FileOutputStream fos = new FileOutputStream(jarFile);
+ BufferedOutputStream bos = null;
+ BufferedInputStream bis = null;
+ try
+ {
+ bos = new BufferedOutputStream(fos);
+ bis = new BufferedInputStream(inputStream);
+ byte[] content = new byte[4096];
+ int length;
+ while ((length = bis.read(content)) != -1)
+ {
+ bos.write(content, 0, length);
+ }
+ bos.flush();
+ }
+ finally
+ {
+ if (bos != null)
+ {
+ bos.close();
+ }
+ if (bis != null)
+ {
+ bis.close();
+ }
+ }
+ return jarFile.toURI().toURL();
+ }
+
+
+}
Added: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/deployer/unit/SingletonContainerDeployerTestCase.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/deployer/unit/SingletonContainerDeployerTestCase.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/deployer/unit/SingletonContainerDeployerTestCase.java 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,114 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ejb3.singleton.test.deployer.unit;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.URL;
+
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.ejb3.singleton.SingletonContainer;
+import org.jboss.ejb3.singleton.deployer.SingletonContainerDeployer;
+import org.jboss.ejb3.singleton.test.common.VDFServer;
+import org.jboss.ejb3.singleton.test.common.VDFServerImpl;
+import org.jboss.ejb3.singleton.test.simple.SimpleSingletonBean;
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * SingletonContainerDeployerTestCase
+ *
+ * Tests the {@link SingletonContainerDeployer}
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class SingletonContainerDeployerTestCase
+{
+
+ private static Logger logger = Logger.getLogger(SingletonContainerDeployerTestCase.class);
+
+ private VDFServer vdfServer;
+
+ private final String BASE_DIR = System.getProperty("basedir");
+
+ /**
+ * Start the {@link VDFServer} and deploy the necessary artifacts
+ *
+ * @throws Exception
+ */
+ @Before
+ public void beforeTest() throws Exception
+ {
+ this.vdfServer = new VDFServerImpl();
+ this.vdfServer.startServer();
+ // the ejb3-singleton-jboss-beans.xml (which gets shipped by this module)
+ File srcResourcesDir = new File(BASE_DIR, "src/main/resources");
+ File ejb3SingletonJBossBeansXml = new File(srcResourcesDir, "META-INF/ejb3-singleton-jboss-beans.xml");
+ Assert.assertNotNull("Could not locate META-INF/ejb3-singleton-jboss-beans.xml", ejb3SingletonJBossBeansXml);
+ this.vdfServer.deploy(ejb3SingletonJBossBeansXml.toURI().toURL());
+
+ // the test case ejb3-test-jboss-beans.xml
+ URL testDeployersXML = Thread.currentThread().getContextClassLoader().getResource(
+ "org/jboss/ejb3/singleton/test/deployer/unit/ejb3-test-deployers-jboss-beans.xml");
+ Assert.assertNotNull("Could not locate org/jboss/ejb3/singleton/test/deployer/unit/ejb3-test-deployers-jboss-beans.xml", testDeployersXML);
+ this.vdfServer.deploy(testDeployersXML);
+
+ // singleton-container-aop.xml
+ URL singletonAOPXML = Thread.currentThread().getContextClassLoader().getResource(
+ "org/jboss/ejb3/singleton/test/deployer/unit/singleton-container-aop.xml");
+ Assert.assertNotNull("Could not locate org/jboss/ejb3/singleton/test/deployer/unit/singleton-container-aop.xml", singletonAOPXML);
+ AspectXmlLoader.deployXML(singletonAOPXML);
+
+ }
+
+ /**
+ * Stop the {@link VDFServer}
+ * @throws Exception
+ */
+ @After
+ public void afterTest() throws Exception
+ {
+ if (this.vdfServer != null)
+ {
+ this.vdfServer.stopServer();
+ }
+ }
+
+ /**
+ * TODO: This is WIP! Needs to be completed after the {@link SingletonContainer} is more robust
+ *
+ * @throws Exception
+ */
+ @Test
+ public void test() throws Exception
+ {
+ //
+ this.vdfServer.deploy("test-deployment", SimpleSingletonBean.class);
+ logger.warn(SingletonContainerDeployerTestCase.class.getName() + " is WIP, needs to be completed");
+
+ }
+
+}
Modified: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/unit/SimpleSingletonTestCase.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/unit/SimpleSingletonTestCase.java 2010-01-07 12:59:11 UTC (rev 99113)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/unit/SimpleSingletonTestCase.java 2010-01-07 14:23:36 UTC (rev 99114)
@@ -30,19 +30,20 @@
import java.util.HashSet;
import java.util.Hashtable;
+import junit.framework.Assert;
+
import org.jboss.aop.AspectManager;
import org.jboss.aop.AspectXmlLoader;
import org.jboss.aop.Domain;
import org.jboss.ejb3.Ejb3Deployment;
import org.jboss.ejb3.common.lang.SerializableMethod;
import org.jboss.ejb3.common.metadata.MetadataUtil;
-import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.ejb3.singleton.SingletonContainer;
-import org.jboss.ejb3.singleton.metadata.SingletonProcessor;
import org.jboss.ejb3.singleton.test.common.MockEjb3Deployment;
import org.jboss.ejb3.singleton.test.simple.SimpleSingletonBean;
import org.jboss.logging.Logger;
import org.jboss.metadata.annotation.creator.AbstractCreator;
+import org.jboss.metadata.annotation.creator.ejb.SingletonProcessor;
import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
import org.jboss.metadata.annotation.finder.AnnotationFinder;
import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
@@ -139,25 +140,12 @@
JBossSessionBeanMetaData beanMetaData = getMetaDataFromBeanImplClass(SimpleSingletonBean.class);
SingletonContainer container = new SingletonContainer(cl, beanMetaData.getEjbClass(), beanMetaData.getEjbName(), domain, ctxProperties, deployment, beanMetaData);
- SessionProxy proxy = new SessionProxy() {
- @Override
- public Object getTarget()
- {
- return null;
- }
-
- @Override
- public void setTarget(Object target)
- {
- // TODO Auto-generated method stub
- //
- throw new RuntimeException("NYI");
- }
-
- };
+
Method realMethod = SimpleSingletonBean.class.getMethod("getState");
SerializableMethod method = new SerializableMethod(realMethod, SimpleSingletonBean.class);
Object args[] = null;
- container.invoke(proxy, method, args);
+ Object result = container.invoke(null, method, args);
+ // TODO: Enable after the singleton container has a complete implementation
+ //Assert.assertNotNull("Result from singleton bean was null", result);
}
}
Added: projects/ejb3/trunk/singleton/src/test/resources/classloader.xml
===================================================================
--- projects/ejb3/trunk/singleton/src/test/resources/classloader.xml (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/resources/classloader.xml 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- We don't want the AOPDependencyBuilder -->
+ <annotation>@org.jboss.aop.microcontainer.annotations.DisableAOP</annotation>
+
+
+ <bean name="SimpleClassLoaderDeployer" class="org.jboss.ejb3.singleton.test.common.SimpleClassLoaderDeployer"/>
+<!-- VFS ClassLoader -->
+ <bean name="ClassLoaderSystem" class="org.jboss.classloader.spi.ClassLoaderSystem">
+ <constructor factoryClass="org.jboss.classloader.spi.ClassLoaderSystem" factoryMethod="getInstance"/>
+ </bean>
+ <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
+ <incallback method="addModule" state="Configured"/>
+ <uncallback method="removeModule" state="Configured"/>
+ </bean>
+ <bean name="ClassLoadingMetaDataParser" class="org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer">
+ <constructor>
+ <parameter>org.jboss.classloading.spi.metadata.ClassLoadingMetaData</parameter>
+ </constructor>
+ <property name="name">jboss-classloading.xml</property>
+ <property name="buildManagedObject">true</property>
+ </bean>
+ <bean name="ClassLoadingDefaultDeployer" class="org.jboss.deployers.plugins.classloading.ClassLoadingDefaultDeployer">
+ <property name="defaultMetaData">
+ <classloading xmlns="urn:jboss:classloading:1.0" export-all="NON_EMPTY" import-all="true"/>
+ </property>
+ </bean>
+ <bean name="ClassLoaderClassPathDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderClassPathDeployer"/>
+ <bean name="ClassLoaderDescribeDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer">
+ <property name="classLoading"><inject bean="ClassLoading"/></property>
+ </bean>
+ <bean name="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer">
+ <property name="classLoading"><inject bean="ClassLoading"/></property>
+ <property name="system"><inject bean="ClassLoaderSystem"/></property>
+ </bean>
+</deployment>
\ No newline at end of file
Modified: projects/ejb3/trunk/singleton/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/trunk/singleton/src/test/resources/log4j.xml 2010-01-07 12:59:11 UTC (rev 99113)
+++ projects/ejb3/trunk/singleton/src/test/resources/log4j.xml 2010-01-07 14:23:36 UTC (rev 99114)
@@ -61,7 +61,7 @@
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
- <param name="Threshold" value="DEBUG"/>
+
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
@@ -107,9 +107,13 @@
</category>
<category name="org.jboss">
- <priority value="INFO"/>
+ <priority value="DEBUG"/>
</category>
-
+<!--
+ <category name="org.jboss.deployers">
+ <priority value="TRACE"/>
+ </category>
+ -->
<!--
Unnecessary, EJB3 is exposed as DEBUG
<category name="org.jboss.ejb3.interceptors.aop.DomainClassLoader">
Added: projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/unit/ejb3-test-deployers-jboss-beans.xml
===================================================================
--- projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/unit/ejb3-test-deployers-jboss-beans.xml (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/unit/ejb3-test-deployers-jboss-beans.xml 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- We don't want the AOPDependencyBuilder -->
+ <annotation>@org.jboss.aop.microcontainer.annotations.DisableAOP</annotation>
+
+ <!-- JNDI -->
+ <bean name="NamingServer" class="org.jnp.server.SingletonNamingServer"/>
+ <!-- Setup java:comp namespace so that it binds an ObjectFactory which returns unique java:comp namespace
+ per TCCL -->
+ <bean name="JavaCompInitializer" class="org.jboss.naming.JavaCompInitializer">
+ <depends>NamingServer</depends>
+ </bean>
+
+
+ <bean name="EjbAnnotationMetaDataDeployer" class="org.jboss.ejb3.deployers.EjbAnnotationMetaDataDeployer"/>
+ <bean name="MergedJBossMetaDataDeployer" class="org.jboss.ejb3.deployers.MergedJBossMetaDataDeployer"/>
+
+
+ <bean name="EJBsDeployer" class="org.jboss.ejb3.deployers.EJBsDeployer"/>
+
+
+ <bean name="MockEJB3DeploymentDeployer" class="org.jboss.ejb3.singleton.test.common.MockEjb3DeploymentDeployer"/>
+
+
+
+</deployment>
\ No newline at end of file
Added: projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/unit/singleton-container-aop.xml
===================================================================
--- projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/unit/singleton-container-aop.xml (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/resources/org/jboss/ejb3/singleton/test/deployer/unit/singleton-container-aop.xml 2010-01-07 14:23:36 UTC (rev 99114)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop xmlns="urn:jboss:aop-beans:1.0">
+ <interceptor class="org.jboss.ejb3.singleton.SingletonInstanceInterceptor" scope="PER_VM"/>
+
+ <!-- Dummy -->
+ <domain name="Singleton Bean" inheritBindings="true">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.singleton.SingletonInstanceInterceptor"/>
+ </bind>
+ </domain>
+</aop>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list