[jboss-cvs] JBossAS SVN: r100797 - in projects/ejb3/components/singleton/trunk: impl/src/test/java/org/jboss/ejb3/singleton/impl/test/simple/unit and 21 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 10 06:42:45 EST 2010
Author: jaikiran
Date: 2010-02-10 06:42:43 -0500 (Wed, 10 Feb 2010)
New Revision: 100797
Added:
projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/InVMContainerInvocationImpl.java
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/AOPBasedSingletonContainerTestCase.java
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/SimpleSingletonBean.java
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockDeploymentUnit.java
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockEJB3Deployment.java
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/jndi.properties
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/ejb3/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/ejb3/singleton/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/ejb3/singleton/legacy/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/ejb3/singleton/legacy/container/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/ejb3/singleton/legacy/container/test/
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/ejb3/singleton/legacy/container/test/singleton-interceptors-aop.xml
Removed:
projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/ContainerInvocationContextImpl.java
Modified:
projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonBeanContext.java
projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonContainer.java
projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonEJBInstanceManagerImpl.java
projects/ejb3/components/singleton/trunk/impl/src/test/java/org/jboss/ejb3/singleton/impl/test/simple/unit/SimpleSingletonContainerTest.java
projects/ejb3/components/singleton/trunk/legacy-container-integration/pom.xml
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedContainerInvocationContext.java
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedInterceptorRegistry.java
projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedSingletonContainer.java
projects/ejb3/components/singleton/trunk/spi/src/main/java/org/jboss/ejb3/singleton/spi/SingletonEJBInstanceManager.java
Log:
EJBTHREE-2010 Initial impl of the singleton container
Deleted: projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/ContainerInvocationContextImpl.java
===================================================================
--- projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/ContainerInvocationContextImpl.java 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/ContainerInvocationContextImpl.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -1,68 +0,0 @@
-/*
-* 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.impl.container;
-
-import java.lang.reflect.Method;
-
-import org.jboss.ejb3.container.spi.ContainerInvocationContext;
-
-/**
- * ContainerInvocationContextImpl
- *
- * TODO: This needs to be in a better place like a common container impl
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class ContainerInvocationContextImpl implements ContainerInvocationContext
-{
-
- private Method method;
-
- private Object[] args;
-
- public ContainerInvocationContextImpl(Method method, Object[] args)
- {
- this.method = method;
- this.args = args;
- }
-
- /**
- * @see org.jboss.ejb3.container.spi.ContainerInvocationContext#getArgs()
- */
- @Override
- public Object[] getArgs()
- {
- return this.args;
- }
-
- /**
- * @see org.jboss.ejb3.container.spi.ContainerInvocationContext#getMethod()
- */
- @Override
- public Method getMethod()
- {
- return this.method;
- }
-
-
-}
Added: projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/InVMContainerInvocationImpl.java
===================================================================
--- projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/InVMContainerInvocationImpl.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/InVMContainerInvocationImpl.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -0,0 +1,104 @@
+/*
+* 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.impl.container;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+import org.jboss.ejb3.container.spi.ContainerInvocation;
+
+/**
+ * ContainerInvocationContextImpl
+ *
+ * TODO: This needs to be in a better place like a common container impl
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class InVMContainerInvocationImpl implements ContainerInvocation
+{
+
+ private Method method;
+
+ private Object[] args;
+
+ private Serializable sessionId;
+
+ private Class<?> businessInterface;
+
+ public InVMContainerInvocationImpl(Method method, Object[] args)
+ {
+ this.method = method;
+ this.args = args;
+ }
+
+ public InVMContainerInvocationImpl(Method method, Object[] args, Serializable sessionId, Class<?> businessInterface)
+ {
+ this(method,args,sessionId);
+ this.businessInterface = businessInterface;
+ }
+
+ public InVMContainerInvocationImpl(Method method, Object[] args, Serializable sessionId)
+ {
+ this.method = method;
+ this.args = args;
+ this.sessionId = sessionId;
+ }
+
+ /**
+ * @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.method;
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.ContainerInvocation#getSessionId()
+ */
+ @Override
+ public Serializable getSessionId()
+ {
+ return this.sessionId;
+ }
+
+ /**
+ * @see org.jboss.ejb3.container.spi.ContainerInvocation#getInvokedBusinessInterface()
+ */
+ @Override
+ public Class<?> getInvokedBusinessInterface()
+ {
+ return this.businessInterface;
+ }
+
+
+}
Modified: projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonBeanContext.java
===================================================================
--- projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonBeanContext.java 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonBeanContext.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -21,6 +21,8 @@
*/
package org.jboss.ejb3.singleton.impl.container;
+import java.io.Serializable;
+
import org.jboss.ejb3.container.spi.BeanContext;
import org.jboss.ejb3.container.spi.EJBContainer;
@@ -74,4 +76,14 @@
return this.beanContainer;
}
+ /**
+ * @see org.jboss.ejb3.container.spi.BeanContext#getSessionId()
+ */
+ @Override
+ public Serializable getSessionId()
+ {
+ // singleton bean context is not session specific
+ return null;
+ }
+
}
Modified: projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonContainer.java
===================================================================
--- projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonContainer.java 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonContainer.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -21,10 +21,8 @@
*/
package org.jboss.ejb3.singleton.impl.container;
-import java.lang.reflect.Method;
-
import org.jboss.ejb3.container.spi.BeanContext;
-import org.jboss.ejb3.container.spi.ContainerInvocationContext;
+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;
@@ -51,7 +49,7 @@
* Logger
*/
private static Logger logger = Logger.getLogger(SingletonContainer.class);
-
+
/**
* Bean implementation class
*/
@@ -74,16 +72,21 @@
/**
* Creates a {@link SingletonContainer} for the EJB class <code>beanClass</code>
- * and the associated session bean metadata <code>sessionBeanMetaData</code>
- *
- * @param beanClass The EJB implementation class
+ * and the associated session bean metadata <code>sessionBeanMetaData</code>. The
+ * <code>interceptorRegistry</code> will be used for intercepting the calls on the
+ * target bean instance
+ *
+ * @param beanClass The EJB implementation class
* @param sessionBeanMetaData The session bean metadata
- * @throws IllegalArgumentException If either <code>beanClass</code> or <code>sessionBeanMetaData</code>
- * is null.
+ * @param interceptorRegistry The interceptor registry which will be used to intercept
+ * the calls to the target bean instance during the invocation on the container
+ * ({@link #invoke(ContainerInvocation)})
+ * @throws IllegalArgumentException If any of the passed parameters is null.
* @throws IllegalStateException If the <code>sesssionBeanMetadata</code> does not represent a singleton
- * bean - which is checked by a call to {@link JBossSessionBean31MetaData#isSingleton()}
+ * bean - which is checked by a call to {@link JBossSessionBean31MetaData#isSingleton()}
*/
- public SingletonContainer(Class<?> beanClass, JBossSessionBean31MetaData sessionBeanMetaData)
+ public SingletonContainer(Class<?> beanClass, JBossSessionBean31MetaData sessionBeanMetaData,
+ InterceptorRegistry interceptorRegistry)
{
if (beanClass == null || sessionBeanMetaData == null)
{
@@ -97,44 +100,61 @@
throw new IllegalStateException("Bean named " + sessionBeanMetaData.getEjbName() + " with class "
+ sessionBeanMetaData.getEjbClass() + " is NOT a singleton bean");
}
+ if (interceptorRegistry == null)
+ {
+ throw new IllegalArgumentException(SingletonContainer.class.getSimpleName()
+ + " cannot be constructed out of a null interceptor registry");
+ }
this.beanClass = beanClass;
this.sessionBeanMetaData = sessionBeanMetaData;
// create instance manager
- this.instanceManager = new SingletonEJBInstanceManagerImpl(beanClass, this);
- // create an empty interceptor registry
- this.interceptorRegistry = new EmptyInterceptorRegistry();
+ this.instanceManager = new SingletonEJBInstanceManagerImpl(beanClass, this, this);
+ // set the interceptor registry
+ this.interceptorRegistry = interceptorRegistry;
+
+
}
+
+ /**
+ * TODO: Think whether this needs to be made available in
+ * a lifecycle aware {@link EJBContainer}
+ */
+ public void create()
+ {
+
+ }
/**
- * Creates a {@link SingletonContainer} for the EJB class <code>beanClass</code>
- * and the associated session bean metadata <code>sessionBeanMetaData</code>. The
- * <code>interceptorRegistry</code> will be used for intercepting the calls on the
- * target bean instance
- *
- * @param beanClass The EJB implementation class
- * @param sessionBeanMetaData The session bean metadata
- * @param interceptorRegistry The interceptor registry which will be used to intercept
- * the calls to the target bean instance during the invocation on the container
- * ({@link #invoke(ContainerInvocationContext)})
- * @throws IllegalArgumentException If any of the passed parameters is null.
- * @throws IllegalStateException If the <code>sesssionBeanMetadata</code> does not represent a singleton
- * bean - which is checked by a call to {@link JBossSessionBean31MetaData#isSingleton()}
+ * TODO: Think whether this needs to be made available in
+ * a lifecycle aware {@link EJBContainer}
*/
- public SingletonContainer(Class<?> beanClass, JBossSessionBean31MetaData sessionBeanMetaData,
- InterceptorRegistry interceptorRegistry)
+ public void start()
{
- this(beanClass, sessionBeanMetaData);
- if (interceptorRegistry == null)
- {
- throw new IllegalArgumentException(SingletonContainer.class.getSimpleName()
- + " cannot be constructed out of a null interceptor registry");
- }
- this.interceptorRegistry = interceptorRegistry;
+ // TODO: If @Startup, then create a singleton bean context here
+
}
+
+ /**
+ * TODO: Think whether this needs to be made available in
+ * a lifecycle aware {@link EJBContainer}
+ */
+ public void stop()
+ {
+
+ }
/**
+ * TODO: Think whether this needs to be made available in
+ * a lifecycle aware {@link EJBContainer}
+ */
+ public void destroy()
+ {
+ this.instanceManager.destroy();
+ }
+
+ /**
* @see org.jboss.ejb3.container.spi.EJBContainer#getBeanInstanceManager()
*/
@Override
@@ -181,10 +201,10 @@
}
/**
- * @see org.jboss.ejb3.container.spi.EJBContainer#invoke(org.jboss.ejb3.container.spi.ContainerInvocationContext)
+ * @see org.jboss.ejb3.container.spi.EJBContainer#invoke(org.jboss.ejb3.container.spi.ContainerInvocation)
*/
@Override
- public Object invoke(ContainerInvocationContext containerInvocation) throws Exception
+ public Object invoke(ContainerInvocation containerInvocation) throws Exception
{
BeanContext beanContext = this.instanceManager.get();
@@ -205,75 +225,27 @@
}
/**
- * @see org.jboss.ejb3.container.spi.EJBContainer#getEJBLifecycleHandler()
- */
- @Override
- public EJBLifecycleHandler getEJBLifecycleHandler()
- {
- return this;
- }
-
- /**
* @see org.jboss.ejb3.container.spi.lifecycle.EJBLifecycleHandler#postConstruct(org.jboss.ejb3.container.spi.BeanContext)
*/
@Override
- public void postConstruct(BeanContext beanContext)
+ public void postConstruct(BeanContext beanContext) throws Exception
{
- // TODO: Implement this
- logger.warn("postConstruct() not yet implemented in " + this.getClass());
+ // pass the bean context to the interceptor registry to do its job.
+ // we don't have anything specific/additional to do here.
+ this.interceptorRegistry.invokePostConstruct(beanContext);
+
}
/**
* @see org.jboss.ejb3.container.spi.lifecycle.EJBLifecycleHandler#preDestroy(org.jboss.ejb3.container.spi.BeanContext)
*/
@Override
- public void preDestroy(BeanContext beanContext)
+ public void preDestroy(BeanContext beanContext) throws Exception
{
- // TODO: Implement this
- logger.warn("preDestroy() not yet implemented in " + this.getClass());
+ // pass the bean context to the interceptor registry to do its job.
+ // we don't have anything specific/additional to do here.
+ this.interceptorRegistry.invokePreDestroy(beanContext);
}
- /**
- *
- * EmptyInterceptorRegistry
- *
- * <p>
- * An implementation of the {@link InterceptorRegistry}. This does NOT apply any interceptors
- * to the invocation on the target object during the {@link #intercept(ContainerInvocationContext, Object)}
- * call. Instead, it directly invokes the method on the target object
- * </p>
- * TODO: This {@link EmptyInterceptorRegistry} probably needs to be in a more better place to be used
- * commonly by other containers. Probably this class needs to be an API.
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
- private class EmptyInterceptorRegistry implements InterceptorRegistry
- {
-
- /**
- * @see org.jboss.ejb3.container.spi.InterceptorRegistry#getEJBContainer()
- */
- @Override
- public EJBContainer getEJBContainer()
- {
- return SingletonContainer.this;
- }
-
- /**
- * @see org.jboss.ejb3.container.spi.InterceptorRegistry#intercept(ContainerInvocationContext, BeanContext)
- */
- @Override
- public Object intercept(ContainerInvocationContext containerInvocation, BeanContext targetBeanContext) throws Exception
- {
- // just directly invoke on the target object
- Method methodToBeInvoked = containerInvocation.getMethod();
- Object args[] = containerInvocation.getArgs();
-
- // invoke
- return methodToBeInvoked.invoke(targetBeanContext.getBeanInstance(), args);
- }
-
- }
-
+
}
Modified: projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonEJBInstanceManagerImpl.java
===================================================================
--- projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonEJBInstanceManagerImpl.java 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonEJBInstanceManagerImpl.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -21,8 +21,11 @@
*/
package org.jboss.ejb3.singleton.impl.container;
+import java.io.Serializable;
+
import org.jboss.ejb3.container.spi.BeanContext;
import org.jboss.ejb3.container.spi.EJBContainer;
+import org.jboss.ejb3.container.spi.EJBInstanceManager;
import org.jboss.ejb3.container.spi.lifecycle.EJBLifecycleHandler;
import org.jboss.ejb3.singleton.spi.SingletonEJBInstanceManager;
@@ -46,6 +49,13 @@
private EJBContainer container;
/**
+ * An {@link EJBLifecycleHandler} responsible for handling the
+ * lifecyle of the bean instances created/destroyed by this
+ * {@link EJBInstanceManager}
+ */
+ private EJBLifecycleHandler beanInstanceLifecycleHandler;
+
+ /**
* The singleton bean context
*/
private BeanContext singletonBeanContext;
@@ -57,17 +67,19 @@
* @param beanClass The bean implementation class
* @param container The container managing the bean
*/
- public SingletonEJBInstanceManagerImpl(Class<?> beanClass, EJBContainer container)
+ public SingletonEJBInstanceManagerImpl(Class<?> beanClass, EJBContainer container,
+ EJBLifecycleHandler lifecycleHandler)
{
this.beanClass = beanClass;
this.container = container;
+ this.beanInstanceLifecycleHandler = lifecycleHandler;
}
/**
* @see org.jboss.ejb3.container.spi.EJBInstanceManager#create()
*/
@Override
- public BeanContext create()
+ public Serializable create()
{
if (this.singletonBeanContext == null)
{
@@ -81,19 +93,25 @@
newInstanceCreated = true;
}
}
- if (newInstanceCreated)
+ if (newInstanceCreated && this.beanInstanceLifecycleHandler != null)
{
// do post-construct
- EJBLifecycleHandler beanLifecycleHandler = this.getEJBContainer().getEJBLifecycleHandler();
- beanLifecycleHandler.postConstruct(this.singletonBeanContext);
+ try
+ {
+ this.beanInstanceLifecycleHandler.postConstruct(this.singletonBeanContext);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not invoke PostConstruct on the newly created bean instance", e);
+ }
}
}
-
- return this.singletonBeanContext;
+ return this.singletonBeanContext.getSessionId();
}
/**
- * @see org.jboss.ejb3.container.spi.EJBInstanceManager#get()
+ *
+ * @see org.jboss.ejb3.singleton.spi.SingletonEJBInstanceManager#get()
*/
@Override
public BeanContext get()
@@ -105,6 +123,33 @@
return this.singletonBeanContext;
}
+
+ /**
+ * @see org.jboss.ejb3.singleton.spi.SingletonEJBInstanceManager#destroy()
+ */
+ @Override
+ public void destroy()
+ {
+ synchronized(this)
+ {
+ if (this.singletonBeanContext == null)
+ {
+ return; // Or should we throw IllegalStateException?
+ }
+ }
+ try
+ {
+ this.beanInstanceLifecycleHandler.preDestroy(this.singletonBeanContext);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not preDestroy the singleton bean instance", e);
+ }
+ synchronized (this)
+ {
+ this.singletonBeanContext = null;
+ }
+ }
/**
* @see org.jboss.ejb3.container.spi.StatefulEJBInstanceManager#getEJBContainer()
@@ -116,16 +161,25 @@
}
/**
- * @see org.jboss.ejb3.container.spi.EJBInstanceManager#destroy(org.jboss.ejb3.container.spi.BeanContext)
+ * @see org.jboss.ejb3.container.spi.EJBInstanceManager#destroy(Serializable)
*/
@Override
- public void destroy(BeanContext beanContext) throws IllegalArgumentException
+ public void destroy(Serializable sessionId) throws IllegalArgumentException, IllegalStateException
{
- // TODO Auto-generated method stub
+ throw new IllegalStateException("destroy(sessionId) cannot be called on a singleton bean's instance manager");
}
/**
+ * @see org.jboss.ejb3.container.spi.EJBInstanceManager#isSessionAware()
+ */
+ @Override
+ public boolean isSessionAware()
+ {
+ return false;
+ }
+
+ /**
* Creates an instance of the bean class
*
* @return Returns the bean instance
Modified: projects/ejb3/components/singleton/trunk/impl/src/test/java/org/jboss/ejb3/singleton/impl/test/simple/unit/SimpleSingletonContainerTest.java
===================================================================
--- projects/ejb3/components/singleton/trunk/impl/src/test/java/org/jboss/ejb3/singleton/impl/test/simple/unit/SimpleSingletonContainerTest.java 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/impl/src/test/java/org/jboss/ejb3/singleton/impl/test/simple/unit/SimpleSingletonContainerTest.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -27,7 +27,11 @@
import java.lang.reflect.Method;
-import org.jboss.ejb3.container.spi.ContainerInvocationContext;
+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;
+import org.jboss.ejb3.singleton.impl.container.InVMContainerInvocationImpl;
import org.jboss.ejb3.singleton.impl.container.SingletonContainer;
import org.jboss.ejb3.singleton.impl.test.simple.SimpleSingletonBean;
import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
@@ -62,7 +66,8 @@
singletonBeanMetadata.setSessionType(SessionType.Singleton);
// create a singleton container
- this.singletonContainer = new SingletonContainer(SimpleSingletonBean.class, singletonBeanMetadata);
+ this.singletonContainer = new SingletonContainer(SimpleSingletonBean.class, singletonBeanMetadata,
+ new EmptyInterceptorRegistry());
}
/**
@@ -80,7 +85,7 @@
final Object params[] = new Object[]
{message};
- ContainerInvocationContext containerInvocation = new DummyContainerInvocation(echoMethod, params);
+ ContainerInvocation containerInvocation = new InVMContainerInvocationImpl(echoMethod, params);
Object result = this.singletonContainer.invoke(containerInvocation);
@@ -106,7 +111,7 @@
final Object params[] = new Object[]
{};
- ContainerInvocationContext containerInvocation = new DummyContainerInvocation(getMeMethod, params);
+ ContainerInvocation containerInvocation = new InVMContainerInvocationImpl(getMeMethod, params);
Object result = this.singletonContainer.invoke(containerInvocation);
assertNotNull("Result returned by singleton container was null", result);
@@ -117,7 +122,7 @@
// more invocations on the bean and check that the same instance is returned
for (int i = 0; i < 5; i++)
{
- containerInvocation = new DummyContainerInvocation(getMeMethod, params);
+ containerInvocation = new InVMContainerInvocationImpl(getMeMethod, params);
result = this.singletonContainer.invoke(containerInvocation);
assertNotNull("Result returned by singleton container was null", result);
@@ -145,7 +150,7 @@
final Method incrementCountMethod = SimpleSingletonBean.class.getMethod("incrementCount", new Class<?>[]
{});
- ContainerInvocationContext containerInvocation = new DummyContainerInvocation(getCountMethod, params);
+ ContainerInvocation containerInvocation = new InVMContainerInvocationImpl(getCountMethod, params);
Object result = this.singletonContainer.invoke(containerInvocation);
assertNotNull("Result returned by singleton container was null", result);
@@ -157,10 +162,10 @@
for (int i = 1; i < 10; i++)
{
// first increment
- containerInvocation = new DummyContainerInvocation(incrementCountMethod, params);
+ containerInvocation = new InVMContainerInvocationImpl(incrementCountMethod, params);
this.singletonContainer.invoke(containerInvocation);
// get the count
- containerInvocation = new DummyContainerInvocation(getCountMethod, params);
+ containerInvocation = new InVMContainerInvocationImpl(getCountMethod, params);
result = this.singletonContainer.invoke(containerInvocation);
assertNotNull("Result returned by singleton container was null", result);
@@ -172,54 +177,70 @@
}
}
- /**
- *
- * DummyContainerInvocation
- *
- * A dummy {@link ContainerInvocationContext} used in tests
- * @author Jaikiran Pai
- * @version $Revision: $
- */
- private class DummyContainerInvocation implements ContainerInvocationContext
+ private class EmptyInterceptorRegistry implements InterceptorRegistry
{
- private Method method;
+ /** (non-Javadoc)
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#getEJBContainer()
+ */
+ @Override
+ public EJBContainer getEJBContainer()
+ {
+ return SimpleSingletonContainerTest.this.singletonContainer;
+ }
- private Object[] args;
+ /**
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#intercept(org.jboss.ejb3.container.spi.ContainerInvocation, org.jboss.ejb3.container.spi.BeanContext)
+ */
+ @Override
+ public Object intercept(ContainerInvocation containerInvocation, BeanContext targetBeanContext) throws Exception
+ {
+ Object target = targetBeanContext.getBeanInstance();
+ Method methodToInvoke = containerInvocation.getMethod();
+ Object[] params = containerInvocation.getArgs();
+ return methodToInvoke.invoke(target, params);
- private boolean stateful;
+ }
- public DummyContainerInvocation(Method method, Object[] args)
+ /**
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#invokePostActivate(org.jboss.ejb3.container.spi.BeanContext)
+ */
+ @Override
+ public void invokePostActivate(BeanContext targetBeanContext) throws Exception
{
- this.method = method;
- this.args = args;
+ // TODO Auto-generated method stub
+
}
- public DummyContainerInvocation(Method method, Object[] args, boolean isStateful)
+ /**
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#invokePostConstruct(org.jboss.ejb3.container.spi.BeanContext)
+ */
+ @Override
+ public void invokePostConstruct(BeanContext targetBeanContext) throws Exception
{
- this(method, args);
- this.stateful = isStateful;
+ // TODO Auto-generated method stub
+
}
/**
- * @see org.jboss.ejb3.container.spi.ContainerInvocationContext#getArgs()
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#invokePreDestroy(org.jboss.ejb3.container.spi.BeanContext)
*/
@Override
- public Object[] getArgs()
+ public void invokePreDestroy(BeanContext targetBeanContext) throws Exception
{
+ // TODO Auto-generated method stub
- return this.args;
}
/**
- * @see org.jboss.ejb3.container.spi.ContainerInvocationContext#getMethod()
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#invokePrePassivate(org.jboss.ejb3.container.spi.BeanContext)
*/
@Override
- public Method getMethod()
+ public void invokePrePassivate(BeanContext targetBeanContext) throws Exception
{
- return this.method;
+ // TODO Auto-generated method stub
+
}
-
}
}
Modified: projects/ejb3/components/singleton/trunk/legacy-container-integration/pom.xml
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/pom.xml 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/pom.xml 2010-02-10 11:42:43 UTC (rev 100797)
@@ -27,7 +27,7 @@
<properties>
<version.ejb3.singleton.impl>${project.version}</version.ejb3.singleton.impl>
- <version.ejb3.core>1.2.0</version.ejb3.core>
+ <version.ejb3.core>1.2.0</version.ejb3.core>
</properties>
<dependencies>
@@ -52,6 +52,69 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+
+ <!-- Get rid of this! it's required for ServiceMBeanSupport class
+ which is being extended by EJB3Deployment -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-system-jmx</artifactId>
+ <version>5.1.0.GA</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- this needs to be removed - EJBTHREE-1343 -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <version>5.1.0.GA</version>
+ <exclusions>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ </exclusion>
+ <!-- jboss-as-server must not dictate the JPA API -->
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>ejb3-persistence</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>test</scope>
+ </dependency>
</dependencies>
Modified: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedContainerInvocationContext.java
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedContainerInvocationContext.java 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedContainerInvocationContext.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -21,12 +21,13 @@
*/
package org.jboss.ejb3.singleton.legacy.container.integration;
+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.ContainerInvocationContext;
+import org.jboss.ejb3.container.spi.ContainerInvocation;
/**
* AOPBasedContainerInvocationContext
@@ -34,7 +35,7 @@
* @author Jaikiran Pai
* @version $Revision: $
*/
-public class AOPBasedContainerInvocationContext implements ContainerInvocationContext
+public class AOPBasedContainerInvocationContext implements ContainerInvocation
{
private Method unadvisedMethod;
@@ -42,6 +43,8 @@
private Object[] args;
private MethodInfo aopMethodInfo;
+
+ private Class<?> businessInterface;
private Map<Object, Object> responseContextInfo = new HashMap<Object, Object>();
@@ -58,9 +61,19 @@
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.ContainerInvocationContext#getArgs()
+ * @see org.jboss.ejb3.container.spi.ContainerInvocation#getArgs()
*/
@Override
public Object[] getArgs()
@@ -69,7 +82,7 @@
}
/**
- * @see org.jboss.ejb3.container.spi.ContainerInvocationContext#getMethod()
+ * @see org.jboss.ejb3.container.spi.ContainerInvocation#getMethod()
*/
@Override
public Method getMethod()
@@ -92,4 +105,24 @@
{
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;
+ }
}
Modified: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedInterceptorRegistry.java
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedInterceptorRegistry.java 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedInterceptorRegistry.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -24,7 +24,7 @@
import org.jboss.aop.MethodInfo;
import org.jboss.ejb3.EJBContainerInvocation;
import org.jboss.ejb3.container.spi.BeanContext;
-import org.jboss.ejb3.container.spi.ContainerInvocationContext;
+import org.jboss.ejb3.container.spi.ContainerInvocation;
import org.jboss.ejb3.container.spi.EJBContainer;
import org.jboss.ejb3.container.spi.InterceptorRegistry;
@@ -37,8 +37,17 @@
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;
@@ -50,14 +59,14 @@
@Override
public EJBContainer getEJBContainer()
{
- return this.aopBasedSingletonContainer.getSingletonContainer();
+ return this.aopBasedSingletonContainer;
}
/**
- * @see org.jboss.ejb3.container.spi.InterceptorRegistry#intercept(ContainerInvocationContext, BeanContext)
+ * @see org.jboss.ejb3.container.spi.InterceptorRegistry#intercept(ContainerInvocation, BeanContext)
*/
@Override
- public Object intercept(ContainerInvocationContext containerInvocation, BeanContext targetBeanContext) throws Exception
+ public Object intercept(ContainerInvocation containerInvocation, BeanContext targetBeanContext) throws Exception
{
// we handle only AOP based invocation
if (!(containerInvocation instanceof AOPBasedContainerInvocationContext))
@@ -74,9 +83,10 @@
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 = this.aopBasedSingletonContainer.getSingletonBeanContext();
+ org.jboss.ejb3.BeanContext<?> singletonBeanContext = new LegacySingletonBeanContext(
+ this.aopBasedSingletonContainer, targetBeanContext);
invocation.setBeanContext(singletonBeanContext);
-
+
try
{
return invocation.invokeNext();
@@ -87,4 +97,50 @@
}
}
+ /**
+ * @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
+
+ }
+
}
Modified: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedSingletonContainer.java
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedSingletonContainer.java 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/src/main/java/org/jboss/ejb3/singleton/legacy/container/integration/AOPBasedSingletonContainer.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -22,8 +22,6 @@
package org.jboss.ejb3.singleton.legacy.container.integration;
import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Hashtable;
import java.util.Map;
@@ -41,8 +39,9 @@
import org.jboss.ejb3.BeanContext;
import org.jboss.ejb3.Ejb3Deployment;
import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.container.spi.ContainerInvocationContext;
+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;
@@ -66,7 +65,7 @@
* @author Jaikiran Pai
* @version $Revision: $
*/
-public class AOPBasedSingletonContainer extends SessionSpecContainer implements InjectionContainer
+public class AOPBasedSingletonContainer extends SessionSpecContainer implements InjectionContainer, EJBContainer
{
/**
@@ -81,11 +80,6 @@
private SingletonContainer simpleSingletonContainer;
/**
- * (Legacy) Bean context
- */
- private BeanContext<?> beanContext;
-
- /**
* @param cl
* @param beanClassName
* @param ejbName
@@ -107,11 +101,17 @@
this.simpleSingletonContainer = new SingletonContainer(this.getBeanClass(), beanMetaData, interceptorRegistry);
}
- public SingletonContainer getSingletonContainer()
+
+ /**
+ * @see org.jboss.ejb3.EJBContainer#create()
+ */
+ @Override
+ public void create() throws Exception
{
- return this.simpleSingletonContainer;
+ super.create();
+ this.simpleSingletonContainer.create();
}
-
+
/**
* @see org.jboss.ejb3.session.SessionSpecContainer#lockedStart()
*/
@@ -120,10 +120,32 @@
{
super.lockedStart();
- // create singleton bean context
+ // 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
@@ -217,7 +239,7 @@
}
SerializableMethod serializableMethod = new SerializableMethod(method, invokedBusinessInterface);
// create a container invocation
- ContainerInvocationContext containerInvocation = new AOPBasedContainerInvocationContext(methodInfo, args);
+ ContainerInvocation containerInvocation = new AOPBasedContainerInvocationContext(methodInfo, args);
try
{
@@ -234,24 +256,25 @@
}
- /* (non-Javadoc)
+ /**
+ * 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()
{
- // TODO Auto-generated method stub
return null;
}
- /* (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 UnsupportedOperationException("NYI");
}
/* (non-Javadoc)
@@ -260,8 +283,7 @@
@Override
public Object localInvoke(Object id, Method method, Object[] args) throws Throwable
{
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("NYI");
}
/* (non-Javadoc)
@@ -270,7 +292,7 @@
@Override
protected void removeHandle(Handle handle) throws Exception
{
- // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("NYI");
}
@@ -280,9 +302,7 @@
@Override
public BeanContext<?> createBeanContext()
{
- EJBInstanceManager instanceManager = this.simpleSingletonContainer.getBeanInstanceManager();
- org.jboss.ejb3.container.spi.BeanContext context = instanceManager.create();
- return new LegacySingletonBeanContext(this, context);
+ throw new UnsupportedOperationException("createBeanContext() is no longer supported");
}
/**
@@ -291,8 +311,7 @@
@Override
public Object getMBean()
{
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("NYI");
}
/**
@@ -301,8 +320,7 @@
@Override
public TimerService getTimerService()
{
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("NYI");
}
/**
@@ -311,66 +329,69 @@
@Override
public TimerService getTimerService(Object key)
{
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("NYI");
}
- /* (non-Javadoc)
- * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.Class)
+ /**
+ * @see EJBContainer#getEJBName()
*/
@Override
- public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz)
+ public String getEJBName()
{
- // TODO Auto-generated method stub
- return null;
+ return this.ejbName;
}
- /* (non-Javadoc)
- * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.Class, java.lang.reflect.Method)
+ /**
+ * @see EJBContainer#getEJBClass()
*/
@Override
- public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Method method)
+ public String getEJBClass()
{
- // TODO Auto-generated method stub
- return null;
+ return this.beanClassName;
}
- /* (non-Javadoc)
- * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.Class, java.lang.reflect.Field)
+ /**
+ * @see EJBContainer#getBeanInstanceManager()
*/
@Override
- public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Field field)
+ public EJBInstanceManager getBeanInstanceManager()
{
- // TODO Auto-generated method stub
- return null;
+ return this.simpleSingletonContainer.getBeanInstanceManager();
}
- public BeanContext<?> getSingletonBeanContext()
+ /**
+ * @see EJBContainer#getDeploymentInfo()
+ */
+ @Override
+ public EJBDeploymentInfo getDeploymentInfo()
{
- return this.beanContext;
+ return this.simpleSingletonContainer.getDeploymentInfo();
}
- protected void initBeanContext() throws RuntimeException
+ /**
+ * @see EJBContainer#invoke(ContainerInvocation)
+ */
+ @Override
+ public Object invoke(ContainerInvocation containerInvocation) throws Exception
{
- if (beanContext == null)
+ try
{
- synchronized (this)
- {
- if (beanContext == null)
- {
- beanContext = createBeanContext();
- pushEnc();
- try
- {
- beanContext.initialiseInterceptorInstances();
- }
- finally
- {
- popEnc();
- }
- }
- }
+ 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();
+ }
+
}
Added: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/AOPBasedSingletonContainerTestCase.java
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/AOPBasedSingletonContainerTestCase.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/AOPBasedSingletonContainerTestCase.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -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.legacy.container.test;
+
+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.impl.container.InVMContainerInvocationImpl;
+import org.jboss.ejb3.singleton.legacy.container.integration.AOPBasedSingletonContainer;
+import org.jboss.ejb3.singleton.legacy.container.test.common.MockEJB3Deployment;
+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/legacy/container/test/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);
+ }
+}
Added: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/SimpleSingletonBean.java
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/SimpleSingletonBean.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/SimpleSingletonBean.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -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.legacy.container.test;
+
+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++;
+ }
+}
Added: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockDeploymentUnit.java
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockDeploymentUnit.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockDeploymentUnit.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -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.legacy.container.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;
+ }
+
+
+}
Added: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockEJB3Deployment.java
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockEJB3Deployment.java (rev 0)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/java/org/jboss/ejb3/singleton/legacy/container/test/common/MockEJB3Deployment.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -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.legacy.container.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");
+ }
+
+}
Added: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/jndi.properties
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/jndi.properties (rev 0)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/jndi.properties 2010-02-10 11:42:43 UTC (rev 100797)
@@ -0,0 +1,2 @@
+java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Property changes on: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/jndi.properties
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/ejb3/singleton/legacy/container/test/singleton-interceptors-aop.xml
===================================================================
--- projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/ejb3/singleton/legacy/container/test/singleton-interceptors-aop.xml (rev 0)
+++ projects/ejb3/components/singleton/trunk/legacy-container-integration/src/test/resources/org/jboss/ejb3/singleton/legacy/container/test/singleton-interceptors-aop.xml 2010-02-10 11:42:43 UTC (rev 100797)
@@ -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
Modified: projects/ejb3/components/singleton/trunk/spi/src/main/java/org/jboss/ejb3/singleton/spi/SingletonEJBInstanceManager.java
===================================================================
--- projects/ejb3/components/singleton/trunk/spi/src/main/java/org/jboss/ejb3/singleton/spi/SingletonEJBInstanceManager.java 2010-02-10 11:38:18 UTC (rev 100796)
+++ projects/ejb3/components/singleton/trunk/spi/src/main/java/org/jboss/ejb3/singleton/spi/SingletonEJBInstanceManager.java 2010-02-10 11:42:43 UTC (rev 100797)
@@ -38,8 +38,13 @@
{
/**
- * @return Returns the {@link BeanContext} for the singleton bean.
+ * @return Returns the {@link BeanContext} of the singleton bean.
*
*/
BeanContext get();
+
+ /**
+ * Destroy the {@link BeanContext} of the singleton bean
+ */
+ void destroy();
}
More information about the jboss-cvs-commits
mailing list