[jboss-cvs] JBossAS SVN: r68383 - in projects/ejb3/trunk: sandbox and 21 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 18 13:13:45 EST 2007
Author: wolfc
Date: 2007-12-18 13:13:44 -0500 (Tue, 18 Dec 2007)
New Revision: 68383
Added:
projects/ejb3/trunk/sandbox/
projects/ejb3/trunk/sandbox/.classpath
projects/ejb3/trunk/sandbox/.project
projects/ejb3/trunk/sandbox/.settings/
projects/ejb3/trunk/sandbox/.settings/org.eclipse.jdt.core.prefs
projects/ejb3/trunk/sandbox/pom.xml
projects/ejb3/trunk/sandbox/src/
projects/ejb3/trunk/sandbox/src/main/
projects/ejb3/trunk/sandbox/src/main/java/
projects/ejb3/trunk/sandbox/src/main/java/org/
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/ContainerInterceptors.java
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/InterceptorContainer.java
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalBusinessInterfaceInterceptor.java
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalProxy.java
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessBeanContext.java
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessContainer.java
projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessInterceptor.java
projects/ejb3/trunk/sandbox/src/test/
projects/ejb3/trunk/sandbox/src/test/java/
projects/ejb3/trunk/sandbox/src/test/java/org/
projects/ejb3/trunk/sandbox/src/test/java/org/jboss/
projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/
projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/
projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/
projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/
projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessBean.java
projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessLocal.java
projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/
projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/SimpleStatelessUnitTestCase.java
projects/ejb3/trunk/sandbox/src/test/resources/
projects/ejb3/trunk/sandbox/src/test/resources/jndi.properties
projects/ejb3/trunk/sandbox/src/test/resources/log4j.xml
Log:
Initial commit
Property changes on: projects/ejb3/trunk/sandbox
___________________________________________________________________
Name: svn:ignore
+ eclipse-target
target
Added: projects/ejb3/trunk/sandbox/.classpath
===================================================================
--- projects/ejb3/trunk/sandbox/.classpath (rev 0)
+++ projects/ejb3/trunk/sandbox/.classpath 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,21 @@
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java" output="eclipse-target/tests-classes"/>
+ <classpathentry kind="src" path="src/test/resources" output="eclipse-target/tests-classes" excluding="**/*.java"/>
+ <classpathentry kind="output" path="eclipse-target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.20070913080910/jboss-transaction-api-1.0.1.20070913080910.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.20070913080910/jboss-transaction-api-1.0.1.20070913080910-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-pool/0.11.0-SNAPSHOT/jboss-ejb3-pool-0.11.0-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-slide/webdavlib/2.0/webdavlib-2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.8/log4j-1.2.8.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jnpserver/5.0.0-SNAPSHOT/jnpserver-5.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/jnpserver/5.0.0-SNAPSHOT/jnpserver-5.0.0-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.2.GA/jboss-common-core-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-core/2.0.2.GA/jboss-common-core-2.0.2.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.20070913080910/jboss-ejb-api-3.0.0.20070913080910.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.20070913080910/jboss-ejb-api-3.0.0.20070913080910-sources.jar"/>
+</classpath>
\ No newline at end of file
Added: projects/ejb3/trunk/sandbox/.project
===================================================================
--- projects/ejb3/trunk/sandbox/.project (rev 0)
+++ projects/ejb3/trunk/sandbox/.project 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,13 @@
+<projectDescription>
+ <name>jboss-ejb3-sandbox</name>
+ <comment>The JBoss EJB 3 Sandbox is a try out area</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added: projects/ejb3/trunk/sandbox/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/ejb3/trunk/sandbox/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/ejb3/trunk/sandbox/.settings/org.eclipse.jdt.core.prefs 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,5 @@
+#Mon Oct 08 15:42:55 CEST 2007
+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/sandbox/pom.xml
===================================================================
--- projects/ejb3/trunk/sandbox/pom.xml (rev 0)
+++ projects/ejb3/trunk/sandbox/pom.xml 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,51 @@
+<!--
+ 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</artifactId>
+ <version>0.11.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-ejb3-sandbox</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss EJB 3 Sandbox</name>
+ <url>http://www.jboss.org</url>
+ <description>The JBoss EJB 3 Sandbox is a try out area</description>
+
+ <dependencies>
+ <!-- internal -->
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-pool</artifactId>
+ </dependency>
+
+ <!-- external -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jnpserver</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.javaee</groupId>
+ <artifactId>jboss-ejb-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Property changes on: projects/ejb3/trunk/sandbox/pom.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/ContainerInterceptors.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/ContainerInterceptors.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/ContainerInterceptors.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.sandbox.interceptorcontainer;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Inherited
+ at Retention(RetentionPolicy.RUNTIME)
+ at Documented
+ at Target({ElementType.TYPE})
+public @interface ContainerInterceptors {
+ Class<?>[] value();
+}
Property changes on: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/ContainerInterceptors.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/InterceptorContainer.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/InterceptorContainer.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/InterceptorContainer.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,197 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.sandbox.interceptorcontainer;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * An interceptor container keeps track of container interceptors
+ * on a class.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InterceptorContainer implements AnnotatedElement
+{
+ private Class<?> beanClass;
+ private Object[] interceptors;
+
+ public class BeanClassInvocationContext implements InvocationContext
+ {
+ private Class<? extends Annotation> annotationClass;
+ private Method method;
+ private Object args[];
+
+ private Map<String, Object> contextData = new HashMap<String, Object>();
+
+ private Iterator<Object> it = Arrays.asList(interceptors).iterator();
+
+ protected BeanClassInvocationContext(Class<? extends Annotation> annotationClass)
+ {
+ assert annotationClass != null : "annotationClass is null";
+
+ this.annotationClass = annotationClass;
+ }
+
+ protected BeanClassInvocationContext(Class<? extends Annotation> annotationClass, Method method, Object args[])
+ {
+ this(annotationClass);
+
+ assert method != null : "method is null";
+ assert args != null : "args is null";
+
+ this.method = method;
+ this.args = args;
+ }
+
+ public Map<String, Object> getContextData()
+ {
+ // Must not return null
+ return contextData;
+ }
+
+ public Method getMethod()
+ {
+ // For lifecycle callback methods, returns null
+
+ return method;
+ }
+
+ public Object[] getParameters()
+ {
+ if(method == null && args == null)
+ {
+ // If invoked in a lifecycle callback
+ throw new IllegalStateException();
+ }
+ return args;
+ }
+
+ public InterceptorContainer getTarget()
+ {
+ return InterceptorContainer.this;
+ }
+
+ public Object proceed() throws Exception
+ {
+ if(!it.hasNext())
+ return null;
+ Object interceptor = it.next();
+ Method callback = findMethod(interceptor.getClass(), annotationClass);
+ if(callback == null)
+ return proceed();
+ Object args[] = { BeanClassInvocationContext.this };
+ return callback.invoke(interceptor, args);
+ }
+
+ public void setParameters(Object[] params)
+ {
+ // If invoked in a lifecycle callback
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public InterceptorContainer(Class<?> beanClass) throws Exception
+ {
+ assert beanClass != null;
+
+ this.beanClass = beanClass;
+
+ // TODO: use a delegate to get annotations (so we can hook into meta data)
+ ContainerInterceptors interceptors = beanClass.getAnnotation(ContainerInterceptors.class);
+ if(interceptors == null)
+ throw new IllegalArgumentException("Class " + beanClass + " doesn't have any container interceptors");
+
+ Class<?> interceptorClasses[] = interceptors.value();
+ this.interceptors = new Object[interceptorClasses.length];
+ for(int i = 0; i < interceptorClasses.length; i++)
+ {
+ this.interceptors[i] = interceptorClasses[i].newInstance();
+ }
+
+ // TODO: inject interceptors
+
+ // Post construct
+ new BeanClassInvocationContext(PostConstruct.class).proceed();
+ }
+
+ private static <A extends Annotation> Method findMethod(Class<?> cls, Class<A> annotationClass)
+ {
+ if(cls == null)
+ return null;
+
+ for(Method method : cls.getDeclaredMethods())
+ {
+ if(method.getAnnotation(annotationClass) != null)
+ return method;
+ }
+
+ return findMethod(cls.getSuperclass(), annotationClass);
+ }
+
+ public Class<?> getBeanClass()
+ {
+ return beanClass;
+ }
+
+ public Object invoke(Method method, Object[] args) throws Throwable
+ {
+ return new BeanClassInvocationContext(AroundInvoke.class, method, args).proceed();
+ }
+
+ /*
+ * Helpers
+ */
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+ {
+ return beanClass.getAnnotation(annotationClass);
+ }
+
+ public Annotation[] getAnnotations()
+ {
+ return beanClass.getAnnotations();
+ }
+
+ public Annotation[] getDeclaredAnnotations()
+ {
+ return beanClass.getAnnotations();
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
+ {
+ return beanClass.isAnnotationPresent(annotationClass);
+ }
+}
Property changes on: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/InterceptorContainer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalBusinessInterfaceInterceptor.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalBusinessInterfaceInterceptor.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalBusinessInterfaceInterceptor.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.sandbox.local;
+
+import java.lang.reflect.Proxy;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.Local;
+import javax.interceptor.InvocationContext;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.sandbox.interceptorcontainer.InterceptorContainer;
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jboss.util.naming.Util;
+
+/**
+ * Creates and binds a proxy for invoking beans over a local interface.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LocalBusinessInterfaceInterceptor
+{
+ private static final Logger log = Logger.getLogger(LocalBusinessInterfaceInterceptor.class);
+
+ @PostConstruct
+ public void postConstruct(InterceptorContainer.BeanClassInvocationContext ctx) throws Exception
+ {
+ log.debug("postConstruct " + ctx);
+
+ Class<?> businessInterfaces[];
+ Local local = ctx.getTarget().getAnnotation(Local.class);
+ if(local != null)
+ businessInterfaces = local.value();
+ else if(ctx.getTarget().getBeanClass().getInterfaces().length == 1)
+ businessInterfaces = new Class<?>[] { ctx.getTarget().getBeanClass().getInterfaces()[0] };
+ else
+ throw new IllegalArgumentException("TODO");
+
+ // TODO: determine JNDI name
+ String jndiName = ctx.getTarget().getBeanClass().getSimpleName() + "/local";
+ log.debug("jndiName = " + jndiName);
+
+ Object proxy = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), businessInterfaces, new LocalProxy(ctx.getTarget()));
+
+ Util.createSubcontext(new InitialContext(), ctx.getTarget().getBeanClass().getSimpleName());
+ NonSerializableFactory.rebind(new InitialContext(), jndiName, proxy);
+
+ ctx.proceed();
+ }
+
+ @PreDestroy
+ public void preDestroy(InvocationContext ctx) throws Exception
+ {
+ log.debug("preDestroy");
+
+ ctx.proceed();
+ }
+}
Property changes on: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalBusinessInterfaceInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalProxy.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalProxy.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalProxy.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.sandbox.local;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import org.jboss.ejb3.sandbox.interceptorcontainer.InterceptorContainer;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LocalProxy implements InvocationHandler
+{
+ private InterceptorContainer container;
+
+ public LocalProxy(InterceptorContainer container)
+ {
+ assert container != null : "container is null";
+
+ this.container = container;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ return container.invoke(method, args);
+ }
+}
Property changes on: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/local/LocalProxy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessBeanContext.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessBeanContext.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessBeanContext.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.sandbox.stateless;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface StatelessBeanContext
+{
+
+}
Property changes on: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessBeanContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessContainer.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessContainer.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.sandbox.stateless;
+
+import java.lang.reflect.Method;
+
+import org.jboss.ejb3.pool.Pool;
+import org.jboss.ejb3.sandbox.interceptorcontainer.InterceptorContainer;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class StatelessContainer extends InterceptorContainer
+{
+ private Pool<StatelessBeanContext> pool;
+
+ public StatelessContainer(Class<?> beanClass) throws Exception
+ {
+ super(beanClass);
+ }
+
+ public Object invoke(Method method, Object args[])
+ {
+ StatelessBeanContext ctx = pool.get();
+ try
+ {
+ //return ctx.invoke(method, args);
+ throw new RuntimeException("NYI");
+ }
+ finally
+ {
+ pool.release(ctx);
+ }
+ }
+}
Property changes on: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessContainer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessInterceptor.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessInterceptor.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessInterceptor.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.sandbox.stateless;
+
+import javax.interceptor.AroundInvoke;
+
+import org.jboss.ejb3.sandbox.interceptorcontainer.InterceptorContainer;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class StatelessInterceptor
+{
+ @AroundInvoke
+ public Object invoke(InterceptorContainer.BeanClassInvocationContext ctx) throws Exception
+ {
+ // TODO: a lot, the pool should be here
+ Object instance = ctx.getTarget().getBeanClass().newInstance();
+ Object result = ctx.getMethod().invoke(instance, ctx.getParameters());
+ ctx.proceed();
+ return result;
+ }
+}
Property changes on: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/stateless/StatelessInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessBean.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessBean.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessBean.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.test.sandbox.stateless;
+
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.sandbox.interceptorcontainer.ContainerInterceptors;
+import org.jboss.ejb3.sandbox.local.LocalBusinessInterfaceInterceptor;
+import org.jboss.ejb3.sandbox.stateless.StatelessInterceptor;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at ContainerInterceptors({ LocalBusinessInterfaceInterceptor.class, StatelessInterceptor.class })
+ at Stateless
+public class SimpleStatelessBean implements SimpleStatelessLocal
+{
+ private static final Logger log = Logger.getLogger(SimpleStatelessBean.class);
+
+ public String sayHi(String name)
+ {
+ log.info("sayHi " + name);
+ return "Hi " + name;
+ }
+
+}
Property changes on: projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessLocal.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessLocal.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessLocal.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.test.sandbox.stateless;
+
+import javax.ejb.Local;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Local
+public interface SimpleStatelessLocal
+{
+ String sayHi(String name);
+}
Property changes on: projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/SimpleStatelessLocal.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/SimpleStatelessUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/SimpleStatelessUnitTestCase.java (rev 0)
+++ projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/SimpleStatelessUnitTestCase.java 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.test.sandbox.stateless.unit;
+
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.sandbox.interceptorcontainer.InterceptorContainer;
+import org.jboss.ejb3.test.sandbox.stateless.SimpleStatelessBean;
+import org.jboss.ejb3.test.sandbox.stateless.SimpleStatelessLocal;
+import org.jnp.server.SingletonNamingServer;
+
+import junit.framework.TestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleStatelessUnitTestCase extends TestCase
+{
+ public void test1() throws Exception
+ {
+ SingletonNamingServer namingServer = new SingletonNamingServer();
+
+ //StatelessContainer statelessContainer = new StatelessContainer();
+ InterceptorContainer container = new InterceptorContainer(SimpleStatelessBean.class);
+
+ InitialContext ctx = new InitialContext();
+
+ SimpleStatelessLocal bean = (SimpleStatelessLocal) ctx.lookup("SimpleStatelessBean/local");
+
+ assertNotNull(bean);
+ String result = bean.sayHi("Test");
+ assertEquals("Hi Test", result);
+
+ namingServer.destroy();
+ }
+}
Property changes on: projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/SimpleStatelessUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/sandbox/src/test/resources/jndi.properties
===================================================================
--- projects/ejb3/trunk/sandbox/src/test/resources/jndi.properties (rev 0)
+++ projects/ejb3/trunk/sandbox/src/test/resources/jndi.properties 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,2 @@
+java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
\ No newline at end of file
Added: projects/ejb3/trunk/sandbox/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/trunk/sandbox/src/test/resources/log4j.xml (rev 0)
+++ projects/ejb3/trunk/sandbox/src/test/resources/log4j.xml 2007-12-18 18:13:44 UTC (rev 68383)
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id$ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<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>
+
+ <!-- A size based file rolling appender
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Threshold" value="TRACE"/>
+ <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 -->
+ <!-- ================ -->
+
+ <!-- Limit JBoss categories to INFO
+ <category name="org.jboss">
+ <priority value="INFO" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!-- Increase the priority threshold for the DefaultDS category
+ <category name="DefaultDS">
+ <priority value="FATAL"/>
+ </category>
+ -->
+
+ <!-- Decrease the priority threshold for the org.jboss.varia category
+ <category name="org.jboss.varia">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!--
+ | An example of enabling the custom TRACE level priority that is used
+ | by the JBoss internals to diagnose low level details. This example
+ | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+ | subpackages. This will produce A LOT of logging output.
+ <category name="org.jboss.system">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Property changes on: projects/ejb3/trunk/sandbox/src/test/resources/log4j.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list