[jboss-cvs] JBossAS SVN: r100807 - in projects/ejb3/components/singleton/trunk/aop-impl/src: main/java/org/jboss/ejb3/singleton/aop and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 10 09:00:47 EST 2010
Author: jaikiran
Date: 2010-02-10 09:00:46 -0500 (Wed, 10 Feb 2010)
New Revision: 100807
Added:
projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/
projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/
projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedContainerInvocationContext.java
projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedInterceptorRegistry.java
projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedSingletonContainer.java
projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/LegacySingletonBeanContext.java
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/common/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/common/MockDeploymentUnit.java
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/common/MockEJB3Deployment.java
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/SimpleSingletonBean.java
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/unit/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/unit/AOPBasedSingletonContainerTestCase.java
projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/aop/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/aop/impl/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/aop/impl/test/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/aop/impl/test/container/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/aop/impl/test/container/singleton-interceptors-aop.xml
Removed:
projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/legacy/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/legacy/
projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/legacy/
Log:
EJBTHREE-2010 Changed package names to match with the new module name
Copied: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedContainerInvocationContext.java (from rev 100805, projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedContainerInvocationContext.java)
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedContainerInvocationContext.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedContainerInvocationContext.java 2010-02-10 14:00:46 UTC (rev 100807)
@@ -0,0 +1,128 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.aop.impl;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.aop.MethodInfo;
+import org.jboss.ejb3.container.spi.ContainerInvocation;
+
+/**
+ * AOPBasedContainerInvocationContext
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AOPBasedContainerInvocationContext implements ContainerInvocation
+{
+
+ private Method unadvisedMethod;
+
+ private Object[] args;
+
+ private MethodInfo aopMethodInfo;
+
+ private Class<?> businessInterface;
+
+ private Map<Object, Object> responseContextInfo = new HashMap<Object, Object>();
+
+ /**
+ * @param method
+ * @param args
+ */
+ public AOPBasedContainerInvocationContext(MethodInfo aopMethodInfo, Object[] args)
+ {
+ this.aopMethodInfo = aopMethodInfo;
+ this.args = args;
+
+ // set the unadvised method
+ this.unadvisedMethod = this.aopMethodInfo.getUnadvisedMethod();
+
+ }
+
+ /**
+ * @param method
+ * @param args
+ */
+ public AOPBasedContainerInvocationContext(MethodInfo aopMethodInfo, Object[] args, Class<?> businessInterface)
+ {
+ this(aopMethodInfo, args);
+ this.businessInterface = businessInterface;
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.ContainerInvocation#getArgs()
+ */
+ @Override
+ public Object[] getArgs()
+ {
+ return this.args;
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.ContainerInvocation#getMethod()
+ */
+ @Override
+ public Method getMethod()
+ {
+ return this.unadvisedMethod;
+ }
+
+
+ public MethodInfo getMethodInfo()
+ {
+ return this.aopMethodInfo;
+ }
+
+ public Map<Object, Object> getResponseContextInfo()
+ {
+ return this.responseContextInfo;
+ }
+
+ public void setResponseContextInfo(Map<Object, Object> responseContextInfo)
+ {
+ this.responseContextInfo = responseContextInfo;
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.ContainerInvocation#getSessionId()
+ */
+ @Override
+ public Serializable getSessionId()
+ {
+ // singleton beans don't have a session id
+ return null;
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.ContainerInvocation#getInvokedBusinessInterface()
+ */
+ @Override
+ public Class<?> getInvokedBusinessInterface()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Copied: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedInterceptorRegistry.java (from rev 100805, projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedInterceptorRegistry.java)
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedInterceptorRegistry.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedInterceptorRegistry.java 2010-02-10 14:00:46 UTC (rev 100807)
@@ -0,0 +1,146 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.aop.impl;
+
+import org.jboss.aop.MethodInfo;
+import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.container.spi.BeanContext;
+import org.jboss.ejb3.container.spi.ContainerInvocation;
+import org.jboss.ejb3.container.spi.EJBContainer;
+import org.jboss.ejb3.container.spi.InterceptorRegistry;
+
+/**
+ * AOPBasedInterceptorRegistry
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AOPBasedInterceptorRegistry implements InterceptorRegistry
+{
+
+ /**
+ * The container to which this interceptor registry belongs
+ */
+ private AOPBasedSingletonContainer aopBasedSingletonContainer;
+
+ /**
+ * Construct an {@link AOPBasedInterceptorRegistry} for a {@link AOPBasedSingletonContainer}
+ *
+ * @param aopBasedContainer The container for which the interceptor registry is being
+ * created.
+ */
+ public AOPBasedInterceptorRegistry(AOPBasedSingletonContainer aopBasedContainer)
+ {
+ this.aopBasedSingletonContainer = aopBasedContainer;
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#getEJBContainer()
+ */
+ @Override
+ public EJBContainer getEJBContainer()
+ {
+ return this.aopBasedSingletonContainer;
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#intercept(ContainerInvocation, BeanContext)
+ */
+ @Override
+ public Object intercept(ContainerInvocation containerInvocation, BeanContext targetBeanContext) throws Exception
+ {
+ // we handle only AOP based invocation
+ if (!(containerInvocation instanceof AOPBasedContainerInvocationContext))
+ {
+ throw new IllegalArgumentException(AOPBasedInterceptorRegistry.class + " can only handle "
+ + AOPBasedContainerInvocationContext.class + " , was passed " + containerInvocation.getClass());
+ }
+ AOPBasedContainerInvocationContext aopInvocationContext = (AOPBasedContainerInvocationContext) containerInvocation;
+
+ MethodInfo methodInfo = aopInvocationContext.getMethodInfo();
+ EJBContainerInvocation<AOPBasedSingletonContainer, LegacySingletonBeanContext> invocation = new EJBContainerInvocation<AOPBasedSingletonContainer, LegacySingletonBeanContext>(
+ aopInvocationContext.getMethodInfo());
+ invocation.setAdvisor(methodInfo.getAdvisor());
+ invocation.setArguments(containerInvocation.getArgs());
+ // get bean context (we could have used the passed one, but we need org.jboss.ejb3.BeanContext for the
+ // AOP based invocation. Hence get it from the AOP based container)
+ org.jboss.ejb3.BeanContext<?> singletonBeanContext = new LegacySingletonBeanContext(
+ this.aopBasedSingletonContainer, targetBeanContext);
+ invocation.setBeanContext(singletonBeanContext);
+
+ try
+ {
+ return invocation.invokeNext();
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException(t);
+ }
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#invokePostActivate(org.jboss.ejb3.container.spi.BeanContext)
+ */
+ @Override
+ public void invokePostActivate(BeanContext targetBeanContext) throws Exception
+ {
+ // nothing to do for singleton beans
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#invokePostConstruct(org.jboss.ejb3.container.spi.BeanContext)
+ */
+ @Override
+ public void invokePostConstruct(BeanContext targetBeanContext) throws Exception
+ {
+ // fallback on legacy AOP based lifecycle impl
+ org.jboss.ejb3.BeanContext<?> legacyBeanContext = new LegacySingletonBeanContext(this.aopBasedSingletonContainer,
+ targetBeanContext);
+ this.aopBasedSingletonContainer.invokePostConstruct(legacyBeanContext);
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#invokePreDestroy(org.jboss.ejb3.container.spi.BeanContext)
+ */
+ @Override
+ public void invokePreDestroy(BeanContext targetBeanContext) throws Exception
+ {
+ // fallback on legacy AOP based lifecycle impl
+ org.jboss.ejb3.BeanContext<?> legacyBeanContext = new LegacySingletonBeanContext(this.aopBasedSingletonContainer,
+ targetBeanContext);
+ this.aopBasedSingletonContainer.invokePreDestroy(legacyBeanContext);
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#invokePrePassivate(org.jboss.ejb3.container.spi.BeanContext)
+ */
+ @Override
+ public void invokePrePassivate(BeanContext targetBeanContext) throws Exception
+ {
+ // nothing to do for singleton beans
+
+ }
+
+}
Copied: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedSingletonContainer.java (from rev 100805, projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedSingletonContainer.java)
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedSingletonContainer.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedSingletonContainer.java 2010-02-10 14:00:46 UTC (rev 100807)
@@ -0,0 +1,406 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.aop.impl;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.ejb.Handle;
+import javax.ejb.TimerService;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.Domain;
+import org.jboss.aop.MethodInfo;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aop.util.MethodHashing;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.container.spi.ContainerInvocation;
+import org.jboss.ejb3.container.spi.EJBContainer;
+import org.jboss.ejb3.container.spi.EJBDeploymentInfo;
+import org.jboss.ejb3.container.spi.EJBInstanceManager;
+import org.jboss.ejb3.container.spi.InterceptorRegistry;
+import org.jboss.ejb3.proxy.impl.remoting.SessionSpecRemotingMetadata;
+import org.jboss.ejb3.session.SessionSpecContainer;
+import org.jboss.ejb3.singleton.impl.container.SingletonContainer;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+
+/**
+ * AOPBasedSingletonContainer
+ * <p>
+ * A singleton container based on AOP. This container is used to integrate the {@link EJBContainer} with the
+ * existing AOP based container framework (mainly the AOP interceptors). Most of the work in this container
+ * is delegated to the {@link SingletonContainer}.
+ * </p>
+ * <p>
+ * The main purpose of this container is to act as an entry point to invocations and plug-in a
+ * AOP based interceptor registry {@link AOPBasedInterceptorRegistry} into the {@link SingletonContainer}
+ * </p>
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AOPBasedSingletonContainer extends SessionSpecContainer implements InjectionContainer, EJBContainer
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(AOPBasedSingletonContainer.class);
+
+ /**
+ * This is the container to which the {@link AOPBasedSingletonContainer} will
+ * delegate the calls to
+ */
+ private SingletonContainer simpleSingletonContainer;
+
+ /**
+ * Returns the AOP domain name which this container uses
+ * for AOP based processing
+ * @return
+ */
+ public static String getAOPDomainName()
+ {
+ return "Singleton Bean";
+ }
+
+ /**
+ * @param cl
+ * @param beanClassName
+ * @param ejbName
+ * @param domain
+ * @param ctxProperties
+ * @param deployment
+ * @param beanMetaData
+ * @throws ClassNotFoundException
+ */
+ public AOPBasedSingletonContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
+ Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBean31MetaData beanMetaData)
+ throws ClassNotFoundException
+ {
+ super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
+
+ // create a AOP based interceptor registry which will be used by the container
+ InterceptorRegistry interceptorRegistry = new AOPBasedInterceptorRegistry(this);
+ // create the new jboss-ejb3-container-spi based singleton container
+ this.simpleSingletonContainer = new SingletonContainer(this.getBeanClass(), beanMetaData, interceptorRegistry);
+ }
+
+ /**
+ * @see org.jboss.ejb3.EJBContainer#create()
+ */
+ @Override
+ public void create() throws Exception
+ {
+ super.create();
+ this.simpleSingletonContainer.create();
+ }
+
+ /**
+ * @see org.jboss.ejb3.session.SessionSpecContainer#lockedStart()
+ */
+ @Override
+ protected void lockedStart() throws Exception
+ {
+ super.lockedStart();
+
+ // pass on the control to our simple singleton container
+ this.simpleSingletonContainer.start();
+ }
+
+ /**
+ * @see org.jboss.ejb3.session.SessionSpecContainer#lockedStop()
+ */
+ @Override
+ protected void lockedStop() throws Exception
+ {
+ super.lockedStop();
+ this.simpleSingletonContainer.stop();
+ }
+
+ /**
+ * @see org.jboss.ejb3.EJBContainer#destroy()
+ */
+ @Override
+ public void destroy() throws Exception
+ {
+ this.simpleSingletonContainer.destroy();
+ // let the super do the rest
+ super.destroy();
+ }
+
+ /**
+ * @see org.jboss.ejb3.session.SessionContainer#createSession(java.lang.Class<?>[], java.lang.Object[])
+ */
+ @Override
+ public Serializable createSession(Class<?>[] initParameterTypes, Object[] initParameterValues)
+ {
+ // no sessions for @Singleton
+ return null;
+ }
+
+ /**
+ * @see org.jboss.ejb3.session.SessionContainer#dynamicInvoke(org.jboss.aop.joinpoint.Invocation)
+ */
+ @Override
+ public InvocationResponse dynamicInvoke(Invocation invocation) throws Throwable
+ {
+ /*
+ * Obtain the target method (unmarshall from invocation)
+ */
+
+ // Cast
+ assert invocation instanceof MethodInvocation : AOPBasedSingletonContainer.class.getName()
+ + ".dynamicInoke supports only " + MethodInvocation.class.getSimpleName() + ", but has been passed: "
+ + invocation.getClass();
+
+ MethodInvocation methodInvocation = (MethodInvocation) invocation;
+
+ // Get the method hash
+ long methodHash = methodInvocation.getMethodHash();
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Received dynamic invocation for method with hash: " + methodHash);
+ }
+
+ // Get the Method via MethodInfo from the Advisor
+ Advisor advisor = this.getAdvisor();
+ MethodInfo methodInfo = advisor.getMethodInfo(methodHash);
+
+ // create a container invocation
+ AOPBasedContainerInvocationContext containerInvocation = new AOPBasedContainerInvocationContext(methodInfo,
+ methodInvocation.getArguments());
+ try
+ {
+ // TODO: This is legacy code copied from StatelessContainer/SessionSpecContainer of ejb3-core
+ // Get the invoked method from invocation metadata
+ Object objInvokedMethod = invocation.getMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
+ SessionSpecRemotingMetadata.KEY_INVOKED_METHOD);
+ assert objInvokedMethod != null : "Invoked Method must be set on invocation metadata";
+ assert objInvokedMethod instanceof SerializableMethod : "Invoked Method set on invocation metadata is not of type "
+ + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
+ SerializableMethod invokedMethod = (SerializableMethod) objInvokedMethod;
+
+ // push onto stack
+ SessionSpecContainer.invokedMethod.push(invokedMethod);
+
+ // pass the control to the simple singleton container
+ Object result = this.simpleSingletonContainer.invoke(containerInvocation);
+
+ // create an InvocationResponse out of the result
+ Map<Object, Object> responseContextInfo = containerInvocation.getResponseContextInfo();
+ InvocationResponse invocationResponse = marshallResponse(invocation, result, responseContextInfo);
+ return invocationResponse;
+
+ }
+ catch (Throwable throwable)
+ {
+ Map<Object, Object> responseContextInfo = containerInvocation.getResponseContextInfo();
+ return marshallException(invocation, throwable, responseContextInfo);
+ }
+ finally
+ {
+ SessionSpecContainer.invokedMethod.pop();
+ }
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.session.SessionSpecContainer#invoke(java.io.Serializable, java.lang.Class, java.lang.reflect.Method, java.lang.Object[])
+ */
+ @Override
+ public Object invoke(Serializable session, Class<?> invokedBusinessInterface, Method method, Object[] args)
+ throws Throwable
+ {
+ // create a (AOP) MethodInfo first so that a AOP based container invocation can be created out of it
+ long hash = MethodHashing.calculateHash(method);
+ MethodInfo methodInfo = getAdvisor().getMethodInfo(hash);
+ if (methodInfo == null)
+ {
+ throw new RuntimeException("Method invocation via Proxy could not be found handled for EJB "
+ + this.getEjbName() + " : " + method.toString()
+ + ", probable error in virtual method registration w/ Advisor for the Container");
+ }
+ SerializableMethod serializableMethod = new SerializableMethod(method, invokedBusinessInterface);
+ // create a container invocation
+ ContainerInvocation containerInvocation = new AOPBasedContainerInvocationContext(methodInfo, args);
+
+ try
+ {
+ // TODO: Legacy push/pop copied from StatelessContainer/SessionSpecContainer
+ SessionSpecContainer.invokedMethod.push(serializableMethod);
+ // pass the control to the simple singleton container
+ return this.simpleSingletonContainer.invoke(containerInvocation);
+
+ }
+ finally
+ {
+ SessionSpecContainer.invokedMethod.pop();
+ }
+
+ }
+
+ /**
+ * This method returns null, because binding of proxies into JNDI is done
+ * by a separate module, outside of the singleton container implementation
+ *
+ * @see org.jboss.ejb3.session.SessionContainer#getJndiRegistrarBindName()
+ */
+ @Override
+ protected String getJndiRegistrarBindName()
+ {
+ return null;
+ }
+
+ /**
+ * @see org.jboss.ejb3.session.SessionContainer#localHomeInvoke(java.lang.reflect.Method, java.lang.Object[])
+ */
+ @Override
+ public Object localHomeInvoke(Method method, Object[] args) throws Throwable
+ {
+ throw new UnsupportedOperationException("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
+ {
+ throw new UnsupportedOperationException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.session.SessionContainer#removeHandle(javax.ejb.Handle)
+ */
+ @Override
+ protected void removeHandle(Handle handle) throws Exception
+ {
+ throw new UnsupportedOperationException("NYI");
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.EJBContainer#createBeanContext()
+ */
+ @Override
+ public BeanContext<?> createBeanContext()
+ {
+ throw new UnsupportedOperationException("createBeanContext() is no longer supported");
+ }
+
+ /**
+ * @see org.jboss.ejb3.Container#getMBean()
+ */
+ @Override
+ public Object getMBean()
+ {
+ throw new UnsupportedOperationException("NYI");
+ }
+
+ /**
+ * @see org.jboss.ejb3.Container#getTimerService()
+ */
+ @Override
+ public TimerService getTimerService()
+ {
+ throw new UnsupportedOperationException("NYI");
+ }
+
+ /**
+ * @see org.jboss.ejb3.Container#getTimerService(java.lang.Object)
+ */
+ @Override
+ public TimerService getTimerService(Object key)
+ {
+ throw new UnsupportedOperationException("NYI");
+ }
+
+ /**
+ * @see EJBContainer#getEJBName()
+ */
+ @Override
+ public String getEJBName()
+ {
+ return this.ejbName;
+ }
+
+ /**
+ * @see EJBContainer#getEJBClass()
+ */
+ @Override
+ public String getEJBClass()
+ {
+ return this.beanClassName;
+ }
+
+ /**
+ * @see EJBContainer#getBeanInstanceManager()
+ */
+ @Override
+ public EJBInstanceManager getBeanInstanceManager()
+ {
+ return this.simpleSingletonContainer.getBeanInstanceManager();
+ }
+
+ /**
+ * @see EJBContainer#getDeploymentInfo()
+ */
+ @Override
+ public EJBDeploymentInfo getDeploymentInfo()
+ {
+ return this.simpleSingletonContainer.getDeploymentInfo();
+ }
+
+ /**
+ * @see EJBContainer#invoke(ContainerInvocation)
+ */
+ @Override
+ public Object invoke(ContainerInvocation containerInvocation) throws Exception
+ {
+ try
+ {
+ return this.invoke((Serializable) null, containerInvocation.getInvokedBusinessInterface(), containerInvocation
+ .getMethod(), containerInvocation.getArgs());
+ }
+ catch (Throwable t)
+ {
+ throw new Exception(t);
+ }
+ }
+
+ /**
+ * @see EJBContainer#getInterceptorRegistry()
+ */
+ @Override
+ public InterceptorRegistry getInterceptorRegistry()
+ {
+ return this.simpleSingletonContainer.getInterceptorRegistry();
+ }
+
+}
Copied: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/LegacySingletonBeanContext.java (from rev 100805, projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/LegacySingletonBeanContext.java)
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/LegacySingletonBeanContext.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/LegacySingletonBeanContext.java 2010-02-10 14:00:46 UTC (rev 100807)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.aop.impl;
+
+import javax.ejb.EJBContext;
+
+import org.jboss.ejb3.container.spi.BeanContext;
+import org.jboss.ejb3.session.SessionSpecBeanContext;
+
+/**
+ * LegacySingletonBeanContext
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class LegacySingletonBeanContext extends SessionSpecBeanContext<AOPBasedSingletonContainer>
+{
+ private AOPBasedSingletonContainer aopBasedSingletonContainer;
+
+ public LegacySingletonBeanContext(AOPBasedSingletonContainer aopBasedSingletonContainer, BeanContext context)
+ {
+ super(aopBasedSingletonContainer, context.getBeanInstance());
+ this.aopBasedSingletonContainer = aopBasedSingletonContainer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.session.SessionBeanContext#getEJBContext()
+ */
+ @Override
+ public EJBContext getEJBContext()
+ {
+ throw new RuntimeException("Not yet implemented");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#remove()
+ */
+ @Override
+ public void remove()
+ {
+ throw new RuntimeException("Not yet implemented");
+
+ }
+}
Copied: projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/common/MockDeploymentUnit.java (from rev 100805, projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockDeploymentUnit.java)
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/common/MockDeploymentUnit.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/common/MockDeploymentUnit.java 2010-02-10 14:00:46 UTC (rev 100807)
@@ -0,0 +1,216 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.aop.impl.test.common;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+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;
+
+/**
+ * MockDeploymentUnit
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class MockDeploymentUnit implements DeploymentUnit
+{
+ private org.jboss.deployers.structure.spi.DeploymentUnit deploymentUnit;
+
+ /**
+ * @deprecated supply a deploymentUnit
+ */
+ public MockDeploymentUnit()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ public MockDeploymentUnit(org.jboss.deployers.structure.spi.DeploymentUnit deploymentUnit)
+ {
+ this.deploymentUnit = deploymentUnit;
+ }
+
+ public Object addAttachment(String name, Object attachment)
+ {
+ return deploymentUnit.addAttachment(name, attachment);
+ }
+ public Object getAttachment(String name)
+ {
+ return deploymentUnit.getAttachment(name);
+ }
+ public Object removeAttachment(String name)
+ {
+ return deploymentUnit.removeAttachment(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getClassLoader()
+ */
+ public ClassLoader getClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getClasses()
+ */
+ @SuppressWarnings("unchecked")
+ public List<Class> getClasses()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getDefaultEntityManagerName()
+ */
+ public String getDefaultEntityManagerName()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getDefaultPersistenceProperties()
+ */
+ @SuppressWarnings("unchecked")
+ public Map getDefaultPersistenceProperties()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getEjbJarXml()
+ */
+ public URL getEjbJarXml()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getInterceptorInfoRepository()
+ */
+ public InterceptorInfoRepository getInterceptorInfoRepository()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getJbossXml()
+ */
+ public URL getJbossXml()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getJndiProperties()
+ */
+ @SuppressWarnings("unchecked")
+ public Hashtable getJndiProperties()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getMetaDataFile(java.lang.String)
+ */
+ public VirtualFile getMetaDataFile(String string)
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getPersistenceXml()
+ */
+ public URL getPersistenceXml()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getRelativeURL(java.lang.String)
+ */
+ public URL getRelativeURL(String path)
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getResourceLoader()
+ */
+ public ClassLoader getResourceLoader()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getResources(org.jboss.virtual.VirtualFileFilter)
+ */
+ public List<VirtualFile> getResources(VirtualFileFilter filter)
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getRootFile()
+ */
+ public VirtualFile getRootFile()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getShortName()
+ */
+ public String getShortName()
+ {
+ return null;
+ }
+
+ public String getRelativePath()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getUrl()
+ */
+ public URL getUrl()
+ {
+ return null;
+ }
+
+
+}
Copied: projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/common/MockEJB3Deployment.java (from rev 100805, projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockEJB3Deployment.java)
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/common/MockEJB3Deployment.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/common/MockEJB3Deployment.java 2010-02-10 14:00:46 UTC (rev 100807)
@@ -0,0 +1,92 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.aop.impl.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;
+
+/**
+ * MockEJB3Deployment
+ *
+ * @author Jaikiran Pai
+ * @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");
+ }
+
+}
Copied: projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/SimpleSingletonBean.java (from rev 100805, projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/SimpleSingletonBean.java)
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/SimpleSingletonBean.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/SimpleSingletonBean.java 2010-02-10 14:00:46 UTC (rev 100807)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.aop.impl.test.container;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Singleton;
+
+/**
+ * SimpleSingletonBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Singleton
+public class SimpleSingletonBean
+{
+ private int count;
+
+ @PostConstruct
+ public void onConstruct()
+ {
+ this.incrementCount();
+ }
+
+ public int getCount()
+ {
+ return this.count;
+ }
+
+ public void incrementCount()
+ {
+ this.count++;
+ }
+}
Copied: projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/unit/AOPBasedSingletonContainerTestCase.java (from rev 100805, projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/AOPBasedSingletonContainerTestCase.java)
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/unit/AOPBasedSingletonContainerTestCase.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/unit/AOPBasedSingletonContainerTestCase.java 2010-02-10 14:00:46 UTC (rev 100807)
@@ -0,0 +1,147 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.aop.impl.test.container.unit;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.aop.Domain;
+import org.jboss.aop.DomainDefinition;
+import org.jboss.ejb3.container.spi.ContainerInvocation;
+import org.jboss.ejb3.singleton.aop.impl.AOPBasedSingletonContainer;
+import org.jboss.ejb3.singleton.aop.impl.test.common.MockEJB3Deployment;
+import org.jboss.ejb3.singleton.aop.impl.test.container.SimpleSingletonBean;
+import org.jboss.ejb3.singleton.impl.container.InVMContainerInvocationImpl;
+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.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.naming.JavaCompInitializer;
+import org.jnp.server.SingletonNamingServer;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * AOPBasedSingletonContainerTestCase
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AOPBasedSingletonContainerTestCase
+{
+
+ private Domain singletonAOPDomain;
+
+ @Before
+ public void beforeTest() throws Exception
+ {
+ this.bootupNamingServer();
+ // load the aop-interceptors
+ String interceptorsFilePath = "org/jboss/ejb3/singleton/aop/impl/test/container/singleton-interceptors-aop.xml";
+ URL url = Thread.currentThread().getContextClassLoader().getResource(interceptorsFilePath);
+ if (url == null)
+ throw new IllegalStateException("Can't find " + interceptorsFilePath + " on class loader "
+ + Thread.currentThread().getContextClassLoader());
+ AspectXmlLoader.deployXML(url);
+
+ DomainDefinition domainDef = AspectManager.instance().getContainer("Singleton Bean");
+ if (domainDef == null)
+ throw new IllegalArgumentException("Singleton Bean domain not found");
+ this.singletonAOPDomain = (Domain) domainDef.getManager();
+ }
+
+ private void bootupNamingServer() throws Exception
+ {
+ SingletonNamingServer namingServer = new SingletonNamingServer();
+
+ JavaCompInitializer javaCompInitializer = new JavaCompInitializer();
+ javaCompInitializer.start();
+ }
+
+ @Test
+ public void testSimpleInvocation() throws Exception
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator metadataCreator = new JBoss50Creator(finder);
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(SimpleSingletonBean.class);
+ JBossMetaData metadata = metadataCreator.create(classes);
+
+ Assert.assertNotNull("Metadata created out of class is null", metadata);
+
+ JBossEnterpriseBeanMetaData enterpriseBean = metadata
+ .getEnterpriseBean(SimpleSingletonBean.class.getSimpleName());
+
+ Assert.assertNotNull("Metadata was not created for " + SimpleSingletonBean.class, enterpriseBean);
+ Assert.assertTrue(SimpleSingletonBean.class + " wasn't considered a session bean ", enterpriseBean.isSession());
+
+ // somewhat OK to cast
+ JBossSessionBean31MetaData sessionBeanMetaData = (JBossSessionBean31MetaData) enterpriseBean;
+ Assert.assertTrue(SimpleSingletonBean.class + " wasn't considered a singleton bean ", sessionBeanMetaData
+ .isSingleton());
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ String beanClassName = SimpleSingletonBean.class.getName();
+ String beanName = SimpleSingletonBean.class.getSimpleName();
+ Hashtable props = new Hashtable();
+ AOPBasedSingletonContainer singletonContainer = new AOPBasedSingletonContainer(cl, beanClassName, beanName,
+ this.singletonAOPDomain, props, new MockEJB3Deployment(), sessionBeanMetaData);
+
+ Method getCountMethod = SimpleSingletonBean.class.getDeclaredMethod("getCount", new Class<?>[]
+ {});
+ Object[] args = new Object[]
+ {};
+ // first check that the initial count is 1 (@PostConstruct calls increments it from 0 to 1)
+ ContainerInvocation invocation = new InVMContainerInvocationImpl(getCountMethod, args);
+ Object result = singletonContainer.invoke(invocation);
+
+ Assert.assertNotNull("Result was null", result);
+
+ int count = (Integer) result;
+ Assert.assertEquals("Incorrect count - @PostConstruct was not called", 1, count);
+
+ // now increment the count
+ Method method = SimpleSingletonBean.class.getDeclaredMethod("incrementCount", new Class<?>[]
+ {});
+
+ invocation = new InVMContainerInvocationImpl(method, args);
+ singletonContainer.invoke(invocation);
+
+ // and now again check the count (should now be 2)
+ invocation = new InVMContainerInvocationImpl(getCountMethod, args);
+ result = singletonContainer.invoke(invocation);
+
+ Assert.assertNotNull("Result was null", result);
+
+ count = (Integer) result;
+ Assert.assertEquals("Incorrect count after incrementing", 2, count);
+ }
+}
Copied: projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/aop/impl/test/container/singleton-interceptors-aop.xml (from rev 100805, projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/legacy/container/test/singleton-interceptors-aop.xml)
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/aop/impl/test/container/singleton-interceptors-aop.xml (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/test/resources/org/jboss/ejb3/singleton/aop/impl/test/container/singleton-interceptors-aop.xml 2010-02-10 14:00:46 UTC (rev 100807)
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop xmlns="urn:jboss:aop-beans:1.0">
+
+ <interceptor class="org.jboss.aspects.remoting.InvokeRemoteInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.security.client.SecurityClientInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.aspects.tx.ClientTxPropagationInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.remoting.IsLocalInterceptor" scope="PER_VM"/>
+
+ <!-- <interceptor class="org.jboss.aspects.tx.TxPropagationInterceptor" scope="PER_VM"/> -->
+
+
+
+ <interceptor class="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.ENCPropagationInterceptor" scope="PER_VM"/>
+ <interceptor name="Basic Authorization" factory="org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor name="JACC Authorization" factory="org.jboss.ejb3.security.JaccAuthorizationInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor factory="org.jboss.ejb3.security.AuthenticationInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor factory="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor class="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor" scope="PER_VM"/>
+ <!--
+ <interceptor factory="org.jboss.ejb3.tx.BMTTxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
+ <interceptor factory="org.jboss.ejb3.tx.CMTTxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
+ -->
+ <interceptor class="org.jboss.ejb3.AllowedOperationsInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.BlockContainerShutdownInterceptor" scope="PER_VM"/>
+ <interceptor factory="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor class="org.jboss.ejb3.interceptor.EJB3TCCLInterceptor" scope="PER_VM"/>
+
+ <aspect name="InjectInterceptorsFactory" factory="org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory" scope="PER_JOINPOINT"/>
+ <aspect name="InvocationContextInterceptor" class="org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor" scope="PER_VM"/>
+
+ <domain name="Intercepted Bean">
+ <pointcut name="beanAroundInvokeCallbackMethods" expr="execution(* @org.jboss.ejb3.interceptors.ManagedObject->@javax.interceptor.AroundInvoke(..))"/>
+ <pointcut name="beanPostConstructCallbackMethods" expr="execution(* @org.jboss.ejb3.interceptors.ManagedObject->@javax.interceptor.PostConstruct(..))"/>
+ <pointcut name="beanPreDestroyCallbackMethods" expr="execution(* @org.jboss.ejb3.interceptors.ManagedObject->@javax.interceptor.PreDestroy(..))"/>
+
+ <pointcut name="beanLifecycleCallbackMethods" expr="beanAroundInvokeCallbackMethods OR beanPostConstructCallbackMethods OR beanPreDestroyCallbackMethods"/>
+
+
+ <!-- Setup AOP interceptors based on spec interceptors -->
+ <bind pointcut="construction(@org.jboss.ejb3.interceptors.ManagedObject->new(..))">
+ <!-- interceptor-ref name="LoggingInterceptor"/ -->
+ <!-- TODO: we don't need invocation context here -->
+ <!-- TODO: we do until we've seperated the post constructs -->
+ <advice name="setup" aspect="InvocationContextInterceptor"/>
+ </bind>
+
+ <stack name="EJBInterceptors">
+ <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
+
+ <advice name="setup" aspect="InvocationContextInterceptor"/>
+ <advice name="fillMethod" aspect="InvocationContextInterceptor"/>
+ <advice name="aroundInvoke" aspect="InjectInterceptorsFactory"/>
+ </stack>
+
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3TCCLInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.BlockContainerShutdownInterceptor"/>
+ </bind>
+
+ <stack name="LifecycleCallbackStack">
+ <interceptor-ref name="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor"/>
+ <advice name="setup" aspect="InvocationContextInterceptor"/>
+ </stack>
+ </domain>
+
+
+
+ <domain name="Singleton Bean" extends="Intercepted Bean" inheritBindings="true">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.ejb3.annotation.SecurityDomain->*(..))">
+ <interceptor-ref name="Basic Authorization"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <!-- <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/> -->
+ <stack-ref name="EJBInterceptors"/>
+ </bind>
+ </domain>
+<!-- <domain name="Singleton Bean">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3TCCLInterceptor"/>
+ </bind>
+
+ </domain>
+ -->
+
+
+</aop>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list