[jboss-cvs] JBossAS SVN: r85843 - in projects/ejb3/trunk: endpoint and 18 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Mar 14 05:21:19 EDT 2009
Author: wolfc
Date: 2009-03-14 05:21:19 -0400 (Sat, 14 Mar 2009)
New Revision: 85843
Added:
projects/ejb3/trunk/endpoint/
projects/ejb3/trunk/endpoint/.classpath
projects/ejb3/trunk/endpoint/.project
projects/ejb3/trunk/endpoint/.settings/
projects/ejb3/trunk/endpoint/.settings/org.eclipse.jdt.core.prefs
projects/ejb3/trunk/endpoint/.settings/org.maven.ide.eclipse.prefs
projects/ejb3/trunk/endpoint/pom.xml
projects/ejb3/trunk/endpoint/src/
projects/ejb3/trunk/endpoint/src/main/
projects/ejb3/trunk/endpoint/src/main/java/
projects/ejb3/trunk/endpoint/src/main/java/org/
projects/ejb3/trunk/endpoint/src/main/java/org/jboss/
projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/
projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/
projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/Endpoint.java
projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/SessionFactory.java
projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/reflect/
projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/reflect/EndpointInvocationHandler.java
projects/ejb3/trunk/endpoint/src/test/
projects/ejb3/trunk/endpoint/src/test/java/
projects/ejb3/trunk/endpoint/src/test/java/org/
projects/ejb3/trunk/endpoint/src/test/java/org/jboss/
projects/ejb3/trunk/endpoint/src/test/java/org/jboss/ejb3/
projects/ejb3/trunk/endpoint/src/test/java/org/jboss/ejb3/endpoint/
projects/ejb3/trunk/endpoint/src/test/java/org/jboss/ejb3/endpoint/test/
projects/ejb3/trunk/endpoint/src/test/java/org/jboss/ejb3/endpoint/test/invocation/
projects/ejb3/trunk/endpoint/src/test/java/org/jboss/ejb3/endpoint/test/invocation/unit/
projects/ejb3/trunk/endpoint/src/test/java/org/jboss/ejb3/endpoint/test/invocation/unit/InvocationTestCase.java
Log:
EJBTHREE-1772: endpoint spi
Property changes on: projects/ejb3/trunk/endpoint
___________________________________________________________________
Name: svn:ignore
+ eclipse-target
target
Added: projects/ejb3/trunk/endpoint/.classpath
===================================================================
--- projects/ejb3/trunk/endpoint/.classpath (rev 0)
+++ projects/ejb3/trunk/endpoint/.classpath 2009-03-14 09:21:19 UTC (rev 85843)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="eclipse-target/classes" path="src/main/java"/>
+ <classpathentry kind="src" output="eclipse-target/tests-classes" path="src/test/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.5.0_15"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="eclipse-target/classes"/>
+</classpath>
Added: projects/ejb3/trunk/endpoint/.project
===================================================================
--- projects/ejb3/trunk/endpoint/.project (rev 0)
+++ projects/ejb3/trunk/endpoint/.project 2009-03-14 09:21:19 UTC (rev 85843)
@@ -0,0 +1,17 @@
+<projectDescription>
+ <name>jboss-ejb3-endpoint</name>
+ <comment>JBoss EJB 3.x Endpoint SPI</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added: projects/ejb3/trunk/endpoint/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/ejb3/trunk/endpoint/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/ejb3/trunk/endpoint/.settings/org.eclipse.jdt.core.prefs 2009-03-14 09:21:19 UTC (rev 85843)
@@ -0,0 +1,5 @@
+#Sat Mar 14 09:27:02 CET 2009
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
Added: projects/ejb3/trunk/endpoint/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/ejb3/trunk/endpoint/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ projects/ejb3/trunk/endpoint/.settings/org.maven.ide.eclipse.prefs 2009-03-14 09:21:19 UTC (rev 85843)
@@ -0,0 +1,8 @@
+#Sat Mar 14 10:04:39 CET 2009
+activeProfiles=eclipse
+eclipse.preferences.version=1
+fullBuildGoals=
+includeModules=false
+resolveWorkspaceProjects=false
+resourceFilterGoals=
+version=1
Added: projects/ejb3/trunk/endpoint/pom.xml
===================================================================
--- projects/ejb3/trunk/endpoint/pom.xml (rev 0)
+++ projects/ejb3/trunk/endpoint/pom.xml 2009-03-14 09:21:19 UTC (rev 85843)
@@ -0,0 +1,40 @@
+<!--
+ 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>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-build</artifactId>
+ <version>1.0.2</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Configuration -->
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-endpoint</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <name>JBoss EJB 3.x Endpoint SPI</name>
+ <description>JBoss EJB 3.x Endpoint SPI</description>
+ <url>http://www.jboss.org/jbossejb3</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/Endpoint.java
===================================================================
--- projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/Endpoint.java (rev 0)
+++ projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/Endpoint.java 2009-03-14 09:21:19 UTC (rev 85843)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.endpoint;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+/**
+ * An endpoint is capable of handling invocation on an EJB instance.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Endpoint
+{
+ /**
+ * Invoke a method on an EJB endpoint.
+ *
+ * @param session the identification of the EJB instance to invoke the method upon
+ * or null if the endpoint doesn't support sessions.
+ * @param invokedBusinessInterface the invokedBusinessInterface or null if not known.
+ * @param method the method to invoke on the EJB instance, note that if
+ * invokedBusinessInterface is specified then the declaring class of the
+ * {@code Method} object must be an instance of
+ * the specified {@code Class} invokedBusinessInterface.
+ * @param args an array of objects containing the values of the
+ * arguments passed in the method invocation on the proxy instance,
+ * or {@code null} if interface method takes no arguments.
+ * Arguments of primitive types are wrapped in instances of the
+ * appropriate primitive wrapper class, such as
+ * {@code java.lang.Integer} or {@code java.lang.Boolean}.
+ *
+ * @return the return value of the invoked {@code Method} method.
+ * @throws Throwable the exception to throw from the method
+ * invocation on the EJB instance.
+ */
+ Object invoke(Serializable session, Class<?> invokedBusinessInterface, Method method, Object args[]) throws Throwable;
+}
Added: projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/SessionFactory.java
===================================================================
--- projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/SessionFactory.java (rev 0)
+++ projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/SessionFactory.java 2009-03-14 09:21:19 UTC (rev 85843)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.endpoint;
+
+import java.io.Serializable;
+
+/**
+ * Create sessions on an EJB. Usually this would be a stateful session bean.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface SessionFactory
+{
+ /**
+ * Create a session on an EJB.
+ *
+ * Under the hood, the EJB's construct will be called. Followed by injection, calling
+ * the post-construct method and finally calling the appropriate init method.
+ *
+ * @param initTypes the argument types for the init method.
+ * @param initValues the arguments for the init method.
+ * @return the session created.
+ */
+ Serializable createSession(Class<?>[] initTypes, Object[] initValues);
+
+ /**
+ * Destroy a session on an EJB.
+ *
+ * Invokes the pre-destroy on the EJB and destroys it.
+ *
+ * @param session the session to destroy.
+ */
+ void destroySession(Serializable session);
+}
Added: projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/reflect/EndpointInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/reflect/EndpointInvocationHandler.java (rev 0)
+++ projects/ejb3/trunk/endpoint/src/main/java/org/jboss/ejb3/endpoint/reflect/EndpointInvocationHandler.java 2009-03-14 09:21:19 UTC (rev 85843)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.endpoint.reflect;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import org.jboss.ejb3.endpoint.Endpoint;
+
+/**
+ * An InvocationHandler adapter for an Endpoint.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class EndpointInvocationHandler implements InvocationHandler, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private Endpoint endpoint;
+ private Serializable session;
+ private Class<?> invokedBusinessInterface;
+
+ /**
+ * Creates an invocation handler.
+ */
+ public EndpointInvocationHandler(Endpoint endpoint, Serializable session, Class<?> invokedBusinessInterface)
+ {
+ assert endpoint != null : "endpoint is null";
+
+ this.endpoint = endpoint;
+ this.session = session; // can be null
+ this.invokedBusinessInterface = invokedBusinessInterface; // can be null;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ return endpoint.invoke(session, invokedBusinessInterface, method, args);
+ }
+}
Added: projects/ejb3/trunk/endpoint/src/test/java/org/jboss/ejb3/endpoint/test/invocation/unit/InvocationTestCase.java
===================================================================
--- projects/ejb3/trunk/endpoint/src/test/java/org/jboss/ejb3/endpoint/test/invocation/unit/InvocationTestCase.java (rev 0)
+++ projects/ejb3/trunk/endpoint/src/test/java/org/jboss/ejb3/endpoint/test/invocation/unit/InvocationTestCase.java 2009-03-14 09:21:19 UTC (rev 85843)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.endpoint.test.invocation.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.Date;
+
+import org.jboss.ejb3.endpoint.Endpoint;
+import org.jboss.ejb3.endpoint.reflect.EndpointInvocationHandler;
+import org.junit.Test;
+
+/**
+ * Test an invocation on a dummy endpoint.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InvocationTestCase
+{
+ @Test
+ public void testInvocation() throws Throwable
+ {
+ Endpoint endpoint = new Endpoint() {
+ public Object invoke(Serializable session, Class<?> invokedBusinessInterface, Method method, Object[] args)
+ throws Throwable
+ {
+ return "Hi " + args[0];
+ }
+ };
+ Serializable session = null;
+ Class<?> invokedBusinessInterface = null;
+ InvocationHandler handler = new EndpointInvocationHandler(endpoint, session, invokedBusinessInterface);
+ Object proxy = null;
+ Method method = null;
+ Date now = new Date();
+ Object args[] = { now };
+ Object result = handler.invoke(proxy, method, args);
+ assertEquals("Hi " + now, result);
+ }
+
+ @Test
+ public void testIllegalEndpoint()
+ {
+ Endpoint endpoint = null;
+ Serializable session = null;
+ Class<?> invokedBusinessInterface = null;
+ try
+ {
+ new EndpointInvocationHandler(endpoint, session, invokedBusinessInterface);
+ fail("Should have thrown AssertionError (or run with -ea)");
+ }
+ catch(AssertionError e)
+ {
+ assertEquals("endpoint is null", e.getMessage());
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list