[jboss-cvs] JBossAS SVN: r85770 - in projects/ejb3/trunk: singleton and 20 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 12 04:24:32 EDT 2009
Author: wolfc
Date: 2009-03-12 04:24:32 -0400 (Thu, 12 Mar 2009)
New Revision: 85770
Added:
projects/ejb3/trunk/singleton/
projects/ejb3/trunk/singleton/.classpath
projects/ejb3/trunk/singleton/.project
projects/ejb3/trunk/singleton/.settings/
projects/ejb3/trunk/singleton/.settings/org.eclipse.jdt.core.prefs
projects/ejb3/trunk/singleton/.settings/org.maven.ide.eclipse.prefs
projects/ejb3/trunk/singleton/pom.xml
projects/ejb3/trunk/singleton/src/
projects/ejb3/trunk/singleton/src/main/
projects/ejb3/trunk/singleton/src/main/java/
projects/ejb3/trunk/singleton/src/main/java/org/
projects/ejb3/trunk/singleton/src/main/java/org/jboss/
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonBeanContext.java
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonContainer.java
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonInstanceInterceptor.java
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/aop/
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/Session31Type.java
projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/SingletonProcessor.java
projects/ejb3/trunk/singleton/src/test/
projects/ejb3/trunk/singleton/src/test/java/
projects/ejb3/trunk/singleton/src/test/java/org/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockDeploymentUnit.java
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockEjb3Deployment.java
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/SimpleSingletonBean.java
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/unit/
projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/unit/SimpleSingletonTestCase.java
projects/ejb3/trunk/singleton/src/test/resources/
projects/ejb3/trunk/singleton/src/test/resources/jndi.properties
projects/ejb3/trunk/singleton/src/test/resources/log4j.xml
projects/ejb3/trunk/singleton/src/test/resources/simple-singleton-aop.xml
Log:
EJBTHREE-1518: initial setup
Property changes on: projects/ejb3/trunk/singleton
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
Added: projects/ejb3/trunk/singleton/.classpath
===================================================================
--- projects/ejb3/trunk/singleton/.classpath (rev 0)
+++ projects/ejb3/trunk/singleton/.classpath 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,8 @@
+<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="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+</classpath>
\ No newline at end of file
Added: projects/ejb3/trunk/singleton/.project
===================================================================
--- projects/ejb3/trunk/singleton/.project (rev 0)
+++ projects/ejb3/trunk/singleton/.project 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,17 @@
+<projectDescription>
+ <name>jboss-ejb3-singleton</name>
+ <comment></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/singleton/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/ejb3/trunk/singleton/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/ejb3/trunk/singleton/.settings/org.eclipse.jdt.core.prefs 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,5 @@
+#Wed Mar 11 18:35:43 CET 2009
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
Added: projects/ejb3/trunk/singleton/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/ejb3/trunk/singleton/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ projects/ejb3/trunk/singleton/.settings/org.maven.ide.eclipse.prefs 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,8 @@
+#Wed Mar 11 16:19:24 CET 2009
+activeProfiles=eclipse
+eclipse.preferences.version=1
+fullBuildGoals=
+includeModules=false
+resolveWorkspaceProjects=false
+resourceFilterGoals=
+version=1
Added: projects/ejb3/trunk/singleton/pom.xml
===================================================================
--- projects/ejb3/trunk/singleton/pom.xml (rev 0)
+++ projects/ejb3/trunk/singleton/pom.xml 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,138 @@
+<!--
+ 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.ejb3</groupId>
+ <artifactId>jboss-ejb3-build</artifactId>
+ <version>1.0.1</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- POM Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Information -->
+ <artifactId>jboss-ejb3-singleton</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>JBoss EJB 3.1 Singleton</name>
+ <url>http://labs.jboss.com/jbossejb3</url>
+ <description>
+ </description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <executable>${JDK6_HOME}/bin/javac</executable>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-jdk6</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireProperty>
+ <property>env.JDK6_HOME</property>
+ <message>JDK6_HOME is not set</message>
+ </requireProperty>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>once</forkMode>
+ <jvm>${JDK6_HOME}/bin/java</jvm>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.bootstrap</groupId>
+ <artifactId>jboss-bootstrap</artifactId>
+ <version>1.0.0-Beta-1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-api</artifactId>
+ <version>3.1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-core</artifactId>
+ <version>1.1.3-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-test</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <!-- this needs to be removed - EJBTHREE-1343 -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <version>5.0.1.GA</version>
+ <exclusions>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-metadata</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-security</artifactId>
+ </exclusion>
+ <!-- Conflicts with org.jboss.security:jbosssx -->
+ <exclusion>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx-client</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.ws.native</groupId>
+ <artifactId>jbossws-native-jaxws</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jmx-mc-int</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonBeanContext.java
===================================================================
--- projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonBeanContext.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonBeanContext.java 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,65 @@
+/*
+ * 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.singleton;
+
+import javax.ejb.EJBContext;
+
+import org.jboss.ejb3.session.SessionSpecBeanContext;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SingletonBeanContext extends SessionSpecBeanContext<SingletonContainer>
+{
+ /**
+ * @param container
+ * @param bean
+ */
+ protected SingletonBeanContext(SingletonContainer container, Object bean)
+ {
+ super(container, bean);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.session.SessionBeanContext#getEJBContext()
+ */
+ @Override
+ public EJBContext getEJBContext()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#remove()
+ */
+ @Override
+ public void remove()
+ {
+ // TODO Auto-generated method stub
+ //
+ throw new RuntimeException("NYI");
+ }
+
+}
Added: projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonContainer.java
===================================================================
--- projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonContainer.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonContainer.java 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,179 @@
+/*
+ * 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.singleton;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+
+import javax.ejb.Handle;
+import javax.ejb.TimerService;
+
+import org.jboss.aop.Domain;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.session.SessionSpecContainer;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SingletonContainer extends SessionSpecContainer
+{
+ private BeanContext<SingletonContainer> instance;
+
+ public SingletonContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
+ Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBeanMetaData beanMetaData)
+ throws ClassNotFoundException
+ {
+ super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
+ }
+
+ @Override
+ public Serializable createSession(Class<?>[] initParameterTypes, Object[] initParameterValues)
+ {
+ assert initParameterTypes == null || initParameterTypes.length == 0;
+ assert initParameterValues == null || initParameterValues.length == 0;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.session.SessionContainer#dynamicInvoke(org.jboss.aop.joinpoint.Invocation)
+ */
+ @Override
+ public InvocationResponse dynamicInvoke(Invocation invocation) throws Throwable
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ protected synchronized BeanContext<SingletonContainer> getInstance()
+ {
+ if(instance != null)
+ return instance;
+ instance = createBeanContext();
+ return instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.session.SessionContainer#getJndiRegistrarBindName()
+ */
+ @Override
+ protected String getJndiRegistrarBindName()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.session.SessionContainer#localHomeInvoke(java.lang.reflect.Method, java.lang.Object[])
+ */
+ @Override
+ public Object localHomeInvoke(Method method, Object[] args) throws Throwable
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.session.SessionContainer#localInvoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
+ */
+ @Override
+ public Object localInvoke(Object id, Method method, Object[] args) throws Throwable
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.session.SessionContainer#removeHandle(javax.ejb.Handle)
+ */
+ @Override
+ protected void removeHandle(Handle handle) throws Exception
+ {
+ // TODO Auto-generated method stub
+ //
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.EJBContainer#createBeanContext()
+ */
+ @Override
+ public SingletonBeanContext createBeanContext()
+ {
+ SingletonBeanContext ctx = new SingletonBeanContext(this, construct());
+ pushContext(ctx);
+ try
+ {
+ injectBeanContext(ctx);
+
+ ctx.initialiseInterceptorInstances();
+ }
+ finally
+ {
+ popContext();
+ }
+
+ invokePostConstruct(ctx);
+
+ return ctx;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getMBean()
+ */
+ public Object getMBean()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getTimerService()
+ */
+ public TimerService getTimerService()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getTimerService(java.lang.Object)
+ */
+ public TimerService getTimerService(Object key)
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+}
Added: projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonInstanceInterceptor.java
===================================================================
--- projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonInstanceInterceptor.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/SingletonInstanceInterceptor.java 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,59 @@
+/*
+ * 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.singleton;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.aop.AbstractInterceptor;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SingletonInstanceInterceptor extends AbstractInterceptor
+{
+ /* (non-Javadoc)
+ * @see org.jboss.aop.advice.Interceptor#invoke(org.jboss.aop.joinpoint.Invocation)
+ */
+ @Override
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ EJBContainerInvocation<SingletonContainer, BeanContext<SingletonContainer>> ejb = (EJBContainerInvocation<SingletonContainer, BeanContext<SingletonContainer>>) invocation;
+ SingletonContainer container = getEJBContainer(invocation);
+ BeanContext<SingletonContainer> ctx = container.getInstance();
+
+ assert ctx != null : "no bean instance";
+
+ ejb.setBeanContext(ctx);
+ container.pushContext(ctx);
+ try
+ {
+ return invocation.invokeNext();
+ }
+ finally
+ {
+ container.popContext();
+ ejb.setBeanContext(null);
+ }
+ }
+}
Added: projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/Session31Type.java
===================================================================
--- projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/Session31Type.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/Session31Type.java 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,41 @@
+/*
+ * 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.singleton.metadata;
+
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+//@XmlType(name="session-typeType")
+//@XmlEnum(String.class)
+public enum Session31Type
+{
+ /** Stateless session bean */
+ Stateless,
+
+ /** Stateful session bean */
+ Stateful,
+
+ /** Singleton session bean */
+ Singleton,
+}
Added: projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/SingletonProcessor.java
===================================================================
--- projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/SingletonProcessor.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/main/java/org/jboss/ejb3/singleton/metadata/SingletonProcessor.java 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,71 @@
+/*
+ * 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.singleton.metadata;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+import javax.ejb.Singleton;
+
+import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.creator.ejb.jboss.AbstractSessionBeanProcessor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SingletonProcessor extends AbstractSessionBeanProcessor
+{
+ /**
+ * @param finder
+ */
+ public SingletonProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ @Override
+ public JBossSessionBeanMetaData create(Class<?> beanClass)
+ {
+ Singleton annotation = finder.getAnnotation(beanClass, Singleton.class);
+ if(annotation == null)
+ return null;
+
+ JBossSessionBeanMetaData beanMetaData = create(beanClass, annotation);
+ //beanMetaData.setSessionType(null);
+ return beanMetaData;
+ }
+
+ protected JBossSessionBeanMetaData create(Class<?> beanClass, Singleton annotation)
+ {
+ return create(beanClass, annotation.name(), annotation.mappedName(), annotation.description());
+ }
+
+ @Override
+ public Collection<Class<? extends Annotation>> getAnnotationTypes()
+ {
+ return ProcessorUtils.createAnnotationSet(Singleton.class);
+ }
+}
Added: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockDeploymentUnit.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockDeploymentUnit.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockDeploymentUnit.java 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,237 @@
+/*
+ * 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.singleton.test.common;
+
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockDeploymentUnit implements DeploymentUnit
+{
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#addAttachment(java.lang.String, java.lang.Object)
+ */
+ public Object addAttachment(String name, Object attachment)
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getAttachment(java.lang.String)
+ */
+ public Object getAttachment(String name)
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getClassLoader()
+ */
+ public ClassLoader getClassLoader()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getClasses()
+ */
+ public List<Class> getClasses()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getDefaultEntityManagerName()
+ */
+ public String getDefaultEntityManagerName()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getDefaultPersistenceProperties()
+ */
+ public Map getDefaultPersistenceProperties()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getEjbJarXml()
+ */
+ public URL getEjbJarXml()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getInterceptorInfoRepository()
+ */
+ public InterceptorInfoRepository getInterceptorInfoRepository()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getJbossXml()
+ */
+ public URL getJbossXml()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getJndiProperties()
+ */
+ public Hashtable getJndiProperties()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getMetaDataFile(java.lang.String)
+ */
+ public VirtualFile getMetaDataFile(String string)
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getPersistenceXml()
+ */
+ public URL getPersistenceXml()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getRelativePath()
+ */
+ public String getRelativePath()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getRelativeURL(java.lang.String)
+ */
+ public URL getRelativeURL(String path)
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getResourceLoader()
+ */
+ public ClassLoader getResourceLoader()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getResources(org.jboss.virtual.VirtualFileFilter)
+ */
+ public List<VirtualFile> getResources(VirtualFileFilter filter)
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getRootFile()
+ */
+ public VirtualFile getRootFile()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getShortName()
+ */
+ public String getShortName()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getUrl()
+ */
+ public URL getUrl()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#removeAttachment(java.lang.String)
+ */
+ public Object removeAttachment(String name)
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+}
Added: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockEjb3Deployment.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockEjb3Deployment.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/common/MockEjb3Deployment.java 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,90 @@
+/*
+ * 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.singleton.test.common;
+
+import javax.security.jacc.PolicyConfiguration;
+
+import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockEjb3Deployment extends Ejb3Deployment
+{
+ public MockEjb3Deployment()
+ {
+ this(new AbstractDeploymentUnit(), new MockDeploymentUnit(), null, null);
+ }
+
+ /**
+ * @param deploymentUnit
+ * @param unit
+ * @param deploymentScope
+ * @param metaData
+ */
+ public MockEjb3Deployment(org.jboss.deployers.structure.spi.DeploymentUnit deploymentUnit, DeploymentUnit unit,
+ DeploymentScope deploymentScope, JBossMetaData metaData)
+ {
+ super(deploymentUnit, unit, deploymentScope, metaData);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Ejb3Deployment#createDependencyPolicy(org.jboss.ejb3.javaee.JavaEEComponent)
+ */
+ @Override
+ public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
+ {
+ return new JBoss5DependencyPolicy(component);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Ejb3Deployment#createPolicyConfiguration()
+ */
+ @Override
+ protected PolicyConfiguration createPolicyConfiguration() throws Exception
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Ejb3Deployment#putJaccInService(javax.security.jacc.PolicyConfiguration, org.jboss.ejb3.DeploymentUnit)
+ */
+ @Override
+ protected void putJaccInService(PolicyConfiguration pc, DeploymentUnit unit)
+ {
+ // TODO Auto-generated method stub
+ //
+ throw new RuntimeException("NYI");
+ }
+
+}
Added: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/SimpleSingletonBean.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/SimpleSingletonBean.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/SimpleSingletonBean.java 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,59 @@
+/*
+ * 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.singleton.test.simple;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.Singleton;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Singleton
+public class SimpleSingletonBean
+{
+ private static final Logger log = Logger.getLogger(SimpleSingletonBean.class);
+
+ @Resource(name="state")
+ private Object state;
+
+ public Object getState()
+ {
+ log.info("getState -> " + state);
+ return state;
+ }
+
+ @PostConstruct
+ public void postConstruct()
+ {
+ log.info("postConstruct");
+ }
+
+ public void setState(Object state)
+ {
+ log.info("setState <- " + state);
+ this.state = state;
+ }
+}
Added: projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/unit/SimpleSingletonTestCase.java
===================================================================
--- projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/unit/SimpleSingletonTestCase.java (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/java/org/jboss/ejb3/singleton/test/simple/unit/SimpleSingletonTestCase.java 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,163 @@
+/*
+ * 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.singleton.test.simple.unit;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Hashtable;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.aop.Domain;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.common.metadata.MetadataUtil;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
+import org.jboss.ejb3.singleton.SingletonContainer;
+import org.jboss.ejb3.singleton.metadata.SingletonProcessor;
+import org.jboss.ejb3.singleton.test.common.MockEjb3Deployment;
+import org.jboss.ejb3.singleton.test.simple.SimpleSingletonBean;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.AbstractCreator;
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.process.chain.ProcessorChain;
+import org.jboss.naming.JavaCompInitializer;
+import org.jnp.server.SingletonNamingServer;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleSingletonTestCase
+{
+ private static final Logger log = Logger.getLogger(SimpleSingletonTestCase.class);
+
+ private static void deployAop(String name) throws Exception
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(name);
+ if (url == null)
+ throw new IllegalStateException("Can't find " + name + " on class loader "
+ + Thread.currentThread().getContextClassLoader());
+ AspectXmlLoader.deployXML(url);
+ }
+
+ private static JBossSessionBeanMetaData getMetaDataFromBeanImplClass(Class<?> beanClass)
+ {
+ // emulate annotation deployer
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ Collection<Class<?>> classes = new HashSet<Class<?>>();
+ /*
+ for (Class<?> beanImplClass : beanImplClasses)
+ {
+ boolean unique = classes.add(beanImplClass);
+ if (!unique)
+ {
+ log.warn("Specified class " + beanImplClass + " was not unique, skipping...");
+ }
+ }
+ */
+ classes.add(beanClass);
+
+ AbstractCreator<JBossMetaData> creator = new JBoss50Creator(finder);
+ creator.addProcessor(new SingletonProcessor(finder));
+ JBossMetaData metadata = creator.create(classes);
+
+ /*
+ * Mock the EjbMetadataJndiPolicyDecoratorDeployer
+ */
+
+ // Decorate w/ JNDI Policy
+ log.debug("Decorating EJB3 EJBs in " + metadata + " with JNDI Policy");
+ MetadataUtil.decorateEjbsWithJndiPolicy(metadata, AccessController
+ .doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ }));
+
+ /*
+ * Mock the post-merge processing deployers
+ */
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ ProcessorChain<JBossMetaData> chain = MetadataUtil.getPostMergeMetadataProcessorChain(cl);
+ chain.process(metadata);
+
+ // Return
+ return (JBossSessionBeanMetaData) metadata.getEnterpriseBeans().iterator().next();
+ }
+
+ @Test
+ public void test1() throws Throwable
+ {
+ new SingletonNamingServer();
+ new JavaCompInitializer().start();
+
+ deployAop("ejb3-interceptors-aop.xml");
+ deployAop("simple-singleton-aop.xml");
+
+ String containerName = "Singleton Bean";
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ String beanClassName = SimpleSingletonBean.class.getName();
+ String ejbName = "SimpleSingletonBean";
+ Domain domain = (Domain) AspectManager.instance().getContainer(containerName).getManager();
+ Hashtable<?, ?> ctxProperties = null;
+ Ejb3Deployment deployment = new MockEjb3Deployment();
+ JBossSessionBeanMetaData beanMetaData = getMetaDataFromBeanImplClass(SimpleSingletonBean.class);
+ SingletonContainer container = new SingletonContainer(cl, beanMetaData.getEjbClass(), beanMetaData.getEjbName(), domain, ctxProperties, deployment, beanMetaData);
+
+ SessionProxy proxy = new SessionProxy() {
+ @Override
+ public Object getTarget()
+ {
+ return null;
+ }
+
+ @Override
+ public void setTarget(Object target)
+ {
+ // TODO Auto-generated method stub
+ //
+ throw new RuntimeException("NYI");
+ }
+
+ };
+ Method realMethod = SimpleSingletonBean.class.getMethod("getState");
+ SerializableMethod method = new SerializableMethod(realMethod, SimpleSingletonBean.class);
+ Object args[] = null;
+ container.invoke(proxy, method, args);
+ }
+}
Added: projects/ejb3/trunk/singleton/src/test/resources/jndi.properties
===================================================================
--- projects/ejb3/trunk/singleton/src/test/resources/jndi.properties (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/resources/jndi.properties 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,2 @@
+java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Added: projects/ejb3/trunk/singleton/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/trunk/singleton/src/test/resources/log4j.xml (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/resources/log4j.xml 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 68671 2008-01-08 10:04:25Z wolfc $ -->
+
+<!--
+ | 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="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="Target" value="System.out"/>
+ <param name="Threshold" value="DEBUG"/>
+
+ <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>
+ -->
+
+ <category name="org.jboss.aop">
+ <priority value="WARN"/>
+ </category>
+
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+
+ <!--
+ Unnecessary, EJB3 is exposed as DEBUG
+ <category name="org.jboss.ejb3.interceptors.aop.DomainClassLoader">
+ <priority value="DEBUG"/>
+ </category> -->
+
+ <category name="org.jboss.ejb3">
+ <priority value="DEBUG"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <priority value="WARN" />
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Added: projects/ejb3/trunk/singleton/src/test/resources/simple-singleton-aop.xml
===================================================================
--- projects/ejb3/trunk/singleton/src/test/resources/simple-singleton-aop.xml (rev 0)
+++ projects/ejb3/trunk/singleton/src/test/resources/simple-singleton-aop.xml 2009-03-12 08:24:32 UTC (rev 85770)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop xmlns="urn:jboss:aop-beans:1.0">
+ <interceptor class="org.jboss.ejb3.singleton.SingletonInstanceInterceptor" scope="PER_VM"/>
+
+ <!--
+ <domain name="Intercepted Bean">
+ </domain>
+ -->
+
+ <domain name="Singleton Bean" extends="Intercepted Bean" inheritBindings="true">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.singleton.SingletonInstanceInterceptor"/>
+ </bind>
+ </domain>
+</aop>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list