[jboss-cvs] JBossAS SVN: r104546 - in branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964: component-matrix and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 6 22:09:44 EDT 2010
Author: ALRubinger
Date: 2010-05-06 22:09:44 -0400 (Thu, 06 May 2010)
New Revision: 104546
Added:
branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/servlet/EmbeddedEjbCallingServlet.java
branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/resources/webxml/ejbCallingServlet.xml
Modified:
branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/build/build.xml
branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/component-matrix/pom.xml
branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/depchain/pom.xml
branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java
branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/slsb/OutputBean.java
branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/slsb/OutputLocalBusiness.java
Log:
[JBAS-7964] First pass integration of EJB3 Embeddable paravirt into AS; needs ShrinkWrapDeployer for test to pass
Modified: branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/build/build.xml
===================================================================
--- branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/build/build.xml 2010-05-07 01:30:19 UTC (rev 104545)
+++ branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/build/build.xml 2010-05-07 02:09:44 UTC (rev 104546)
@@ -699,6 +699,7 @@
<include name="ejb3-timerservice-jboss-beans.xml"/>
<include name="ejb3-connectors-jboss-beans.xml"/>
</fileset>
+ <fileset refid="org.jboss.ejb3.embedded:jboss-ejb3-embedded-impl-as:jar"/>
<fileset dir="${ejb3.module.output}/resources/META-INF">
<include name="singleton-container-aop.xml"/>
</fileset>
@@ -1989,6 +1990,9 @@
<fileset refid="org.jboss.ejb3.container:jboss-ejb3-container-spi:jar"/>
<fileset refid="org.jboss.ejb3.context:jboss-ejb3-context-base:jar"/>
<fileset refid="org.jboss.ejb3.context:jboss-ejb3-context-naming:jar"/>
+ <fileset refid="org.jboss.ejb3.embedded:jboss-ejb3-embedded-api:jar"/>
+ <fileset refid="org.jboss.ejb3.embedded:jboss-ejb3-embedded-impl-base:jar"/>
+ <fileset refid="org.jboss.ejb3.embedded:jboss-ejb3-embedded-spi:jar"/>
<fileset refid="org.jboss.ejb3:jboss-ejb3-core:jar"/>
<fileset refid="org.jboss.ejb3:jboss-ejb3-deployers:jar"/>
<fileset refid="org.jboss.ejb3:jboss-ejb3-endpoint:jar"/>
Modified: branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/component-matrix/pom.xml
===================================================================
--- branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/component-matrix/pom.xml 2010-05-07 01:30:19 UTC (rev 104545)
+++ branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/component-matrix/pom.xml 2010-05-07 02:09:44 UTC (rev 104546)
@@ -99,6 +99,8 @@
<version.org.jboss.common.core>2.2.17.GA</version.org.jboss.common.core>
<version.org.jboss.deployers>2.2.0.Alpha4</version.org.jboss.deployers>
<version.org.jboss.ejb3.bom>0.1.2</version.org.jboss.ejb3.bom>
+ <!-- This to move into the EJB3 BOM -->
+ <version.org.jboss.ejb3.embedded>1.0.0-SNAPSHOT</version.org.jboss.ejb3.embedded>
<version.org.jboss.ejb.api>1.0-alpha-1</version.org.jboss.ejb.api>
<version.org.jboss.embedded>1.0.0-alpha-3</version.org.jboss.embedded>
<version.org.jboss.integration>6.0.0.Alpha9</version.org.jboss.integration>
@@ -2362,8 +2364,30 @@
<type>pom</type>
<scope>import</scope>
</dependency>
-
+
+ <!-- This to move into the EJB3 BOM -->
<dependency>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>jboss-ejb3-embedded-api</artifactId>
+ <version>${version.org.jboss.ejb3.embedded}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>jboss-ejb3-embedded-impl-as</artifactId>
+ <version>${version.org.jboss.ejb3.embedded}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>jboss-ejb3-embedded-impl-base</artifactId>
+ <version>${version.org.jboss.ejb3.embedded}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>jboss-ejb3-embedded-spi</artifactId>
+ <version>${version.org.jboss.ejb3.embedded}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.embedded</groupId>
<artifactId>jboss-embedded-api</artifactId>
<version>${version.org.jboss.embedded}</version>
Modified: branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/depchain/pom.xml
===================================================================
--- branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/depchain/pom.xml 2010-05-07 01:30:19 UTC (rev 104545)
+++ branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/depchain/pom.xml 2010-05-07 02:09:44 UTC (rev 104546)
@@ -534,6 +534,62 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>jboss-ejb3-embedded-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>jboss-ejb3-embedded-impl-as</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>jboss-ejb3-embedded-impl-base</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>jboss-ejb3-embedded-spi</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-endpoint-deployer</artifactId>
<exclusions>
Modified: branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java
===================================================================
--- branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java 2010-05-07 01:30:19 UTC (rev 104545)
+++ branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java 2010-05-07 02:09:44 UTC (rev 104546)
@@ -56,6 +56,7 @@
import org.apache.http.message.BasicNameValuePair;
import org.jboss.bootstrap.api.lifecycle.LifecycleState;
import org.jboss.bootstrap.api.mc.server.MCBasedServer;
+import org.jboss.ejb3.embedded.api.JBossEJBContainer;
import org.jboss.embedded.api.server.JBossASEmbeddedServer;
import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
import org.jboss.jbossas.embedded.testsuite.ejb3.entity.Jbossian;
@@ -65,6 +66,7 @@
import org.jboss.jbossas.embedded.testsuite.ejb3.slsb.OutputBean;
import org.jboss.jbossas.embedded.testsuite.ejb3.slsb.OutputLocalBusiness;
import org.jboss.jbossas.embedded.testsuite.mc.StateReportingBean;
+import org.jboss.jbossas.embedded.testsuite.servlet.EmbeddedEjbCallingServlet;
import org.jboss.jbossas.embedded.testsuite.servlet.JspForwardingServlet;
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.ArchivePaths;
@@ -109,11 +111,18 @@
private static final String PATH_RESOURCE_WEB_XML = "webxml/";
/**
- * Path, relative to the resources base, of a test web.xml
+ * Path, relative to the resources base, of a test web.xml for a Servlet which forwards control to a JSP
*/
- private static final String PATH_ACTUAL_WEB_XML = PATH_RESOURCE_WEB_XML + "servletForwardingToJsp.xml";
+ private static final String PATH_ACTUAL_SERVLET_FORWARDING_TO_JSP_WEB_XML = PATH_RESOURCE_WEB_XML
+ + "servletForwardingToJsp.xml";
/**
+ * Path, relative to the resources base, of a test web.xml for a Servlet which uses the {@link JBossEJBContainer} API
+ */
+ private static final String PATH_ACTUAL_SERVLET_EMBEDDED_EJB_WEB_XML = PATH_RESOURCE_WEB_XML
+ + "ejbCallingServlet.xml";
+
+ /**
* Filename of a test queue *-service.xml
*/
private static final String FILENAME_QUEUE_SERVICE_XML = "hornetq-jms.xml";
@@ -294,7 +303,8 @@
final Class<?> servletClass = JspForwardingServlet.class;
final WebArchive archive = ShrinkWrap.create(name, WebArchive.class);
final ArchivePath targetPathWebXml = ArchivePaths.create("web.xml");
- archive.addWebResource(PATH_ACTUAL_WEB_XML, targetPathWebXml).addResource(PATH_JSP).addClass(servletClass);
+ archive.addWebResource(PATH_ACTUAL_SERVLET_FORWARDING_TO_JSP_WEB_XML, targetPathWebXml).addResource(PATH_JSP)
+ .addClass(servletClass);
log.info(archive.toString(true));
// Deploy
@@ -332,6 +342,58 @@
}
/**
+ * Tests deployment of a virtual WAR which contains a servlet
+ * that will use the {@link JBossEJBContainer} API to deploy
+ * and invoke upon an EJB.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testServletUsingEmbeddedEJB() throws Exception
+ {
+ // Log
+ log.info("testServletUsingEmbeddedEJB");
+
+ // Make a deployment
+ final String appName = "embeddedEjbCallingServlet";
+ final String name = appName + ".war";
+ final Class<?> servletClass = EmbeddedEjbCallingServlet.class;
+ final WebArchive archive = ShrinkWrap.create(name, WebArchive.class);
+ final ArchivePath targetPathWebXml = ArchivePaths.create("web.xml");
+ archive.addWebResource(PATH_ACTUAL_SERVLET_EMBEDDED_EJB_WEB_XML, targetPathWebXml).addClass(servletClass);
+ log.info(archive.toString(true));
+
+ // Deploy
+ server.deploy(archive);
+
+ // Get an HTTP Client
+ final HttpClient client = new DefaultHttpClient();
+
+ // Make an HTTP Request
+ final URI uri = URIUtils.createURI("http", "localhost", 8080, appName + SEPARATOR + servletClass.getSimpleName(),
+ null, null);
+ final HttpGet request = new HttpGet(uri);
+
+ // Execute the request
+ log.info("Executing request to: " + request.getURI());
+ final HttpResponse response = client.execute(request);
+ final HttpEntity entity = response.getEntity();
+ if (entity == null)
+ {
+ TestCase.fail("Request returned no entity");
+ }
+
+ // Read the result, ensure it's what we're expecting
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ final String line = reader.readLine();
+ log.info("Got response: " + line);
+ Assert.assertEquals(OutputLocalBusiness.JNDI_NAME, line);
+
+ // Undeploy
+ server.undeploy(archive);
+ }
+
+ /**
* Tests deployment of a JMS Queue with EJB3 MDB Listener
*
* The MDB will simply store the text of the message in a publicly-accessible
Modified: branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/slsb/OutputBean.java
===================================================================
--- branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/slsb/OutputBean.java 2010-05-07 01:30:19 UTC (rev 104545)
+++ branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/slsb/OutputBean.java 2010-05-07 02:09:44 UTC (rev 104546)
@@ -24,10 +24,9 @@
import javax.ejb.Local;
import javax.ejb.Stateless;
+import org.jboss.ejb3.annotation.LocalBinding;
/**
- * OutputBean
- *
* Simple SLSB which will return a contracted output
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
@@ -35,16 +34,19 @@
*/
@Stateless
@Local(OutputLocalBusiness.class)
+ at LocalBinding(jndiBinding = OutputLocalBusiness.JNDI_NAME)
public class OutputBean implements OutputLocalBusiness
{
//-------------------------------------------------------------------------------------||
// Required Implementations -----------------------------------------------------------||
//-------------------------------------------------------------------------------------||
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.jbossas.embedded.testsuite.ejb3.slsb.OutputLocalBusiness#getOutput()
+ */
public String getOutput()
{
- String sd="";
- sd.toCharArray();
return OutputLocalBusiness.OUTPUT;
}
}
Modified: branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/slsb/OutputLocalBusiness.java
===================================================================
--- branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/slsb/OutputLocalBusiness.java 2010-05-07 01:30:19 UTC (rev 104545)
+++ branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/slsb/OutputLocalBusiness.java 2010-05-07 02:09:44 UTC (rev 104546)
@@ -36,14 +36,22 @@
// Constants --------------------------------------------------------------------||
//-------------------------------------------------------------------------------||
+ /**
+ * Contracted output
+ */
String OUTPUT = "Embedded SLSB Local Business Output";
+ /**
+ * Target JNDI name to which we'll be bound
+ */
+ String JNDI_NAME = "OutputBeanLocal";
+
//-------------------------------------------------------------------------------||
// Contracts --------------------------------------------------------------------||
//-------------------------------------------------------------------------------||
/**
- * Returns the contracted output
+ * Returns {@link OutputLocalBusiness#OUTPUT}
*/
String getOutput();
}
Added: branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/servlet/EmbeddedEjbCallingServlet.java
===================================================================
--- branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/servlet/EmbeddedEjbCallingServlet.java (rev 0)
+++ branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/servlet/EmbeddedEjbCallingServlet.java 2010-05-07 02:09:44 UTC (rev 104546)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jbossas.embedded.testsuite.servlet;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.ejb3.embedded.api.JBossEJBContainer;
+import org.jboss.jbossas.embedded.testsuite.ejb3.slsb.OutputBean;
+import org.jboss.jbossas.embedded.testsuite.ejb3.slsb.OutputLocalBusiness;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * Servlet which forwards calls upon an EJB
+ * via the {@link EJBContainer} API.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class EmbeddedEjbCallingServlet extends HttpServlet
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(EmbeddedEjbCallingServlet.class.getName());
+
+ /**
+ * serialVersionUID
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Content type to use in forwarding
+ */
+ private static final String CONTENT_TYPE_TEXT_PLAIN = "text/plain";
+
+ //-------------------------------------------------------------------------------------||
+ // Overridden Implementations ---------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Returns the value {@link OutputLocalBusiness#OUTPUT} by invoking via an EJB
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException,
+ IOException
+ {
+ // Log
+ log.info("Request: " + request);
+
+ // Set the content-type to text
+ response.setContentType(CONTENT_TYPE_TEXT_PLAIN);
+
+ // Create the EJB Container
+ final Map<String, String> ejbContainerProps = new HashMap<String, String>();
+ ejbContainerProps.put(EJBContainer.MODULES, ""); // Deploy no modules and do no scanning by default
+ final JBossEJBContainer ejbContainer = (JBossEJBContainer) EJBContainer.createEJBContainer(ejbContainerProps);
+
+ // Define the EJB JAR
+ final JavaArchive archive = ShrinkWrap.create("outputSlsb.jar", JavaArchive.class).addClasses(OutputBean.class,
+ OutputLocalBusiness.class);
+
+ // Deploy the JAR
+ ejbContainer.deploy(archive);
+
+ // Look up the EJB
+ final Context context = ejbContainer.getContext();
+ final OutputLocalBusiness bean;
+ try
+ {
+ bean = (OutputLocalBusiness) context.lookup(OutputLocalBusiness.JNDI_NAME);
+ }
+ catch (final NamingException e)
+ {
+ throw new RuntimeException("Could not find bean proxy at " + OutputLocalBusiness.JNDI_NAME, e);
+ }
+
+ // Invoke
+ final String value = bean.getOutput();
+
+ // Undeploy
+ ejbContainer.undeploy(archive);
+
+ // Shut down EJBContainer
+ ejbContainer.close();
+
+ // Write out
+ log.info("Got value from EJB: " + value);
+ response.getWriter().write(value);
+ }
+}
Added: branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/resources/webxml/ejbCallingServlet.xml
===================================================================
--- branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/resources/webxml/ejbCallingServlet.xml (rev 0)
+++ branches/TEMP_EJB3_EMBEDDABLE_JBAS-7964/embedded/src/test/resources/webxml/ejbCallingServlet.xml 2010-05-07 02:09:44 UTC (rev 104546)
@@ -0,0 +1,13 @@
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+ <servlet>
+ <servlet-name>EmbeddedEjbCallingServlet</servlet-name>
+ <servlet-class>org.jboss.jbossas.embedded.testsuite.servlet.EmbeddedEjbCallingServlet
+ </servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>EmbeddedEjbCallingServlet</servlet-name>
+ <url-pattern>/EmbeddedEjbCallingServlet</url-pattern>
+ </servlet-mapping>
+</web-app>
More information about the jboss-cvs-commits
mailing list