[jboss-cvs] JBossAS SVN: r102436 - in projects/ejb3/components: instantiator and 34 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 15 18:05:32 EDT 2010
Author: ALRubinger
Date: 2010-03-15 18:05:31 -0400 (Mon, 15 Mar 2010)
New Revision: 102436
Added:
projects/ejb3/components/instantiator/
projects/ejb3/components/instantiator/tags/
projects/ejb3/components/instantiator/trunk/
projects/ejb3/components/instantiator/trunk/build/
projects/ejb3/components/instantiator/trunk/build/pom.xml
projects/ejb3/components/instantiator/trunk/impl/
projects/ejb3/components/instantiator/trunk/impl/pom.xml
projects/ejb3/components/instantiator/trunk/impl/src/
projects/ejb3/components/instantiator/trunk/impl/src/main/
projects/ejb3/components/instantiator/trunk/impl/src/main/java/
projects/ejb3/components/instantiator/trunk/impl/src/main/java/org/
projects/ejb3/components/instantiator/trunk/impl/src/main/java/org/jboss/
projects/ejb3/components/instantiator/trunk/impl/src/main/java/org/jboss/ejb3/
projects/ejb3/components/instantiator/trunk/impl/src/main/java/org/jboss/ejb3/instantiator/
projects/ejb3/components/instantiator/trunk/impl/src/main/java/org/jboss/ejb3/instantiator/impl/
projects/ejb3/components/instantiator/trunk/impl/src/main/java/org/jboss/ejb3/instantiator/impl/Ejb31SpecBeanInstantiator.java
projects/ejb3/components/instantiator/trunk/impl/src/main/resources/
projects/ejb3/components/instantiator/trunk/impl/src/test/
projects/ejb3/components/instantiator/trunk/impl/src/test/java/
projects/ejb3/components/instantiator/trunk/impl/src/test/java/org/
projects/ejb3/components/instantiator/trunk/impl/src/test/java/org/jboss/
projects/ejb3/components/instantiator/trunk/impl/src/test/java/org/jboss/ejb3/
projects/ejb3/components/instantiator/trunk/impl/src/test/java/org/jboss/ejb3/instantiator/
projects/ejb3/components/instantiator/trunk/impl/src/test/java/org/jboss/ejb3/instantiator/impl/
projects/ejb3/components/instantiator/trunk/impl/src/test/java/org/jboss/ejb3/instantiator/impl/Ejb31SpecBeanInstantiatorUnitTest.java
projects/ejb3/components/instantiator/trunk/impl/src/test/resources/
projects/ejb3/components/instantiator/trunk/pom.xml
projects/ejb3/components/instantiator/trunk/spi/
projects/ejb3/components/instantiator/trunk/spi/pom.xml
projects/ejb3/components/instantiator/trunk/spi/src/
projects/ejb3/components/instantiator/trunk/spi/src/main/
projects/ejb3/components/instantiator/trunk/spi/src/main/java/
projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/
projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/
projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/
projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/
projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/
projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/BeanInstantiationException.java
projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/BeanInstantiator.java
projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/InvalidConstructionParamsException.java
projects/ejb3/components/instantiator/trunk/spi/src/main/resources/
projects/ejb3/components/instantiator/trunk/spi/src/test/
projects/ejb3/components/instantiator/trunk/spi/src/test/java/
projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/
projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/
projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/
projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/
projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/spi/
projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/spi/BeanInstantiationExceptionUnitTest.java
projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/spi/InvalidConstructionParamsExceptionUnitTest.java
projects/ejb3/components/instantiator/trunk/spi/src/test/resources/
Log:
[EJBTHREE-2046] Create Bean Instantiator SPI
Property changes on: projects/ejb3/components/instantiator
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
target-eclipse
bin
.classpath
.project
.settings
Property changes on: projects/ejb3/components/instantiator/trunk
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
target-eclipse
bin
.classpath
.project
.settings
Property changes on: projects/ejb3/components/instantiator/trunk/build
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
target-eclipse
bin
.classpath
.project
.settings
Added: projects/ejb3/components/instantiator/trunk/build/pom.xml
===================================================================
--- projects/ejb3/components/instantiator/trunk/build/pom.xml (rev 0)
+++ projects/ejb3/components/instantiator/trunk/build/pom.xml 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ 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">
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4</version>
+ </parent>
+
+ <!-- Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Configuration -->
+ <groupId>org.jboss.ejb3.instantiator</groupId>
+ <artifactId>instantiator-build</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <name>JBoss EJB 3.x Instantiator Build</name>
+ <description>Centralized Build Configuration for EJB 3.x Bean Instance Creators</description>
+ <packaging>pom</packaging>
+
+ <!-- Properties -->
+ <properties>
+
+ <!-- Versioning -->
+ <version.junit_junit>4.7</version.junit_junit>
+
+ </properties>
+
+ <!-- SCM -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/components/instantiator/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/ejb3/components/instantiator/trunk</developerConnection>
+ <url>http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/components/instantiator/trunk</url>
+ </scm>
+
+ <!-- Issues -->
+ <issueManagement>
+ <system>jira</system>
+ <url>http://jira.jboss.com/jira/browse/EJBTHREE</url>
+ </issueManagement>
+
+ <!-- Build -->
+ <build>
+
+ <plugins>
+
+ <!-- Compiler / JDK6 required for EJB 3.1 -->
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <showDeprecation>false</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <optimize>true</optimize>
+ <compilerVersion>1.6</compilerVersion>
+ <fork>true</fork>
+ <argLine>-Xmx512M</argLine>
+ <executable>${JAVA_HOME}/bin/javac</executable>
+ </configuration>
+ </plugin>
+
+ <!-- Surefire -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <trimStackTrace>false</trimStackTrace>
+ <printSummary>true</printSummary>
+ <includes>
+ <include>**/*UnitTest.java</include>
+ </includes>
+ <forkMode>always</forkMode>
+ <useFile>true</useFile>
+ </configuration>
+ </plugin>
+
+ <!-- Maven Release Plugin Configuration -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <tagBase>https://svn.jboss.org/repos/jbossas/projects/ejb3/components/instantiator/tags</tagBase>
+ </configuration>
+ </plugin>
+
+ <!-- Enforce Maven Environment -->
+ <plugin>
+ <artifactId>maven-enforcer-plugin
+ </artifactId>
+ <executions>
+ <execution>
+ <id>enforce-maven-environment</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>1.6.0</version> <!-- Must be JDK6 -->
+ </requireJavaVersion>
+ <requireProperty>
+ <property>env.JAVA_HOME</property>
+ <message>"JAVA_HOME needs to be set to compile"</message>
+ </requireProperty>
+ </rules>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+ <!-- Dependency Management -->
+ <dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit_junit}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+
+ <!-- Reporting -->
+ <reporting>
+ <plugins>
+
+ <!-- Cobertura (Code Coverage) -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <configuration>
+ <formats>
+ <format>html</format>
+ <format>xml</format>
+ </formats>
+ </configuration>
+ </plugin>
+
+ <!-- FindBugs -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <findbugsXmlOutputDirectory>target/site</findbugsXmlOutputDirectory>
+ </configuration>
+ </plugin>
+
+ <!-- JavaDoc / APIViz -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <doclet>org.jboss.apiviz.APIviz</doclet>
+ <docletArtifact>
+ <groupId>org.jboss.apiviz</groupId>
+ <artifactId>apiviz</artifactId>
+ <version>1.3.0.GA</version>
+ </docletArtifact>
+ <useStandardDocletOptions>true</useStandardDocletOptions>
+ <charset>UTF-8</charset>
+ <encoding>UTF-8</encoding>
+ <docencoding>UTF-8</docencoding>
+ <breakiterator>true</breakiterator>
+ <version>true</version>
+ <author>true</author>
+ <keywords>true</keywords>
+ <additionalparam>
+ -sourceclasspath ${project.build.outputDirectory}
+ </additionalparam>
+ </configuration>
+ </plugin>
+
+
+ </plugins>
+ </reporting>
+
+</project>
+
Added: projects/ejb3/components/instantiator/trunk/impl/pom.xml
===================================================================
--- projects/ejb3/components/instantiator/trunk/impl/pom.xml (rev 0)
+++ projects/ejb3/components/instantiator/trunk/impl/pom.xml 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,59 @@
+<!--
+ 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.instantiator</groupId>
+ <artifactId>instantiator-build</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Maven POM Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Information -->
+ <artifactId>instantiator-impl</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss EJB 3.x Instantiator Implementation</name>
+ <description>Implementation for JBoss EJB 3.x Bean Instance Creators</description>
+
+ <!-- Build Configuration -->
+ <build>
+
+
+ </build>
+
+ <properties>
+
+
+
+ </properties>
+
+ <dependencies>
+
+ <!--
+ Dependencies: org.jboss.ejb3.instantiator
+ -->
+ <dependency>
+ <groupId>org.jboss.ejb3.instantiator</groupId>
+ <artifactId>instantiator-spi</artifactId>
+ <version>${version}</version>
+ </dependency>
+
+
+ <!--
+ Dependencies: External to EJB3
+ -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+
+ </dependencies>
+</project>
Added: projects/ejb3/components/instantiator/trunk/impl/src/main/java/org/jboss/ejb3/instantiator/impl/Ejb31SpecBeanInstantiator.java
===================================================================
--- projects/ejb3/components/instantiator/trunk/impl/src/main/java/org/jboss/ejb3/instantiator/impl/Ejb31SpecBeanInstantiator.java (rev 0)
+++ projects/ejb3/components/instantiator/trunk/impl/src/main/java/org/jboss/ejb3/instantiator/impl/Ejb31SpecBeanInstantiator.java 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,101 @@
+/*
+ * 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.instantiator.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.ejb3.instantiator.spi.BeanInstantiationException;
+import org.jboss.ejb3.instantiator.spi.BeanInstantiator;
+import org.jboss.ejb3.instantiator.spi.InvalidConstructionParamsException;
+
+/**
+ * Implementation of {@link BeanInstantiator} strictly conforming to the
+ * EJB 3.1 Specification. Any non-0-length or non-null parameter arguments to
+ * {@link Ejb31SpecBeanInstantiator#create(Class, Object[])}
+ * will result in {@link InvalidConstructionParamsException}
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class Ejb31SpecBeanInstantiator implements BeanInstantiator
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(Ejb31SpecBeanInstantiator.class.getName());
+
+ /**
+ * Message used in reporting exceptions during instantiation
+ */
+ private static final String MSG_PREFIX_INSTANTIATION_EXCEPTION = "Could not create new instance with no arguments of: ";
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.instantiator.spi.BeanInstantiator#create(java.lang.Class, java.lang.Object[])
+ */
+ public <T> T create(final Class<T> implClass, final Object[] parameters) throws IllegalArgumentException,
+ InvalidConstructionParamsException, BeanInstantiationException
+ {
+ // Precondition checks
+ if (parameters != null && parameters.length > 0)
+ {
+ throw InvalidConstructionParamsException
+ .newInstance("EJB Specification requires a no-argument constructor be invoked for bean instances on "
+ + implClass.getName());
+ }
+
+ // Instantiate
+ final T obj;
+ try
+ {
+ obj = implClass.newInstance();
+ }
+ catch (final InstantiationException e)
+ {
+ throw BeanInstantiationException.newInstance(MSG_PREFIX_INSTANTIATION_EXCEPTION + implClass, e);
+ }
+ catch (final IllegalAccessException e)
+ {
+ throw BeanInstantiationException.newInstance(MSG_PREFIX_INSTANTIATION_EXCEPTION + implClass, e);
+ }
+
+ // Log
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer("Created: " + obj + "; instance of " + implClass.getName());
+ }
+
+ // Return
+ return obj;
+ }
+
+}
Added: projects/ejb3/components/instantiator/trunk/impl/src/test/java/org/jboss/ejb3/instantiator/impl/Ejb31SpecBeanInstantiatorUnitTest.java
===================================================================
--- projects/ejb3/components/instantiator/trunk/impl/src/test/java/org/jboss/ejb3/instantiator/impl/Ejb31SpecBeanInstantiatorUnitTest.java (rev 0)
+++ projects/ejb3/components/instantiator/trunk/impl/src/test/java/org/jboss/ejb3/instantiator/impl/Ejb31SpecBeanInstantiatorUnitTest.java 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,134 @@
+/*
+ * 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.instantiator.impl;
+
+import junit.framework.TestCase;
+
+import org.jboss.ejb3.instantiator.spi.BeanInstantiationException;
+import org.jboss.ejb3.instantiator.spi.BeanInstantiator;
+import org.jboss.ejb3.instantiator.spi.InvalidConstructionParamsException;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test cases to ensure that the {@link Ejb31SpecBeanInstantiator}
+ * is working as contracted
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class Ejb31SpecBeanInstantiatorUnitTest
+{
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@link BeanInstantiator} instance under test
+ */
+ private BeanInstantiator instantiator;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates the {@link BeanInstantiator} before each test run
+ */
+ @Before
+ public void createInstantiator()
+ {
+ instantiator = new Ejb31SpecBeanInstantiator();
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures an instance can be created when using null params
+ */
+ @Test
+ public void canCreateInstanceFromNullParams()
+ {
+ // Suppress the warning for unused assignment, this is in place to show type safety in creation
+ @SuppressWarnings("unused")
+ final Pojo pojo;
+ try
+ {
+ pojo = instantiator.create(Pojo.class, null);
+ }
+ catch (final BeanInstantiationException e)
+ {
+ TestCase.fail("Should have created an instance, instead got " + e);
+ }
+
+ }
+
+ /**
+ * Ensures an instance can be created when using 0-length params
+ */
+ @Test
+ public void canCreateInstanceFrom0LengthParams()
+ {
+ try
+ {
+ instantiator.create(Pojo.class, new Object[]
+ {});
+ }
+ catch (final BeanInstantiationException e)
+ {
+ TestCase.fail("Should have created an instance, instead got " + e);
+ }
+
+ }
+
+ /**
+ * Ensures that passing in parameters results in {@link InvalidConstructionParamsException}
+ */
+ @Test(expected = InvalidConstructionParamsException.class)
+ public void parametersDisallowed()
+ {
+ try
+ {
+ instantiator.create(Pojo.class, new Object[]
+ {""});
+ }
+ catch (final BeanInstantiationException e)
+ {
+ TestCase.fail("Should have received " + InvalidConstructionParamsException.class.getName() + "; instead got "
+ + e);
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Inner Classes ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Class used in testing
+ */
+ public static class Pojo
+ {
+
+ }
+}
Added: projects/ejb3/components/instantiator/trunk/pom.xml
===================================================================
--- projects/ejb3/components/instantiator/trunk/pom.xml (rev 0)
+++ projects/ejb3/components/instantiator/trunk/pom.xml 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ 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">
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4</version>
+ </parent>
+
+ <!-- Model Information -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Information -->
+ <groupId>org.jboss.ejb3.instantiator</groupId>
+ <artifactId>instantiator-parent</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>JBoss EJB 3.x Instantiator Aggregator</name>
+ <url>http://www.jboss.org</url>
+ <description>Responsible for Bean Instance Creation within JBoss EJB3</description>
+
+ <!-- Plugin Configuration -->
+ <build>
+ <plugins>
+
+ <!-- Deploy -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <!-- Don't include this aggregator in the deployment -->
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <!-- Aggregate Modules -->
+ <modules>
+ <module>spi</module>
+ <module>build</module>
+ <module>impl</module>
+ </modules>
+
+</project>
Property changes on: projects/ejb3/components/instantiator/trunk/spi
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
target-eclipse
bin
.classpath
.project
.settings
Added: projects/ejb3/components/instantiator/trunk/spi/pom.xml
===================================================================
--- projects/ejb3/components/instantiator/trunk/spi/pom.xml (rev 0)
+++ projects/ejb3/components/instantiator/trunk/spi/pom.xml 2010-03-15 22:05:31 UTC (rev 102436)
@@ -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.instantiator</groupId>
+ <artifactId>instantiator-build</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Maven POM Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Information -->
+ <artifactId>instantiator-spi</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss EJB 3.x Instantiator SPI</name>
+ <description>Service Provider Interface for JBoss EJB 3.x Bean Instance Creators</description>
+
+ <!-- Build Configuration -->
+ <build>
+
+
+ </build>
+
+ <properties>
+
+
+
+ </properties>
+
+ <dependencies>
+
+ <!--
+ Dependencies: org.jboss.ejb3
+ -->
+
+
+ <!--
+ Dependencies: External to EJB3
+ -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+
+ </dependencies>
+</project>
Added: projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/BeanInstantiationException.java
===================================================================
--- projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/BeanInstantiationException.java (rev 0)
+++ projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/BeanInstantiationException.java 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,87 @@
+/*
+ * 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.instantiator.spi;
+
+/**
+ * Thrown when the implementation of {@link BeanInstantiator#create(Class, Object[])}
+ * encounters an error in creating a new bean instance; the underlying cause
+ * is guaranteed to be available from @link {@link BeanInstantiationException}{@link #getCause()}.
+ * Provided as not all {@link BeanInstantiator} implementations will use a JDK
+ * backend, so provides safe translation for instance from {@link InstantiationException}.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class BeanInstantiationException extends Exception
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * serialVersionUID
+ */
+ private static final long serialVersionUID = 1L;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructors -----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new {@link BeanInstantiationException} with the
+ * specified message and cause. Private so we can perform precondition checks;
+ * callers should use {@link BeanInstantiationException#newInstance(String,Throwable)}.
+ */
+ private BeanInstantiationException(final String message, final Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Factory Methods -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new {@link BeanInstantiationException} with the
+ * specified message and cause. Both arguments required.
+ *
+ * @throws IllegalArgumentException If the message or cause is not specified
+ */
+ public static BeanInstantiationException 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");
+ }
+
+ // Return new instance.
+ return new BeanInstantiationException(message, cause);
+ }
+
+}
Added: projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/BeanInstantiator.java
===================================================================
--- projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/BeanInstantiator.java (rev 0)
+++ projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/BeanInstantiator.java 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,56 @@
+/*
+ * 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.instantiator.spi;
+
+/**
+ * Contract of a component responsible for creation of EJB bean
+ * and instances. Though the EJB specification dictates
+ * the use of a no-arg constructor, contextual EJBs defined by JSR-299
+ * provides for additional features such as injected constructor parameters,
+ * so alternate implementations of this type may be used by the
+ * EJB container.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface BeanInstantiator
+{
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new instance of the specified implementation {@link Class}
+ * using the supplied parameters. While the implementation class
+ * must be specified, <code>null</code> is a valid value for the parameters,
+ * and will be treated as a 0-length array.
+ *
+ * @throws IllegalArgumentException If the implementation class was not specified
+ * or the implementation does not support parameters (while they've been supplied).
+ * @throws InvalidConstructionParamsException If the implementation of this type does
+ * not support the parameters supplied.
+ * @throws BeanInstantiationException If an unexpected error occurred in constructing the bean
+ * instance
+ */
+ <T> T create(Class<T> implClass, Object[] parameters) throws IllegalArgumentException,
+ InvalidConstructionParamsException, BeanInstantiationException;
+}
Added: projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/InvalidConstructionParamsException.java
===================================================================
--- projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/InvalidConstructionParamsException.java (rev 0)
+++ projects/ejb3/components/instantiator/trunk/spi/src/main/java/org/jboss/ejb3/instantiator/spi/InvalidConstructionParamsException.java 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,79 @@
+/*
+ * 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.instantiator.spi;
+
+/**
+ * Thrown when the implementation of {@link BeanInstantiator#create(Class, Object[])}
+ * has been given a set of parameters that it does not support.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class InvalidConstructionParamsException extends RuntimeException
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * serialVersionUID
+ */
+ private static final long serialVersionUID = 1L;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructors -----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new {@link InvalidConstructionParamsException} with the
+ * specified message. Private so we can perform precondition checks on the
+ * message; callers should use {@link InvalidConstructionParamsException#newInstance(String)}.
+ */
+ private InvalidConstructionParamsException(final String message)
+ {
+ super(message);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Factory Methods -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new {@link InvalidConstructionParamsException} with the
+ * specified message. The message is required.
+ *
+ * @throws IllegalArgumentException If the message is not specified
+ */
+ public static InvalidConstructionParamsException newInstance(final String message) throws IllegalArgumentException
+ {
+ // Precondition check
+ if (message == null || message.length() == 0)
+ {
+ throw new IllegalArgumentException("Message must be specified");
+ }
+
+ // Return new instance.
+ return new InvalidConstructionParamsException(message);
+ }
+
+}
Added: projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/spi/BeanInstantiationExceptionUnitTest.java
===================================================================
--- projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/spi/BeanInstantiationExceptionUnitTest.java (rev 0)
+++ projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/spi/BeanInstantiationExceptionUnitTest.java 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,79 @@
+/*
+ * 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.instantiator.spi;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+/**
+ * Test cases to ensure that the {@link BeanInstantiationException}
+ * factory method is working as contracted
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class BeanInstantiationExceptionUnitTest
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures an instance can be created when following the contract
+ */
+ @Test
+ public void canCreateInstance()
+ {
+ final BeanInstantiationException exception = BeanInstantiationException.newInstance("Message", new Exception());
+ Assert.assertNotNull(exception);
+ }
+
+ /**
+ * Ensures that an instance with blank message cannot be created
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void blankMessageDisallowed()
+ {
+ BeanInstantiationException.newInstance("", new Exception());
+ }
+
+ /**
+ * Ensures that an instance with null message cannot be created
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void nullMessageDisallowed()
+ {
+ BeanInstantiationException.newInstance(null, new Exception());
+ }
+
+ /**
+ * Ensures that an instance with null cause cannot be created
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void nullCauseDisallowed()
+ {
+ BeanInstantiationException.newInstance("Message", null);
+ }
+
+}
Added: projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/spi/InvalidConstructionParamsExceptionUnitTest.java
===================================================================
--- projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/spi/InvalidConstructionParamsExceptionUnitTest.java (rev 0)
+++ projects/ejb3/components/instantiator/trunk/spi/src/test/java/org/jboss/ejb3/instantiator/spi/InvalidConstructionParamsExceptionUnitTest.java 2010-03-15 22:05:31 UTC (rev 102436)
@@ -0,0 +1,70 @@
+/*
+ * 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.instantiator.spi;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+/**
+ * Test cases to ensure that the {@link InvalidConstructionParamsException}
+ * factory method is working as contracted
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class InvalidConstructionParamsExceptionUnitTest
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures an instance can be created when following the contract
+ */
+ @Test
+ public void canCreateInstance()
+ {
+ final InvalidConstructionParamsException exception = InvalidConstructionParamsException.newInstance("Message");
+ Assert.assertNotNull(exception);
+ }
+
+ /**
+ * Ensures that an instance with blank message cannot be created
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void blankMessageDisallowed()
+ {
+ InvalidConstructionParamsException.newInstance("");
+ }
+
+ /**
+ * Ensures that an instance with null message cannot be created
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void nullMessageDisallowed()
+ {
+ InvalidConstructionParamsException.newInstance(null);
+ }
+
+}
More information about the jboss-cvs-commits
mailing list