[jboss-cvs] JBossAS SVN: r104299 - in projects/ejb3/components/embedded/trunk: api and 65 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 28 16:05:52 EDT 2010
Author: ALRubinger
Date: 2010-04-28 16:05:48 -0400 (Wed, 28 Apr 2010)
New Revision: 104299
Added:
projects/ejb3/components/embedded/trunk/api/
projects/ejb3/components/embedded/trunk/api/pom.xml
projects/ejb3/components/embedded/trunk/api/src/
projects/ejb3/components/embedded/trunk/api/src/main/
projects/ejb3/components/embedded/trunk/api/src/main/java/
projects/ejb3/components/embedded/trunk/api/src/main/java/org/
projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/
projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/
projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/
projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/api/
projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/api/EJBDeploymentException.java
projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/api/JBossEJBContainer.java
projects/ejb3/components/embedded/trunk/api/src/main/resources/
projects/ejb3/components/embedded/trunk/api/src/test/
projects/ejb3/components/embedded/trunk/api/src/test/java/
projects/ejb3/components/embedded/trunk/api/src/test/resources/
projects/ejb3/components/embedded/trunk/impl-as/
projects/ejb3/components/embedded/trunk/impl-as/pom.xml
projects/ejb3/components/embedded/trunk/impl-as/src/
projects/ejb3/components/embedded/trunk/impl-as/src/main/
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/EmbeddedEJBContainerASAdaptor.java
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/JBossASEJBContainerProvider.java
projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/JBossASEmbeddedEJBContainer.java
projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/
projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/META-INF/
projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/META-INF/services/
projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/META-INF/services/javax.ejb.spi.EJBContainerProvider
projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/embedded-ejb-as-adaptor-jboss-beans.xml
projects/ejb3/components/embedded/trunk/impl-as/src/test/
projects/ejb3/components/embedded/trunk/impl-as/src/test/java/
projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/
projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/jboss/
projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/jboss/ejb3/
projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/jboss/ejb3/embedded/
projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/jboss/ejb3/embedded/impl/
projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/jboss/ejb3/embedded/impl/as/
projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/jboss/ejb3/embedded/impl/as/EmbeddedEJBContainerExistingMCServerIntegrationUnitTest.java
projects/ejb3/components/embedded/trunk/impl-as/src/test/resources/
projects/ejb3/components/embedded/trunk/impl-as/src/test/resources/log4j.xml
projects/ejb3/components/embedded/trunk/impl-base/
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerBase.java
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerProviderBase.java
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEmbeddedContainerStartupParams.java
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/ClassPathEjbJarScanner.java
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/SecurityActions.java
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/filter/
projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/filter/BundleSymbolicNameExclusionFilter.java
projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/
projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/
projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/
projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/
projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/
projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/
projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerProviderUnitTest.java
projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/scanner/
projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/scanner/ClassPathEjbJarScannerUnitTest.java
projects/ejb3/components/embedded/trunk/impl-base/src/test/resources/log4j.xml
projects/ejb3/components/embedded/trunk/impl-standalone/
projects/ejb3/components/embedded/trunk/impl-standalone/pom.xml
projects/ejb3/components/embedded/trunk/impl-standalone/src/
projects/ejb3/components/embedded/trunk/impl-standalone/src/main/
projects/ejb3/components/embedded/trunk/impl-standalone/src/main/java/
projects/ejb3/components/embedded/trunk/impl-standalone/src/main/resources/
projects/ejb3/components/embedded/trunk/impl-standalone/src/test/
projects/ejb3/components/embedded/trunk/impl-standalone/src/test/java/
projects/ejb3/components/embedded/trunk/impl-standalone/src/test/resources/
projects/ejb3/components/embedded/trunk/impl-standalone/src/test/resources/log4j.xml
projects/ejb3/components/embedded/trunk/spi/src/main/java/org/
projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/
projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/ejb3/
projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/ejb3/embedded/
projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/ejb3/embedded/spi/
projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/ejb3/embedded/spi/scanner/
projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/ejb3/embedded/spi/scanner/filter/
projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/ejb3/embedded/spi/scanner/filter/ExclusionFilter.java
Removed:
projects/ejb3/components/embedded/trunk/impl/
Modified:
projects/ejb3/components/embedded/trunk/build/pom.xml
projects/ejb3/components/embedded/trunk/impl-base/pom.xml
projects/ejb3/components/embedded/trunk/pom.xml
projects/ejb3/components/embedded/trunk/spi/pom.xml
Log:
[EJBTHREE-2083] Start porting in EJBContainer support. More to come as we get Unit Tests and docs off the existing prototypes.
Property changes on: projects/ejb3/components/embedded/trunk/api
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
target-eclipse
.settings
.classpath
.project
Added: projects/ejb3/components/embedded/trunk/api/pom.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/api/pom.xml (rev 0)
+++ projects/ejb3/components/embedded/trunk/api/pom.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,54 @@
+<!--
+ vi:ts=2:sw=2:expandtab
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!-- Define Parent -->
+ <parent>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>embedded-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Maven POM Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Information -->
+ <artifactId>embedded-api</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss EJB 3.1+ Embedded API</name>
+ <description>Application Programming Interface for JBoss Embedded EJB 3.1+ Container</description>
+
+ <!-- Build Configuration -->
+ <build>
+
+
+ </build>
+
+ <properties>
+
+ <!-- Versioning -->
+
+
+ </properties>
+
+ <dependencies>
+
+ <!--
+ Dependencies: External to EJB3
+ -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ </dependency>
+
+
+ </dependencies>
+</project>
Added: projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/api/EJBDeploymentException.java
===================================================================
--- projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/api/EJBDeploymentException.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/api/EJBDeploymentException.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.api;
+
+/**
+ * Represents a problem occurred during deployment or
+ * undeployment operations to the {@link JBossEJBContainer}
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class EJBDeploymentException extends Exception
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * serialVersionUID
+ */
+ private static final long serialVersionUID = 1L;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new instance from the specified cause, providing
+ * exception translation to the EJB layer.
+ *
+ * @param message
+ * @param cause
+ */
+ private EJBDeploymentException(final String message, final Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Factory ----------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new {@link EJBDeploymentException} instance from the specified
+ * message and cause
+ * @throws IllegalArgumentException If either the message or cause is not specified
+ */
+ public static EJBDeploymentException newInstance(final String message, final Throwable cause)
+ throws IllegalArgumentException
+ {
+
+ // Precondition checks
+ if (message == null || message.length() == 0)
+ {
+ throw new IllegalArgumentException("message must be specified");
+ }
+ if (cause == null)
+ {
+ throw new IllegalArgumentException("cause must be specified");
+ }
+ // Create and return
+ return new EJBDeploymentException(message, cause);
+ }
+
+}
Added: projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/api/JBossEJBContainer.java
===================================================================
--- projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/api/JBossEJBContainer.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/api/src/main/java/org/jboss/ejb3/embedded/api/JBossEJBContainer.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.api;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+import org.jboss.shrinkwrap.api.Archive;
+
+/**
+ * End-user view of JBoss {@link EJBContainer} implementation.
+ * In addition to exposing some support within {@link EJBContainer},
+ * this makes available explicit user deployment and undeployment.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface JBossEJBContainer
+{
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Retrieve a naming context for looking up references to session beans
+ * executing in the embeddable container.
+ * @see {@link EJBContainer#getContext()}
+ */
+ Context getContext();
+
+ /**
+ * Shutdown an embeddable EJBContainer instance.
+ * Embeddable applications should always call close() in order to free up the resources
+ * associated with the embeddable container.
+ * @see {@link EJBContainer#close()}
+ */
+ void close();
+
+ /**
+ * Deploys the specified {@link Archive}s into the container
+ * @param archive
+ * @throws EJBDeploymentException
+ */
+ void deploy(Archive<?>... archives) throws EJBDeploymentException;
+
+ /**
+ * Undeploys the specified {@link Archive}s from the container
+ * @param archive
+ * @throws EJBDeploymentException
+ */
+ void undeploy(Archive<?>... archives) throws EJBDeploymentException;
+
+}
Modified: projects/ejb3/components/embedded/trunk/build/pom.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/build/pom.xml 2010-04-28 19:54:33 UTC (rev 104298)
+++ projects/ejb3/components/embedded/trunk/build/pom.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
- <version>4</version>
+ <version>5</version>
</parent>
<!-- Model Version -->
@@ -27,7 +27,13 @@
<properties>
<!-- Versioning -->
- <version.junit_junit>4.6</version.junit_junit>
+ <version.junit_junit>4.7</version.junit_junit>
+ <version.org.jboss.reloaded_jboss.reloaded.vdf.bootstrap.minimal>0.1.1</version.org.jboss.reloaded_jboss.reloaded.vdf.bootstrap.minimal>
+ <version.org.jboss.kernel>2.2.0.Alpha9</version.org.jboss.kernel>
+ <version.org.jboss.spec.javax.ejb_jboss-ejb-api_3.1_spec>1.0.0.Beta2</version.org.jboss.spec.javax.ejb_jboss-ejb-api_3.1_spec>
+ <version.org.jboss.logging>2.2.0.CR1</version.org.jboss.logging>
+ <version.org.jboss.shrinkwrap>1.0.0-alpha-9</version.org.jboss.shrinkwrap>
+ <version.org.jboss.vfs>3.0.0.CR5</version.org.jboss.vfs>
</properties>
@@ -77,7 +83,6 @@
<include>**/*UnitTest.java</include>
</includes>
<forkMode>always</forkMode>
- <reportFormat>xml</reportFormat>
</configuration>
</plugin>
@@ -128,7 +133,53 @@
<version>${version.junit_junit}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.reloaded</groupId>
+ <artifactId>jboss-reloaded-vdf-bootstrap-minimal</artifactId>
+ <version>${version.org.jboss.reloaded_jboss.reloaded.vdf.bootstrap.minimal}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>${version.org.jboss.kernel}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <version>${version.org.jboss.spec.javax.ejb_jboss-ejb-api_3.1_spec}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>${version.org.jboss.logging}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <version>${version.org.jboss.vfs}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-api</artifactId>
+ <version>${version.org.jboss.shrinkwrap}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-spi</artifactId>
+ <version>${version.org.jboss.shrinkwrap}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ <version>${version.org.jboss.shrinkwrap}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
Property changes on: projects/ejb3/components/embedded/trunk/impl-as
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
target-eclipse
.settings
.classpath
.project
Added: projects/ejb3/components/embedded/trunk/impl-as/pom.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-as/pom.xml (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-as/pom.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,55 @@
+<!--
+ vi:ts=2:sw=2:expandtab
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!-- Define Parent -->
+ <parent>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>embedded-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Maven POM Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Information -->
+ <artifactId>embedded-impl-as</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss EJB 3.1+ Embedded Implementation (Internals) for Application Server</name>
+ <description>Implementation Support for Embedded EJB 3.1+ Container within an AS Environment</description>
+
+ <!-- Build Configuration -->
+ <build>
+
+ </build>
+
+ <properties>
+
+ <!-- Versioning -->
+
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>embedded-impl-base</artifactId>
+ <version>${version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.reloaded</groupId>
+ <artifactId>jboss-reloaded-vdf-bootstrap-minimal</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+</project>
Added: projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/EmbeddedEJBContainerASAdaptor.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/EmbeddedEJBContainerASAdaptor.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/EmbeddedEJBContainerASAdaptor.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.as;
+
+import javax.ejb.embeddable.EJBContainer;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.bootstrap.api.mc.server.MCServer;
+
+/**
+ * Utility class providing static access to the {@link MCServer}
+ * and other facilities underpinning the JBoss implementation of
+ * the {@link EJBContainer} used within AS. Though an antipattern
+ * to expose these in a static manner, creation of {@link EJBContainer}s
+ * is, by spec, a static operation. This is therefore the single hook
+ * to the underlying wiring. Integration environments should inject the correct
+ * {@link MCServer} instance appropriately. Creating a new instance exposes
+ * the {@link MCServer} statically; once this has been done new requests for
+ * construction of another {@link EmbeddedEJBContainerASAdaptor} will
+ * fail with {@link IllegalStateException}
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public final class EmbeddedEJBContainerASAdaptor
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@link MCServer} instance handling all wiring of components which together
+ * will compose the JBoss Embedded EJB3 implementation.
+ */
+ private static volatile MCServer server;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new instance, but more importantly exposes the supplied {@link MCServer}
+ * in static fashion. Once called, subsequent requests for construction will fail with
+ * {@link IllegalStateException}.
+ *
+ * @param server The MC Server to make available statically. Must be supplied
+ * @throws IllegalArgumentException If the server is not specified
+ * @throws IllegalStateException If this has already been called
+ */
+ public EmbeddedEJBContainerASAdaptor(@Inject final MCServer server) throws IllegalStateException,
+ IllegalArgumentException
+ {
+ // So that we can't reset the MC Server
+ synchronized (this)
+ {
+ // Precondition checks
+ if (server == null)
+ {
+ throw new IllegalStateException("MC Server instance was not specified");
+ }
+
+ setMCServer(server);
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Utility Methods -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Returns the {@link MCServer} instance underpinning the JBoss {@link EJBContainer}
+ * implementation. May only be called after the server has been set, otherwise an
+ * {@link IllegalStateException} will be raised
+ *
+ * @throws IllegalStateException If the {@link MCServer} has not yet been set
+ */
+ static MCServer getMCServer() throws IllegalStateException
+ {
+ // Precondition checks
+ if (server == null)
+ {
+ throw new IllegalStateException("MC Server has not yet been set");
+ }
+
+ // Return
+ return server;
+ }
+
+ /**
+ * Sets the {@link MCServer} instance underpinning the JBoss {@link EJBContainer}
+ * implementation. May only be called once, otherwise a {@link IllegalStateException}
+ * will be raised. The specified kernel instance may not be null.
+ * @param server
+ * @throws IllegalStateException If the {@link MCServer} has already been set
+ * @throws IllegalArgumentException If the specified {@link MCServer} is null
+ */
+ private static void setMCServer(final MCServer server) throws IllegalStateException, IllegalArgumentException
+ {
+ // Precondition checks
+ if (server == null)
+ {
+ throw new IllegalArgumentException("MC Server instance may not be null");
+ }
+
+ if (EmbeddedEJBContainerASAdaptor.server != null)
+ {
+ throw new IllegalStateException("MC Server has already been set");
+ }
+
+ // Set
+ EmbeddedEJBContainerASAdaptor.server = server;
+ }
+
+}
Added: projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/JBossASEJBContainerProvider.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/JBossASEJBContainerProvider.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/JBossASEJBContainerProvider.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.as;
+
+import javax.ejb.embeddable.EJBContainer;
+
+import org.jboss.ejb3.embedded.impl.base.JBossEJBContainerProviderBase;
+import org.jboss.ejb3.embedded.impl.base.JBossEmbeddedContainerStartupParams;
+
+/**
+ *
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASEJBContainerProvider extends JBossEJBContainerProviderBase
+{
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.embedded.impl.base.JBossEJBContainerProviderBase#createEJBContainer(org.jboss.ejb3.embedded.impl.base.JBossEmbeddedContainerStartupParams)
+ */
+ @Override
+ public EJBContainer createEJBContainer(final JBossEmbeddedContainerStartupParams params)
+ {
+ return new JBossASEmbeddedEJBContainer(params.getProperties(), params.getModules());
+ }
+
+}
Added: projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/JBossASEmbeddedEJBContainer.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/JBossASEmbeddedEJBContainer.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-as/src/main/java/org/jboss/ejb3/embedded/impl/as/JBossASEmbeddedEJBContainer.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.as;
+
+import java.util.Map;
+
+import org.jboss.ejb3.embedded.impl.base.JBossEJBContainerBase;
+
+/**
+ *
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public final class JBossASEmbeddedEJBContainer extends JBossEJBContainerBase
+{
+
+ public JBossASEmbeddedEJBContainer(final Map<?, ?> properties, final String[] modules)
+ {
+ super(properties, modules, EmbeddedEJBContainerASAdaptor.getMCServer());
+ }
+
+ @Override
+ public void close()
+ {
+ // TODO
+
+ /*
+ * Here we've just created an adaptor to AS, so we cannot close or shutdown MC.
+ * We can either make close a NOOP, or set a flag to throw IllegalStateException
+ * or similar if other operations are invoked after close.
+ */
+
+ }
+
+}
Added: projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/META-INF/services/javax.ejb.spi.EJBContainerProvider
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/META-INF/services/javax.ejb.spi.EJBContainerProvider (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/META-INF/services/javax.ejb.spi.EJBContainerProvider 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1 @@
+org.jboss.ejb3.embedded.impl.as.JBossASEJBContainerProvider
\ No newline at end of file
Added: projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/embedded-ejb-as-adaptor-jboss-beans.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/embedded-ejb-as-adaptor-jboss-beans.xml (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-as/src/main/resources/embedded-ejb-as-adaptor-jboss-beans.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <!--
+ EJB/AS Adaptor
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+
+ <bean name="org.jboss.ejb3.EmbeddedEJBContainerASAdaptor"
+ class="org.jboss.ejb3.embedded.impl.as.EmbeddedEJBContainerASAdaptor">
+ <constructor>
+ <parameter name="server">
+ <inject />
+ </parameter>
+ </constructor>
+ </bean>
+
+</deployment>
\ No newline at end of file
Added: projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/jboss/ejb3/embedded/impl/as/EmbeddedEJBContainerExistingMCServerIntegrationUnitTest.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/jboss/ejb3/embedded/impl/as/EmbeddedEJBContainerExistingMCServerIntegrationUnitTest.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-as/src/test/java/org/jboss/ejb3/embedded/impl/as/EmbeddedEJBContainerExistingMCServerIntegrationUnitTest.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,189 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.as;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.ejb.embeddable.EJBContainer;
+
+import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.api.mc.server.MCServer;
+import org.jboss.bootstrap.api.mc.server.MCServerFactory;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.reloaded.api.ReloadedDescriptors;
+import org.jboss.vfs.VFS;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test cases ensuring that the Embedded {@link EJBContainer}
+ * can integrate with an existing {@link MCServer} in "hypervised"
+ * mode, as is the case within the JBoss Application Server.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class EmbeddedEJBContainerExistingMCServerIntegrationUnitTest
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(EmbeddedEJBContainerExistingMCServerIntegrationUnitTest.class
+ .getName());
+
+ /**
+ * Existing MC Server to which the Embedded {@link EJBContainer} will attach
+ */
+ private static MCServer server;
+
+ /**
+ * Filename of the jboss-beans XML which installs the {@link EmbeddedEJBContainerASAdaptor}
+ */
+ private static final String FILENAME_EMBEDDED_EJB_AS_ADAPTOR_XML = "embedded-ejb-as-adaptor-jboss-beans.xml";
+
+ /**
+ * Deployer used by the {@link MCServer}
+ */
+ private static MainDeployer deployer;
+
+ /**
+ * Deployment used in installing the AS / EJBContainer adaptor
+ */
+ private static Deployment deployment;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Setup JBossXB
+ * TODO @see comments below so that this step is not necessary
+ */
+ @BeforeClass
+ public static void setupJBossXb()
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Void>()
+ {
+ public Void run()
+ {
+ // Must use unordered sequence else JBossXB will explode
+ //TODO Define a proper vfs.xml which is properly ordered
+ System.setProperty(NAME_SYSPROP_JBOSSXB_IGNORE_ORDER, VALUE_SYSPROP_JBOSSXB_IGNORE_ORDER);
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Name of the system property signaling JBossXB to ignore order
+ */
+ private static final String NAME_SYSPROP_JBOSSXB_IGNORE_ORDER = "xb.builder.useUnorderedSequence";
+
+ /**
+ * Value to set for JBossXB ordering
+ */
+ private static final String VALUE_SYSPROP_JBOSSXB_IGNORE_ORDER = "true";
+
+ @BeforeClass
+ public static void startServer() throws Exception
+ {
+ // Create a server
+ final MCServer mcServer = MCServerFactory.createServer();
+
+ // Add the required bootstrap descriptors
+ final List<BootstrapDescriptor> descriptors = mcServer.getConfiguration().getBootstrapDescriptors();
+ descriptors.add(ReloadedDescriptors.getClassLoadingDescriptor());
+ descriptors.add(ReloadedDescriptors.getVdfDescriptor());
+
+ log.info("Using bootstrap descriptors:" + descriptors);
+
+ // Set
+ server = mcServer;
+
+ // Start
+ server.start();
+
+ final URL codebase = EmbeddedEJBContainerExistingMCServerIntegrationUnitTest.class.getProtectionDomain()
+ .getCodeSource().getLocation();
+ final URL classes = new URL(codebase, "../classes/");
+ final URL adaptorUrl = new URL(classes, FILENAME_EMBEDDED_EJB_AS_ADAPTOR_XML);
+
+ final Deployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(VFS.getChild(adaptorUrl));
+ EmbeddedEJBContainerExistingMCServerIntegrationUnitTest.deployment = deployment;
+ final MainDeployer deployer = (MainDeployer) server.getKernel().getController().getInstalledContext(
+ "MainDeployer").getTarget();
+ EmbeddedEJBContainerExistingMCServerIntegrationUnitTest.deployer = deployer;
+
+ deployer.deploy(deployment);
+ deployer.process();
+ deployer.checkComplete();
+ }
+
+ /**
+ * Stops the server before the test comes down
+ * @throws Exception
+ */
+ @AfterClass
+ public static void stopServer() throws Exception
+ {
+ // If started, stop the server
+ if (server != null && server.getState().equals(LifecycleState.STARTED))
+ {
+ deployer.undeploy(deployment);
+ deployer.process();
+ deployer.checkComplete();
+ server.stop();
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates an {@link JBossASEmbeddedEJBContainer}
+ */
+ @Test
+ public void createEJBContainer() throws Exception
+ {
+ final EJBContainer container = EJBContainer.createEJBContainer();
+ Assert.assertNotNull("Container was null", container);
+
+ Assert.assertTrue("Container is not of expected type", container instanceof JBossASEmbeddedEJBContainer);
+ JBossASEmbeddedEJBContainer jbossContainer = (JBossASEmbeddedEJBContainer) container;
+
+ }
+
+}
Added: projects/ejb3/components/embedded/trunk/impl-as/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-as/src/test/resources/log4j.xml (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-as/src/test/resources/log4j.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="INFO"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jnp">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jboss.ejb3.embedded">
+ <priority value="ALL"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Copied: projects/ejb3/components/embedded/trunk/impl-base (from rev 104196, projects/ejb3/components/embedded/trunk/impl)
Modified: projects/ejb3/components/embedded/trunk/impl-base/pom.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/impl/pom.xml 2010-04-23 12:57:42 UTC (rev 104196)
+++ projects/ejb3/components/embedded/trunk/impl-base/pom.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -17,10 +17,10 @@
<modelVersion>4.0.0</modelVersion>
<!-- Artifact Information -->
- <artifactId>embedded-impl</artifactId>
+ <artifactId>embedded-impl-base</artifactId>
<packaging>jar</packaging>
- <name>JBoss EJB 3.1+ Embedded Implementation (Internals)</name>
- <description>Implementation Support for Embedded EJB 3.1+ Container</description>
+ <name>JBoss EJB 3.1+ Embedded Base Implementation (Internals)</name>
+ <description>Implementation Base Support for Embedded EJB 3.1+ Container</description>
<!-- Build Configuration -->
<build>
@@ -28,16 +28,43 @@
</build>
<properties>
-
- <!-- Versioning -->
-
+
</properties>
<dependencies>
- <!--
- Dependencies: org.jboss.ejb3
- -->
+ <dependency>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>embedded-spi</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.reloaded</groupId>
+ <artifactId>jboss-reloaded-vdf-bootstrap-minimal</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
Added: projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerBase.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerBase.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerBase.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,301 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.base;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.bootstrap.api.mc.server.MCServer;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.ejb3.embedded.api.EJBDeploymentException;
+import org.jboss.ejb3.embedded.api.JBossEJBContainer;
+import org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner;
+import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Base for JBoss {@link EJBContainer}s. Provides
+ * support for deployment operations backed by a supplied {@link MCServer}
+ * to be provided by concrete implementations.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class JBossEJBContainerBase extends EJBContainer implements JBossEJBContainer
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(JBossEJBContainerBase.class);
+
+ /**
+ * Name in MC under which the {@link MainDeployer} is bound
+ */
+ private static final String MC_BIND_NAME_MAIN_DEPLOYER = "MainDeployer";
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Underlying deployer installed into the {@link JBossEJBContainerBase#mcServer}
+ */
+ private final MainDeployer deployer;
+
+ /**
+ * Underlying MC Server
+ */
+ private final MCServer mcServer;
+
+ /**
+ * All deployments currently installed via this container
+ */
+ private final Set<Deployment> deployments;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ protected JBossEJBContainerBase(final Map<?, ?> properties, final String[] modules, final MCServer server)
+ {
+ // Precondition checks
+ if (server == null)
+ {
+ throw new IllegalArgumentException("MC Server must be specified");
+ }
+
+ // Obtain MainDeployer
+ final Kernel kernel = server.getKernel();
+ final MainDeployer deployer = (MainDeployer) kernel.getController().getInstalledContext(
+ MC_BIND_NAME_MAIN_DEPLOYER).getTarget();
+ assert deployer != null : "Main Deployer found in the Kernel was null";
+
+ log.info("Started JBoss Embedded " + EJBContainer.class.getSimpleName());
+ log.info("Modules for deployment: " + Arrays.asList(modules));
+
+ // Set
+ this.mcServer = server;
+ this.deployer = deployer;
+ this.deployments = new HashSet<Deployment>();
+ }
+
+ protected JBossEJBContainerBase(final Map<?, ?> properties, final MCServer server)
+ {
+ this(properties, ClassPathEjbJarScanner.getEjbJars(), server);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Deploys the specified {@link Deployment}s into the Container
+ *
+ * @param deployments One or more {@link Deployment}s to process
+ * @throws DeploymentException If an error occured in deployment
+ * @throws IllegalArgumentException If at least one {@link Deployment} was not specified
+ */
+ protected void deploy(final Deployment... deployments) throws EJBDeploymentException, IllegalArgumentException
+ {
+ // Precondition checks
+ if (deployments == null || deployments.length == 0)
+ {
+ throw new IllegalArgumentException("At least one deployment must be specified");
+ }
+
+ // Mark deployments added
+ final Set<Deployment> deploymentsAdded = new HashSet<Deployment>();
+
+ // Add all deployments
+ for (final Deployment deployment : deployments)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.tracef("Adding deployment: ", deployment);
+ }
+ try
+ {
+ // Add to the deployer
+ deployer.addDeployment(deployment);
+
+ // Mark we've added this
+ deploymentsAdded.add(deployment);
+ }
+ catch (final DeploymentException mainDeploymentException)
+ {
+ // Remove the pending deployments
+ for (final Deployment pending : deploymentsAdded)
+ {
+ try
+ {
+ deployer.removeDeployment(pending);
+ }
+ catch (final DeploymentException pendingDeploymentRemovalException)
+ {
+ log.warn("Could not back out pending deployment due to " + pendingDeploymentRemovalException
+ + " while handing deployment error: " + mainDeploymentException);
+ }
+ }
+
+ // Translate exception to our API
+ throw EJBDeploymentException
+ .newInstance("Could not add deployment: " + deployment, mainDeploymentException);
+ }
+ }
+
+ // Process and ensure everything's OK
+ deployer.process();
+ try
+ {
+ deployer.checkComplete();
+ }
+ catch (final DeploymentException e)
+ {
+ throw EJBDeploymentException.newInstance("Processing the pending deployments resulted in error", e);
+ }
+
+ // Mark we've got new deployments
+ this.deployments.addAll(deploymentsAdded);
+
+ }
+
+ /**
+ * Deploys the specified {@link URL}s into the Container
+ *
+ * @param urls URLs to deploy; at least one must be specified
+ * @throws DeploymentException If an error occurred during deployment
+ * @throws IOException
+ * @throws IllegalArgumentException
+ */
+ protected void deploy(final URL... urls) throws EJBDeploymentException, IllegalArgumentException
+ {
+ // Precondition checks
+ if (urls == null || urls.length == 0)
+ {
+ throw new IllegalArgumentException("At least one URL for deployment must be specified");
+ }
+
+ // Hold the deployments
+ final Deployment[] deployments = new Deployment[urls.length];
+
+ // For each URL, make a Deployment
+ for (int i = 0; i < urls.length; i++)
+ {
+ final URL url = urls[i];
+ final VirtualFile root;
+ try
+ {
+ root = VFS.getChild(url);
+ }
+ catch (final URISyntaxException urise)
+ {
+ throw new RuntimeException("Could not create a virtual file to deploy from URL: " + url, urise);
+ }
+ final VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(root);
+ deployments[i] = deployment;
+ }
+
+ // Delegate to real deployment
+ this.deploy(deployments);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.embedded.api.JBossEJBContainer#deploy(org.jboss.shrinkwrap.api.Archive<?>[])
+ */
+ @Override
+ public void deploy(final Archive<?>... archives) throws EJBDeploymentException
+ {
+ //TODO
+ throw new UnsupportedOperationException("Not yet implemented; to delegate to the Reloaded ShrinkWrapDeployer");
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.embedded.api.JBossEJBContainer#undeploy(org.jboss.shrinkwrap.api.Archive<?>[])
+ */
+ @Override
+ public void undeploy(final Archive<?>... archives) throws EJBDeploymentException
+ {
+ //TODO
+ throw new UnsupportedOperationException("Not yet implemented; to delegate to the Reloaded ShrinkWrapDeployer");
+ }
+
+ /**
+ * Exposes the underlying {@link MCServer} to children; take care not to expose this to
+ * end users (clients).
+ *
+ * @return
+ */
+ protected MCServer getMCServer()
+ {
+ return mcServer;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see javax.ejb.embeddable.EJBContainer#getContext()
+ */
+ @Override
+ public Context getContext()
+ {
+ //TODO
+ // We could return this assuming the naming system is up, as one idea (probably cache the context)
+ try
+ {
+ new InitialContext();
+ }
+ catch (final NamingException e)
+ {
+ throw new RuntimeException("Could not create new naming context", e);
+ }
+ // Just throw an exception for now
+ throw new UnsupportedOperationException("IMPLEMENT");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle Methods ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+}
Added: projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerProviderBase.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerProviderBase.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerProviderBase.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.base;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.ejb.EJBException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.ejb.spi.EJBContainerProvider;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Base support for JBoss {@link EJBContainerProvider}
+ * implementations. Responsible for parsing all properties
+ * into an encapsulated {@link JBossEmbeddedContainerStartupParams} object which
+ * will be used to instantiate the real container provider impl.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class JBossEJBContainerProviderBase implements EJBContainerProvider
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(JBossEJBContainerProviderBase.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see javax.ejb.spi.EJBContainerProvider#createEJBContainer(java.util.Map)
+ */
+ @Override
+ public EJBContainer createEJBContainer(Map<?, ?> properties) throws EJBException
+ {
+ // Normally we'd prohibit null inputs as a precondition check, but the spec doesn't
+ // specify that properties are required. So set new ones.
+ if (properties == null)
+ {
+ properties = Collections.emptyMap();
+ }
+
+ /*
+ * Ensure we qualify as a valid implementation class
+ * 1) Our impl class is equal to the value of "javax.ejb.embeddable.initial"
+ * 2) No "avax.ejb.embeddable.provider" property was specified
+ * (Note: http://wiki.jcp.org/boards/index.php?t=4468)
+ */
+ final String providerProp = EJBContainer.PROVIDER;
+ final Object requestedImplClassValue = properties.get(providerProp);
+ // If a provider was explicitly-defined
+ if (requestedImplClassValue != null)
+ {
+ // Ensure the right type was provided
+ if (!(requestedImplClassValue instanceof String))
+ {
+ log.warn("Obtained propety \"" + providerProp + "\" should be the String FQN of a provider, instead got: "
+ + requestedImplClassValue + ". Ignoring.");
+ }
+ // See if the requested FQN is us
+ final String requestedImplClassFqn = (String) requestedImplClassValue;
+ if (!this.getClass().getName().equals(requestedImplClassFqn))
+ {
+ // Requested another provider, return null per spec orders
+ log.warn("Got explicit requested provider \"" + requestedImplClassFqn
+ + "\", so returning null from this provider: " + this);
+ return null;
+ }
+ }
+
+ // Create a container
+ try
+ {
+ String modules[] = null;
+ if (properties != null)
+ {
+ Object o = properties.get(EJBContainer.MODULES);
+ if (o != null)
+ {
+ if (o instanceof String)
+ modules = new String[]
+ {(String) o};
+ else if (o instanceof Collection<?>)
+ modules = toStringArray(o);
+ else
+ throw new EJBException("Illegal type of " + EJBContainer.MODULES + " (" + o.getClass().getName()
+ + ") (EJB 3.1 22.2.2.2)");
+ }
+ }
+
+ // Create the container from the parameters
+ final JBossEmbeddedContainerStartupParams params = new JBossEmbeddedContainerStartupParams(properties, modules);
+ return this.createEJBContainer(params);
+ }
+ catch (final Throwable t)
+ {
+ if (t instanceof Error)
+ throw (Error) t;
+ if (t instanceof RuntimeException)
+ throw (RuntimeException) t;
+ if (t instanceof Exception)
+ throw new EJBException((Exception) t);
+ throw new RuntimeException(t);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static final String[] toStringArray(Object o)
+ {
+ return ((Collection<String>) o).toArray(new String[0]);
+ }
+
+ /**
+ *
+ * @param params
+ * @return
+ */
+ public abstract EJBContainer createEJBContainer(final JBossEmbeddedContainerStartupParams params);
+
+}
Added: projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEmbeddedContainerStartupParams.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEmbeddedContainerStartupParams.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/JBossEmbeddedContainerStartupParams.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.base;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ejb.embeddable.EJBContainer;
+
+import org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner;
+import org.jboss.logging.Logger;
+
+/**
+ * Value object encapsulating the constructor parameters
+ * required to create a new {@link JBossEJBContainerBase}
+ * extension instance.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossEmbeddedContainerStartupParams
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(JBossEmbeddedContainerStartupParams.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Spec-defined and JBoss-specific properties used in creating
+ * new JBoss {@link EJBContainer} instances. To be defensively copied
+ * and set as immutable during construction.
+ */
+ private final Map<?, ?> properties;
+
+ /**
+ * Value of {@link EJBContainer#MODULES} used to denote the
+ * initial deployments to be processed by the Container. To be defensively
+ * copied during construction and copied as returned to the caller.
+ */
+ private final String[] modules;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new instance using the specified properties and deployment modules
+ *
+ * @param properties Properties used in constructing the {@link EJBContainer}. If null,
+ * a new, empty {@link Map} will be allocated
+ * @param modules Modules to deploy into the {@link EJBContainer}. A null argument here
+ * signals that the ClassPath should be searched for EJB Modules as defined by {@link EJBContainer#createEJBContainer()}
+ * and EJB 3.1 22.2.1.
+ */
+ public JBossEmbeddedContainerStartupParams(Map<?, ?> properties, String[] modules)
+ {
+ // Precondition checks and adjustments
+ if (properties == null)
+ {
+ properties = new HashMap<Object, Object>(0);
+ }
+ if (modules == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("No modules explicitly passed in; scanning ClassPath for EJBs");
+ }
+ modules = ClassPathEjbJarScanner.getEjbJars();
+ }
+
+ // Defensive copy and set
+ final Map<?, ?> copy = new HashMap<Object, Object>(properties);
+ this.properties = Collections.unmodifiableMap(copy);
+
+ final String[] copyModules = copy(modules);
+ this.modules = copyModules;
+
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Accessors --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Returns an immutable view of the construction properties
+ * used to create the container
+ * @return the properties
+ */
+ public Map<?, ?> getProperties()
+ {
+ return properties;
+ }
+
+ /**
+ * Returns a copy of the value of {@link EJBContainer#MODULES} property
+ * @return the modules
+ */
+ public String[] getModules()
+ {
+ // Return null or a copy
+ return modules == null ? null : copy(modules);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Copies the specified array into a new object, returning the new instance
+ */
+ private String[] copy(final String[] original)
+ {
+ return Arrays.copyOf(original, original.length);
+ }
+
+}
Added: projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/ClassPathEjbJarScanner.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/ClassPathEjbJarScanner.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/ClassPathEjbJarScanner.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,375 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.base.scanner;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+import javax.ejb.MessageDriven;
+import javax.ejb.Singleton;
+import javax.ejb.Stateful;
+import javax.ejb.Stateless;
+
+import org.jboss.logging.Logger;
+import org.jboss.vfs.TempFileProvider;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Implements JVM ClassPath scanning for EJB JARs as defined
+ * by EJB 3.1 Final Draft 22.2.1. This is a static utility
+ * class which is not to be instantiated.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ClassPathEjbJarScanner
+{
+
+ //TODO
+ /*
+ * This is an intentionally naive implementation which essentially
+ * amounts to junkware. It gets us to the next phases of development,
+ * but isn't intended to be the final solution.
+ *
+ * Open issues:
+ *
+ * 1) Don't load all Classes to look for annotations. Vie for ASM or Javassist (or
+ * other bytecode analyzer). Or pass through an isolated VDF Deployer chain and let the
+ * deployers figure out what the eligible modules are
+ * 2) Extract out a configurable set of ExclusionFilters which can determine if a given
+ * root should be skipped (ie. for JUnit or JBossAS binaries)
+ * 3) Define a configurable ScheduledExecutorService to back the TempFileProvider
+ * used to mount ZIP VFS roots. If we go the deployer chain route as noted by 1) this
+ * won't be necessary
+ */
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ClassPathEjbJarScanner.class);
+
+ /**
+ * System property key denoting the JVM ClassPath
+ */
+ private static final String SYS_PROP_KEY_CLASS_PATH = "java.class.path";
+
+ /**
+ * Dummy String array used in converting a {@link Collection} of {@link String} to a typed array
+ */
+ private static final String[] DUMMY = new String[]
+ {};
+
+ /**
+ * Path of the EJB Descriptor, relative to the root of a deployment
+ */
+ private static final String PATH_EJB_JAR_XML = "META-INF/ejb-jar.xml";
+
+ /**
+ * .class Extension
+ */
+ private static final String EXTENSION_CLASS = ".class";
+
+ /**
+ * .jar Extension
+ */
+ private static final String EXTENSION_JAR = ".jar";
+
+ /**
+ * EJB Component-defining annotations
+ */
+ @SuppressWarnings("unchecked")
+ private static final Class<? extends Annotation>[] EJB_COMPONENT_ANNOTATIONS = (Class<? extends Annotation>[]) new Class<?>[]
+ {Stateless.class, Stateful.class, Singleton.class, MessageDriven.class};
+
+ /**
+ * {@link ScheduledExecutorService} to mount files to be scanned
+ */
+ @Deprecated
+ //TODO Get some reusable, configurable real SES (as managed by the container) else we'll block on JVM shutdown;
+ // this one is never shut down cleanly
+ private static final ScheduledExecutorService ses = Executors.newScheduledThreadPool(Runtime.getRuntime()
+ .availableProcessors());
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Internal Constructor, no instances permitted
+ */
+ private ClassPathEjbJarScanner()
+ {
+ throw new UnsupportedOperationException("No instances permitted");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains all EJB JAR entries from the ClassPath
+ */
+ public static String[] getEjbJars()
+ {
+
+ // Initialize
+ final Collection<String> returnValue = new ArrayList<String>();
+
+ // Get the full ClassPath
+ final String classPath = SecurityActions.getSystemProperty(SYS_PROP_KEY_CLASS_PATH);
+ if (log.isTraceEnabled())
+ {
+ log.tracef("Class Path: %s", classPath);
+ }
+
+ // Split by the path separator character
+ final String[] classPathEntries = classPath.split(File.pathSeparator);
+
+ // For each CP entry
+ for (final String classPathEntry : classPathEntries)
+ {
+ // If this is an EJB JAR
+ if (isEjbJar(classPathEntry))
+ {
+ // Add to be returned
+ returnValue.add(classPathEntry);
+ }
+ }
+
+ // Return
+ if (log.isDebugEnabled())
+ {
+ log.debug("EJB Modules discovered on ClassPath: " + returnValue);
+ }
+ return returnValue.toArray(DUMMY);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Determines whether this entry from the ClassPath is an EJB JAR
+ */
+ private static boolean isEjbJar(final String candidate)
+ {
+
+ /*
+ * EJB 3.1 22.2.1:
+ *
+ * A classpath entry is considered a matching entry if it meets one of the following criteria:
+ * - It is an ejb-jar according to the standard module-type identification rules defined by the Java
+ * EE platform specification
+ * - It is a directory containing a META-INF/ejb-jar.xml file or at least one .class with an enterprise
+ * bean component-defining annotation
+ */
+
+ // Represent as VFS so we get a nice unified API
+ final VirtualFile file = VFS.getChild(candidate);
+ Closeable handle = null;
+ TempFileProvider provider = null;
+
+ try
+ {
+
+ // If the file exists
+ if (file.exists())
+ {
+ // Mount Exploded dir
+ if (file.isDirectory())
+ {
+ handle = VFS.mountReal(file.getPhysicalFile(), file);
+ }
+ // Mount EJB JAR
+ else if (file.getName().endsWith(EXTENSION_JAR))
+ {
+ if (provider == null)
+ {
+ provider = TempFileProvider.create("jbossejbmodulescanner", ses);
+ }
+ handle = VFS.mountZip(file.getPhysicalFile(), file, provider);
+ }
+ // No conditions met
+ else
+ {
+ return false;
+ }
+ }
+ // Not a real file
+ else
+ {
+ log.warn("File on ClassPath could not be found: " + file);
+ return false;
+ }
+
+ }
+ catch (final IOException e)
+ {
+ throw new RuntimeException("Could not mount file from ClassPath for EJB JAR module scanning", e);
+ }
+
+ try
+ {
+ /*
+ * Directories and real JARs are handled the same way in VFS, so just do
+ * one check and skip logic to test isDirectory or not
+ */
+
+ // Look for META-INF/ejb-jar.xml
+ final VirtualFile ejbJarXml = file.getChild(PATH_EJB_JAR_XML);
+ if (ejbJarXml.exists())
+ {
+ if (log.isTraceEnabled())
+ {
+ log.tracef("Found descriptor %s in %s", ejbJarXml.getPathNameRelativeTo(file), file);
+ }
+ return true;
+ }
+
+ // Look for at least one .class with an EJB annotation
+ if (containsEjbComponentClass(file))
+ {
+ return true;
+ }
+
+ // Return
+ return false;
+ }
+ finally
+ {
+ try
+ {
+ handle.close();
+ }
+ catch (final IOException e)
+ {
+ // Ignore
+ log.warn("Could not close handle to mounted " + file, e);
+ }
+ }
+ }
+
+ /**
+ * Determines if there is at least one .class in the given file
+ * with an EJB component-defining annotation (Stateless, Stateful,
+ * Singleton, MessageDriven)
+ * @param file
+ * @return
+ * @deprecated Use a real implementation scanner
+ */
+ @Deprecated
+ private static boolean containsEjbComponentClass(final VirtualFile file)
+ {
+ return containsEjbComponentClass(file, file);
+ }
+
+ /**
+ * Determines if there is at least one .class in the given file
+ * with an EJB component-defining annotation (Stateless, Stateful,
+ * Singleton, MessageDriven).
+ * @param root The original root from which we started the search
+ * @param file
+ * @return
+ * @deprecated Use a real implementation scanner
+ */
+ @Deprecated
+ private static boolean containsEjbComponentClass(final VirtualFile root, final VirtualFile file)
+ {
+
+ // Precondition check
+ assert file != null : "File must be specified";
+
+ // For all children
+ for (final VirtualFile child : file.getChildren())
+ {
+ if (child.isDirectory())
+ {
+ // Determine if there's one in the child
+ final boolean foundInChild = containsEjbComponentClass(root, child);
+ if (foundInChild)
+ {
+ return true;
+ }
+ }
+
+ // Get the Class for all .class files
+ final String childName = child.getPathNameRelativeTo(root);
+ if (childName.endsWith(EXTENSION_CLASS))
+ {
+ final String className = childName.substring(0, childName.length() - EXTENSION_CLASS.length()).replace('/',
+ '.');
+
+ // Here's the naughty part; loading the Class (which we really don't need to do, just inspect for annotations)
+ Class<?> clazz = null;
+ try
+ {
+ clazz = Class.forName(className, false, SecurityActions.getTccl());
+ }
+ catch (final ClassNotFoundException cnfe)
+ {
+ throw new RuntimeException("Found .class on ClassPath which could not be found by the TCCL", cnfe);
+ }
+ catch (final NoClassDefFoundError ncdfe)
+ {
+ // Ugly ugly hack, Eclipse IDE JUnit runner puts stuff on the CP which can't be loaded
+ // This will be solved by a configurable exclusion filter so we don't look in the root
+ // in the first place.
+ log.warnf("Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to %s", ncdfe
+ .toString());
+ }
+
+ // Determine if we have a class with an EJB component annotation
+ if (clazz != null)
+ {
+ for (final Class<? extends Annotation> annotationClass : EJB_COMPONENT_ANNOTATIONS)
+ {
+ if (clazz.isAnnotationPresent(annotationClass))
+ {
+ if (log.isTraceEnabled())
+ {
+ log.tracef("Found %s on %s in %s", annotationClass, clazz, root);
+ }
+ return true;
+ }
+ }
+ }
+
+ }
+
+ }
+
+ // No conditions met, so false
+ return false;
+ }
+}
Added: projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/SecurityActions.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/SecurityActions.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/SecurityActions.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.base.scanner;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Internal security actions not to escape
+ * this package; contains utilities to access
+ * privileged actions.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+class SecurityActions
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Blocks instanciation
+ */
+ private SecurityActions()
+ {
+ throw new UnsupportedOperationException("No instances permitted");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the system property of the specified key
+ *
+ * @param key
+ */
+ static String getSystemProperty(final String key)
+ {
+ assert key != null && key.length() > 0 : "Key must be specified";
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ @Override
+ public String run()
+ {
+ return System.getProperty(key);
+ }
+ });
+ }
+
+ /**
+ * Returns the Thread Context {@link ClassLoader}
+ * @return
+ */
+ static ClassLoader getTccl()
+ {
+ return AccessController.doPrivileged(GetTcclAction.INSTANCE);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Members ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@link PrivilegedAction} implementation to obtain the TCCL
+ */
+ private enum GetTcclAction implements PrivilegedAction<ClassLoader> {
+ INSTANCE;
+
+ @Override
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ }
+
+}
Added: projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/filter/BundleSymbolicNameExclusionFilter.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/filter/BundleSymbolicNameExclusionFilter.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-base/src/main/java/org/jboss/ejb3/embedded/impl/base/scanner/filter/BundleSymbolicNameExclusionFilter.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.base.scanner.filter;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.ejb3.embedded.spi.scanner.filter.ExclusionFilter;
+import org.jboss.logging.Logger;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * {@link ExclusionFilter} implementation which
+ * will block OSGi bundles with the header "Bundle-SymbolicName"
+ * if the value matches one in a configurable set.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class BundleSymbolicNameExclusionFilter implements ExclusionFilter
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(BundleSymbolicNameExclusionFilter.class);
+
+ /**
+ * Key of the bundle symbolic name header
+ */
+ private static final String HEADER_BUNDLE_SYMBOLIC_NAME = "Bundle-SymbolicName";
+
+ /**
+ * Location of the manifest file under the root
+ */
+ private static final String NAME_MANIFEST = "META-INF/MANIFEST.MF";
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Patterns to exclude if present in value of the bundle symbolic name header
+ */
+ private final Set<String> exclusionValues;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new instance configured to the specified exclusion values
+ * @param exclusionValues Patterns to exclude if present in the bundle symbolic name header
+ * @throws IllegalArgumentException If no exclusions are specified
+ */
+ public BundleSymbolicNameExclusionFilter(final String... exclusionValues) throws IllegalArgumentException
+ {
+ // Precondition check
+ if (exclusionValues == null || exclusionValues.length == 0)
+ {
+ throw new IllegalArgumentException("one or more exclusion values must be specified");
+ }
+
+ // Defensive copy on set and make immutable
+ final Set<String> excludeSet = new HashSet<String>();
+ for (final String exclusionValue : exclusionValues)
+ {
+ excludeSet.add(exclusionValue);
+ }
+ this.exclusionValues = Collections.unmodifiableSet(excludeSet);
+
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.embedded.spi.scanner.filter.ExclusionFilter#exclude(org.jboss.vfs.VirtualFile)
+ */
+ @Override
+ public boolean exclude(final VirtualFile file)
+ {
+ // Precondition checks
+ if (file == null)
+ {
+ throw new IllegalArgumentException("file must be specified");
+ }
+
+ // If this exists, first of all
+ if (!file.exists())
+ {
+ return false;
+ }
+
+ // Get the Manifest
+ final VirtualFile manifest = file.getChild(NAME_MANIFEST);
+ if (!manifest.exists())
+ {
+ return false;
+ }
+
+ // Inspect the manifest contents
+ //TODO Left off here
+
+ // No conditions met
+ return false;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+}
Added: projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerProviderUnitTest.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerProviderUnitTest.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/JBossEJBContainerProviderUnitTest.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.base;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.ejb.spi.EJBContainerProvider;
+import javax.naming.Context;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Ensures the {@link JBossEJBContainerProviderBase}
+ * is working as contracted
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossEJBContainerProviderUnitTest
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that setting the provider property to another
+ * provider than the one in use results in a null
+ * {@link EJBContainer}
+ */
+ @Test
+ public void rejectsIncorrectExplicitProviderProperty()
+ {
+ // Request a container using a dummy provider FQN
+ final EJBContainer container = this.createEJBContainerUsingProvider("dummyValue");
+
+ // Ensure we didn't get a container back; we requested a dummy provider value
+ Assert.assertNull("Explicit provider property not met by current provider should return a null container",
+ container);
+
+ }
+
+ /**
+ * Ensures that setting the explicit provider property
+ * to the current provider results in creation of an {@link EJBContainer}
+ */
+ @Test
+ public void allowsMatchingExplicitProviderProperty()
+ {
+ // Request a container using a dummy provider FQN
+ final EJBContainer container = this
+ .createEJBContainerUsingProvider(TestJBossEJBContainerProvider.class.getName());
+
+ // Ensure we didn't get a container back; we requested a dummy provider value
+ Assert.assertNotNull("Explicit provider property set to the current provider should return an EJB Container",
+ container);
+
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Uses the test {@link EJBContainerProvider} to create a new EJB Container using the given
+ * provider fully-qualified name
+ */
+ private EJBContainer createEJBContainerUsingProvider(final String providerFqn)
+ {
+ // Precondition check
+ assert providerFqn != null && providerFqn.length() > 0 : "Provider FQN must be specified";
+
+ // Set an explicit provider
+ final String providerPropName = EJBContainer.PROVIDER;
+ final String providerPropValue = providerFqn;
+ final Map<String, String> props = new HashMap<String, String>();
+ props.put(providerPropName, providerPropValue);
+
+ // Make the provider
+ final EJBContainerProvider provider = new TestJBossEJBContainerProvider();
+
+ // Request a container
+ final EJBContainer container = provider.createEJBContainer(props);
+ return container;
+ }
+
+ /**
+ * Concrete {@link EJBContainerProvider} implementation using {@link JBossEJBContainerProviderBase}
+ * support.
+ */
+ private static class TestJBossEJBContainerProvider extends JBossEJBContainerProviderBase
+ {
+
+ /**
+ * @see org.jboss.ejb3.embedded.impl.base.JBossEJBContainerProviderBase#createEJBContainer(org.jboss.ejb3.embedded.impl.base.JBossEmbeddedContainerStartupParams)
+ */
+ @Override
+ public EJBContainer createEJBContainer(final JBossEmbeddedContainerStartupParams params)
+ {
+ // Just return some mock
+ return new EJBContainer()
+ {
+
+ @Override
+ public Context getContext()
+ {
+ return null;
+ }
+
+ @Override
+ public void close()
+ {
+ }
+ };
+ }
+
+ }
+}
Added: projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/scanner/ClassPathEjbJarScannerUnitTest.java
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/scanner/ClassPathEjbJarScannerUnitTest.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-base/src/test/java/org/jboss/ejb3/embedded/impl/base/scanner/ClassPathEjbJarScannerUnitTest.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,272 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.impl.base.scanner;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import javax.ejb.MessageDriven;
+import javax.ejb.Singleton;
+import javax.ejb.Stateful;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner;
+import org.jboss.logging.Logger;
+import org.jboss.shrinkwrap.api.Asset;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.exporter.ExplodedExporter;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests fo ensure that the {@link ClassPathEjbJarScanner} is working
+ * as contracted to fulfill the EJB 3.1 Specification
+ * 22.2.1
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ClassPathEjbJarScannerUnitTest
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ClassPathEjbJarScannerUnitTest.class);
+
+ /**
+ * System property key denoting the JVM ClassPath
+ */
+ private static final String SYS_PROP_KEY_CLASS_PATH = "java.class.path";
+
+ /**
+ * EJB JAR containing @Stateless
+ */
+ private static final String NAME_JAR_SLSB = "slsb.jar";
+
+ /**
+ * EJB JAR containing @Stateful
+ */
+ private static final String NAME_JAR_SFSB = "sfsb.jar";
+
+ /**
+ * EJB JAR containing @Singleton
+ */
+ private static final String NAME_JAR_SINGLETON = "singleton.jar";
+
+ /**
+ * EJB JAR containing @MessageDriven
+ */
+ private static final String NAME_JAR_MDB = "mdb.jar";
+
+ /**
+ * EJB JAR containing a POJO with no descriptor (should not be detected as an EJB Module)
+ */
+ private static final String NAME_JAR_POJO = "pojo.jar";
+
+ /**
+ * EJB JAR containing a POJO with a descriptor
+ */
+ private static final String NAME_JAR_POJO_WITH_DESCRIPTOR = "descriptor.jar";
+
+ /**
+ * The ClassPath entries expected to be reported as modules
+ */
+ private static final Collection<String> expectedEjbJarClassPathEntries = new ArrayList<String>();
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a series of test EJB JARs and exploded directories to
+ * be scanned as valid EJB modules
+ */
+ @BeforeClass
+ public static void createTestEJBJarsAndDirs() throws Exception
+ {
+
+ // Create a bunch of test Archives
+ final Collection<JavaArchive> archives = new ArrayList<JavaArchive>();
+ archives.add(ShrinkWrap.create(NAME_JAR_SLSB, JavaArchive.class).addClass(Slsb.class));
+ archives.add(ShrinkWrap.create(NAME_JAR_SFSB, JavaArchive.class).addClass(Sfsb.class));
+ archives.add(ShrinkWrap.create(NAME_JAR_SINGLETON, JavaArchive.class).addClass(Singleton1.class));
+ archives.add(ShrinkWrap.create(NAME_JAR_MDB, JavaArchive.class).addClass(Mdb.class));
+ archives.add(ShrinkWrap.create(NAME_JAR_POJO, JavaArchive.class).addClass(Pojo.class));
+ archives.add(ShrinkWrap.create(NAME_JAR_POJO_WITH_DESCRIPTOR, JavaArchive.class).addClass(Pojo.class)
+ .addManifestResource(new Asset()
+ {
+
+ @Override
+ public InputStream openStream()
+ {
+ return new ByteArrayInputStream(new byte[]
+ {});
+ }
+ }, "ejb-jar.xml"));
+
+ // Flush these out to disk in both JAR and Exploded format
+ final URL shrinkwrapOutputUrl = new URL(ClassPathEjbJarScannerUnitTest.class.getProtectionDomain()
+ .getCodeSource().getLocation(), "../shrinkwrap");
+ final File shrinkwrapOutputDir = new File(shrinkwrapOutputUrl.toURI());
+ rm(shrinkwrapOutputDir);
+ final File shrinkwrapOutputDirJars = new File(shrinkwrapOutputDir, "jars");
+ final File shrinkwrapOutputDirExploded = new File(shrinkwrapOutputDir, "exploded");
+ shrinkwrapOutputDirJars.mkdirs();
+ shrinkwrapOutputDirExploded.mkdirs();
+ final Collection<File> classPathFileEntries = new ArrayList<File>();
+ for (final JavaArchive archive : archives)
+ {
+ // Log
+ log.info(archive.toString(true));
+ // Export as JAR
+ final File jar = new File(shrinkwrapOutputDirJars, archive.getName());
+ archive.as(ZipExporter.class).exportZip(jar, true);
+ classPathFileEntries.add(jar);
+ // Export as exploded directory
+ archive.as(ExplodedExporter.class).exportExploded(shrinkwrapOutputDirExploded);
+ classPathFileEntries.add(new File(shrinkwrapOutputDirExploded, archive.getName()));
+ }
+
+ // Set the ClassPath
+ final StringBuilder sb = new StringBuilder();
+ for (final File classPathFileEntry : classPathFileEntries)
+ {
+ sb.append(classPathFileEntry);
+ sb.append(File.pathSeparatorChar);
+ }
+ log.info("Test ClassPath to be scanned: " + sb.toString());
+ System.setProperty(SYS_PROP_KEY_CLASS_PATH, sb.toString());
+
+ // Build the expected CP entries
+ for (final File classPathFileEntry : classPathFileEntries)
+ {
+ final String classPathFileEntryName = classPathFileEntry.getAbsolutePath();
+ if (!classPathFileEntry.toString().contains(NAME_JAR_POJO))
+ {
+ expectedEjbJarClassPathEntries.add(classPathFileEntryName);
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Tests that the EJB Modules found on the ClassPath by the {@link ClassPathEjbJarScanner}
+ * are as expected
+ */
+ @Test
+ public void obtainsEjbJarModulesFromClassPath()
+ {
+ // Get entries identified as modules from the ClassPath
+ final List<String> ejbModulesFromClassPath = Arrays.asList(ClassPathEjbJarScanner.getEjbJars());
+
+ // Ensure the size (we should have 10 modules defined)
+ Assert.assertEquals("EJB Modules found on ClassPath isn't of expected size", 10, ejbModulesFromClassPath.size());
+
+ // Ensure all expected modules are found
+ for (final String expectedToBeFound : expectedEjbJarClassPathEntries)
+ {
+ Assert.assertTrue("Expected EJB module was not found by ClassPath scanner: " + expectedToBeFound,
+ ejbModulesFromClassPath.contains(expectedToBeFound));
+ }
+
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Recursively removes the specified directory
+ * @param file
+ * @throws IOException
+ */
+ private static void rm(final File file) throws IOException
+ {
+ if (file.isDirectory())
+ {
+ for (final File child : file.listFiles())
+ {
+ rm(child);
+ }
+ }
+ file.delete();
+ }
+
+ /*
+ * Test EJB Component Classes
+ */
+
+ @Stateless
+ private static final class Slsb
+ {
+
+ }
+
+ @Stateful
+ private static final class Sfsb
+ {
+
+ }
+
+ @Singleton
+ private static final class Singleton1
+ {
+
+ }
+
+ @MessageDriven
+ private static final class Mdb
+ {
+
+ }
+
+ /**
+ * Test class with no EJB Component Annotation
+ *
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ private static final class Pojo
+ {
+
+ }
+}
Added: projects/ejb3/components/embedded/trunk/impl-base/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-base/src/test/resources/log4j.xml (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-base/src/test/resources/log4j.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="INFO"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jnp">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jboss.ejb3.embedded">
+ <priority value="ALL"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Property changes on: projects/ejb3/components/embedded/trunk/impl-standalone
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
target-eclipse
.settings
.classpath
.project
Added: projects/ejb3/components/embedded/trunk/impl-standalone/pom.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-standalone/pom.xml (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-standalone/pom.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,55 @@
+<!--
+ vi:ts=2:sw=2:expandtab
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!-- Define Parent -->
+ <parent>
+ <groupId>org.jboss.ejb3.embedded</groupId>
+ <artifactId>embedded-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Maven POM Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Information -->
+ <artifactId>embedded-impl-standalone</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss EJB 3.1+ Embedded Implementation (Internals) for Standalone Environments</name>
+ <description>Implementation Support for Embedded EJB 3.1+ Container within a generic existing JVM</description>
+
+ <!-- Build Configuration -->
+ <build>
+
+ </build>
+
+ <properties>
+
+ <!-- Versioning -->
+
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>embedded-impl-base</artifactId>
+ <version>${version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.reloaded</groupId>
+ <artifactId>jboss-reloaded-vdf-bootstrap-minimal</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+</project>
Added: projects/ejb3/components/embedded/trunk/impl-standalone/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/impl-standalone/src/test/resources/log4j.xml (rev 0)
+++ projects/ejb3/components/embedded/trunk/impl-standalone/src/test/resources/log4j.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="INFO"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jnp">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jboss.ejb3.embedded">
+ <priority value="ALL"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Modified: projects/ejb3/components/embedded/trunk/pom.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/pom.xml 2010-04-28 19:54:33 UTC (rev 104298)
+++ projects/ejb3/components/embedded/trunk/pom.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
- <version>4</version>
+ <version>5</version>
</parent>
<!-- Model Information -->
@@ -43,8 +43,11 @@
<!-- Aggregate Modules -->
<modules>
+ <module>api</module>
<module>build</module>
- <module>impl</module>
+ <module>impl-as</module>
+ <module>impl-base</module>
+ <module>impl-standalone</module>
<module>spi</module>
</modules>
Modified: projects/ejb3/components/embedded/trunk/spi/pom.xml
===================================================================
--- projects/ejb3/components/embedded/trunk/spi/pom.xml 2010-04-28 19:54:33 UTC (rev 104298)
+++ projects/ejb3/components/embedded/trunk/spi/pom.xml 2010-04-28 20:05:48 UTC (rev 104299)
@@ -40,11 +40,26 @@
<!--
Dependencies: org.jboss.ejb3
-->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>embedded-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!--
Dependencies: External to EJB3
-->
+ <dependency>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
Added: projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/ejb3/embedded/spi/scanner/filter/ExclusionFilter.java
===================================================================
--- projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/ejb3/embedded/spi/scanner/filter/ExclusionFilter.java (rev 0)
+++ projects/ejb3/components/embedded/trunk/spi/src/main/java/org/jboss/ejb3/embedded/spi/scanner/filter/ExclusionFilter.java 2010-04-28 20:05:48 UTC (rev 104299)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.spi.scanner.filter;
+
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Defines a mechanism whereby ClassPath entries
+ * may be excluded from scanning for EJB resources
+ * according to some implementation-specific
+ * criteria.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ExclusionFilter
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Returns whether this {@link VirtualFile} should be
+ * excluded from scanning for EJB resources. The criteria
+ * whereby a file is excluded is up to the implementation.
+ */
+ boolean exclude(VirtualFile file);
+
+}
More information about the jboss-cvs-commits
mailing list