[jboss-cvs] JBossAS SVN: r64888 - in trunk/ejb3: src/main/org/jboss/ejb3/session and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 27 09:39:41 EDT 2007
Author: wolfc
Date: 2007-08-27 09:39:40 -0400 (Mon, 27 Aug 2007)
New Revision: 64888
Added:
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/Mock.java
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockDeploymentUnit.java
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockEjb3Deployment.java
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockStatefulContainer.java
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MyStatefulSessionFilePersistenceManager.java
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java
Modified:
trunk/ejb3/
trunk/ejb3/build-test.xml
trunk/ejb3/src/main/org/jboss/ejb3/session/SessionContextImpl.java
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulSessionContextImpl.java
Log:
EJBTHREE-1016: Fixed SFSB passivation/activation
Property changes on: trunk/ejb3
___________________________________________________________________
Name: svn:ignore
- output
build.log
.settings
run.tstamp
junit191723717.properties
junit*.properties
+ output
build.log
.settings
run.tstamp
junit191723717.properties
junit*.properties
temp
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2007-08-27 11:17:45 UTC (rev 64887)
+++ trunk/ejb3/build-test.xml 2007-08-27 13:39:40 UTC (rev 64888)
@@ -285,6 +285,15 @@
<path refid="apache.httpclient.classpath"/>
</path>
+ <path id="full.classpath">
+ <path refid="client.classpath"/>
+ <!-- This test accesses some ejb3 classes directly -->
+ <path refid="jboss.ejb3.classpath"/>
+ <path refid="jboss.main.classpath"/>
+ <path refid="jboss.systemjmx.classpath"/>
+ <path refid="library.classpath"/>
+ </path>
+
<path id="iiop.client.classpath">
<pathelement path="${resources}/test/iiop"/>
<path refid="client.classpath"/>
@@ -986,6 +995,9 @@
</target>
+ <target name="cachepassivation" depends="compile-classes">
+ </target>
+
<target name="clientinterceptor"
description="Builds all jar files."
depends="compile-classes">
@@ -3643,8 +3655,11 @@
<condition property="client.run.classpath" value="iiop.client.classpath">
<equals arg1="${test}" arg2="iiop"/>
</condition>
- <condition property="client.run.classpath" value="dd.classpath">
- <equals arg1="${test}" arg2="threadlocal"/>
+ <condition property="client.run.classpath" value="full.classpath">
+ <or>
+ <equals arg1="${test}" arg2="cachepassivation"/>
+ <equals arg1="${test}" arg2="threadlocal"/>
+ </or>
</condition>
<condition property="client.run.classpath" value="client.classpath">
<not>
@@ -4217,6 +4232,9 @@
<target name="simple-tests" depends="init">
<antcall target="test" inheritRefs="true">
+ <param name="test" value="cachepassivation"/>
+ </antcall>
+ <antcall target="test" inheritRefs="true">
<param name="test" value="threadlocal"/>
</antcall>
</target>
@@ -4687,7 +4705,7 @@
We are using the simplest remoting sslsocket configuration possible, we
need to tell JBoss to use the supplied keystore via system properties
-->
- <property name="ssl-args" value="-Xmx128M -Djavax.net.ssl.keyStore=${jboss.dist}/server/ejb3-ssl/conf/localhost.keystore -Djavax.net.ssl.keyStorePassword=opensource"/>
+ <property name="ssl-args" value="-Xmx256M -Djavax.net.ssl.keyStore=${jboss.dist}/server/ejb3-ssl/conf/localhost.keystore -Djavax.net.ssl.keyStorePassword=opensource"/>
<start-jboss conf="ejb3-ssl" host="${node0}" jvmargs="${ssl-args}"/>
<wait-on-host/>
Modified: trunk/ejb3/src/main/org/jboss/ejb3/session/SessionContextImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/session/SessionContextImpl.java 2007-08-27 11:17:45 UTC (rev 64887)
+++ trunk/ejb3/src/main/org/jboss/ejb3/session/SessionContextImpl.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -21,54 +21,15 @@
*/
package org.jboss.ejb3.session;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.security.Identity;
-import java.security.Principal;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-
-import javax.ejb.EJBException;
-import javax.ejb.EJBHome;
-import javax.ejb.EJBLocalHome;
import javax.ejb.EJBLocalObject;
import javax.ejb.EJBObject;
-import javax.ejb.MessageDrivenContext;
import javax.ejb.SessionContext;
-import javax.ejb.TimerService;
-import javax.ejb.TransactionManagementType;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
import javax.xml.rpc.handler.MessageContext;
-import org.jboss.annotation.security.RunAsPrincipal;
-import org.jboss.annotation.security.SecurityDomain;
-import org.jboss.aop.Advisor;
-import org.jboss.ejb3.BaseContext;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.EJBContainer;
import org.jboss.ejb3.EJBContextImpl;
-import org.jboss.ejb3.Ejb3Registry;
-import org.jboss.ejb3.SecurityActions;
-import org.jboss.ejb3.security.SecurityDomainManager;
import org.jboss.ejb3.stateless.StatelessBeanContext;
-import org.jboss.ejb3.tx.TxUtil;
-import org.jboss.ejb3.tx.UserTransactionImpl;
import org.jboss.logging.Logger;
-import org.jboss.security.RealmMapping;
-import org.jboss.security.RunAsIdentity;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.SimplePrincipal;
-
/**
* Comment
*
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java 2007-08-27 11:17:45 UTC (rev 64887)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -62,8 +62,8 @@
{
/** The serialVersionUID */
private static final long serialVersionUID = -102470788178912606L;
-
- private static class Serialized implements Serializable
+
+ protected static class Serialized implements Serializable
{
private static final long serialVersionUID = 1L;
@@ -75,6 +75,8 @@
private boolean removed;
private boolean replicationIsPassivation;
+ protected transient StatefulBeanContext ctx;
+
private Object readResolve() throws ObjectStreamException
{
StatefulContainer container = Ejb3Registry.getContainer(containerName, StatefulContainer.class);
@@ -86,6 +88,7 @@
context.replicationIsPassivation = this.replicationIsPassivation;
// I'm deserializing, so I was passivated
context.passivated = true;
+ ctx = context;
return context;
}
}
@@ -181,6 +184,9 @@
return copy;
}
+ /**
+ * Returns an EJB context which is usable in an EJB.
+ */
@Override
public EJBContext getEJBContext()
{
@@ -864,9 +870,17 @@
}
}
- private Object writeReplace() throws ObjectStreamException
+ private transient Serialized state = null;
+
+ /**
+ * Use only during serialization!
+ * @return
+ */
+ protected Serialized getState()
{
- Serialized state = new Serialized();
+ if(state != null)
+ return state;
+ this.state = new Serialized();
if (this.beanMO == null)
{
Object[] beanAndInterceptors = new Object[4];
@@ -904,6 +918,7 @@
state.beanMO = this.beanMO;
}
state.containerName = this.containerName;
+ assert this.containerName != null;
state.id = this.id;
state.lastUsed = this.lastUsed;
state.metadata = this.metadata;
@@ -912,6 +927,11 @@
return state;
}
+ private Object writeReplace() throws ObjectStreamException
+ {
+ return getState();
+ }
+
// public void writeExternal(ObjectOutput out) throws IOException
// {
// out.writeUTF(containerName);
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulSessionContextImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulSessionContextImpl.java 2007-08-27 11:17:45 UTC (rev 64887)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulSessionContextImpl.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -23,49 +23,186 @@
import java.io.ObjectStreamException;
import java.io.Serializable;
+import java.security.Identity;
+import java.security.Principal;
+import java.util.Properties;
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.SessionContext;
+import javax.ejb.TimerService;
+import javax.transaction.UserTransaction;
+import javax.xml.rpc.handler.MessageContext;
+
import org.jboss.ejb3.Ejb3Registry;
import org.jboss.ejb3.session.SessionBeanContext;
import org.jboss.ejb3.session.SessionContextImpl;
/**
* A session context that is serializable.
+ *
+ * Since a session context can be serialized with a bean it must not have a
+ * direct reference to StatefulBeanContext. Direct instantiation of a
+ * StatefulSessionContextImpl after activation is also not possible, because
+ * the bean is than not yet in cache. Therefore we use a delegate.
*
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
*/
-public class StatefulSessionContextImpl extends SessionContextImpl implements Serializable
+public class StatefulSessionContextImpl implements Serializable, SessionContext
{
private static final long serialVersionUID = 1L;
+ /**
+ * The container identifier.
+ */
+ private String oid;
+ /**
+ * The SFSB identifier.
+ */
+ private Object id;
+
+ private transient SessionContext delegate;
+
private static class Serialized implements Serializable
{
private static final long serialVersionUID = 1L;
-// private SessionBeanContext beanContext;
-
private String oid;
private Object id;
private Object readResolve() throws ObjectStreamException
{
- StatefulContainer container = Ejb3Registry.getContainer(oid, StatefulContainer.class);
- StatefulBeanContext beanContext = container.getCache().get(id, false);
- return new StatefulSessionContextImpl(beanContext);
+ return new StatefulSessionContextImpl(oid, id);
}
}
+ public StatefulSessionContextImpl(String oid, Object id)
+ {
+ assert oid != null : "oid is null";
+ assert id != null : "id is null";
+
+ this.oid = oid;
+ this.id = id;
+ }
+
public StatefulSessionContextImpl(SessionBeanContext beanContext)
{
- super(beanContext);
+ assert beanContext != null : "beanContext is null";
+
+ this.delegate = new SessionContextImpl(beanContext);
+ this.oid = beanContext.getContainer().getObjectName().getCanonicalName();
+ this.id = beanContext.getId();
}
private Object writeReplace() throws ObjectStreamException
{
Serialized s = new Serialized();
- s.oid = container.getObjectName().getCanonicalName();
- s.id = beanContext.getId();
-// s.beanContext = beanContext;
+ s.oid = this.oid;
+ s.id = this.id;
return s;
}
+
+ public <T> T getBusinessObject(Class<T> businessInterface) throws IllegalStateException
+ {
+ return getDelegate().getBusinessObject(businessInterface);
+ }
+
+ protected SessionContext getDelegate()
+ {
+ if(delegate == null)
+ {
+ delegate = new SessionContextImpl(Ejb3Registry.getContainer(oid, StatefulContainer.class).getCache().get(id, false));
+ }
+ return delegate;
+ }
+
+ public EJBLocalObject getEJBLocalObject() throws IllegalStateException
+ {
+ return getDelegate().getEJBLocalObject();
+ }
+
+ public EJBObject getEJBObject() throws IllegalStateException
+ {
+ return getDelegate().getEJBObject();
+ }
+
+ public Class<?> getInvokedBusinessInterface() throws IllegalStateException
+ {
+ return getDelegate().getInvokedBusinessInterface();
+ }
+
+ public MessageContext getMessageContext() throws IllegalStateException
+ {
+ return getDelegate().getMessageContext();
+ }
+
+ @SuppressWarnings("deprecation")
+ public Identity getCallerIdentity()
+ {
+ return getDelegate().getCallerIdentity();
+ }
+
+ public Principal getCallerPrincipal()
+ {
+ return getDelegate().getCallerPrincipal();
+ }
+
+ public EJBHome getEJBHome()
+ {
+ return getDelegate().getEJBHome();
+ }
+
+ public EJBLocalHome getEJBLocalHome()
+ {
+ return getDelegate().getEJBLocalHome();
+ }
+
+ public Properties getEnvironment()
+ {
+ return getDelegate().getEnvironment();
+ }
+
+ public boolean getRollbackOnly() throws IllegalStateException
+ {
+ return getDelegate().getRollbackOnly();
+ }
+
+ public TimerService getTimerService() throws IllegalStateException
+ {
+ return getDelegate().getTimerService();
+ }
+
+ public UserTransaction getUserTransaction() throws IllegalStateException
+ {
+ return getDelegate().getUserTransaction();
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean isCallerInRole(Identity role)
+ {
+ return getDelegate().isCallerInRole(role);
+ }
+
+ public boolean isCallerInRole(String roleName)
+ {
+ return getDelegate().isCallerInRole(roleName);
+ }
+
+ public Object lookup(String name)
+ {
+ return getDelegate().lookup(name);
+ }
+
+ public void setRollbackOnly() throws IllegalStateException
+ {
+ getDelegate().setRollbackOnly();
+ }
+
+ public String toString()
+ {
+ return super.toString() + "{oid=" + oid + ",id=" + id + "}";
+ }
}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/Mock.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/Mock.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/Mock.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.test.cachepassivation;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Mock
+{
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockBean.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.test.cachepassivation;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.SessionContext;
+
+import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.cache.Cache;
+import org.jboss.annotation.ejb.cache.simple.CacheConfig;
+import org.jboss.annotation.ejb.cache.simple.PersistenceManager;
+import org.jboss.ejb3.ThreadlocalPool;
+import org.jboss.ejb3.cache.simple.SimpleStatefulCache;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Cache(SimpleStatefulCache.class)
+ at PersistenceManager(MyStatefulSessionFilePersistenceManager.class)
+ at CacheConfig(idleTimeoutSeconds=1)
+ at PoolClass(value=ThreadlocalPool.class)
+public class MockBean implements Mock
+{
+ public static Object notification = new Object();
+ public static boolean passivated = false;
+
+ @Resource
+ public SessionContext ctx;
+
+ @PostActivate
+ public void postActivate()
+ {
+ System.out.println("postActivate");
+ }
+
+ @PostConstruct
+ public void postConstruct()
+ {
+ System.out.println("postConstruct");
+ }
+
+ @PrePassivate
+ public void prePassivate()
+ {
+ System.out.println("prePassivate");
+ synchronized (notification)
+ {
+ passivated = true;
+ notification.notify();
+ }
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockDeploymentUnit.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockDeploymentUnit.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockDeploymentUnit.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -0,0 +1,174 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.test.cachepassivation;
+
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockDeploymentUnit implements DeploymentUnit
+{
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getClassLoader()
+ */
+ public ClassLoader getClassLoader()
+ {
+ return null;
+ }
+
+ /* (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;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.DeploymentUnit#getUrl()
+ */
+ public URL getUrl()
+ {
+ return null;
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockEjb3Deployment.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockEjb3Deployment.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockEjb3Deployment.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.test.cachepassivation;
+
+import javax.security.jacc.PolicyConfiguration;
+
+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;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockEjb3Deployment extends Ejb3Deployment
+{
+
+ public MockEjb3Deployment(DeploymentUnit unit, DeploymentScope deploymentScope)
+ {
+ super(unit, deploymentScope);
+ }
+
+ @Override
+ public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
+ {
+ return new JBoss5DependencyPolicy(component);
+ }
+
+ @Override
+ protected PolicyConfiguration createPolicyConfiguration() throws Exception
+ {
+ throw new RuntimeException("mock");
+ }
+
+ @Override
+ protected void putJaccInService(PolicyConfiguration pc, DeploymentUnit unit)
+ {
+ throw new RuntimeException("mock");
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockStatefulContainer.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockStatefulContainer.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockStatefulContainer.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.test.cachepassivation;
+
+import java.util.Hashtable;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.ejb3.stateful.StatefulContainer;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockStatefulContainer extends StatefulContainer
+{
+
+ @SuppressWarnings("unchecked")
+ public MockStatefulContainer(ClassLoader cl, String beanClassName, String ejbName, AspectManager manager,
+ Hashtable ctxProperties, InterceptorInfoRepository interceptorRepository, Ejb3Deployment deployment)
+ {
+ super(cl, beanClassName, ejbName, manager, ctxProperties, interceptorRepository, deployment);
+ }
+
+ @Override
+ public Object createSession()
+ {
+ // TODO Auto-generated method stub
+ return super.createSession();
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MyStatefulSessionFilePersistenceManager.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MyStatefulSessionFilePersistenceManager.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MyStatefulSessionFilePersistenceManager.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -0,0 +1,530 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.test.cachepassivation;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.ejb.EJBException;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.cache.simple.StatefulSessionPersistenceManager;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
+import org.jboss.serial.io.JBossObjectInputStream;
+import org.jboss.serial.io.JBossObjectOutputStream;
+import org.jboss.system.server.ServerConfigLocator;
+import org.jboss.util.id.UID;
+
+/**
+ * This is a direct copy of StatefulSessionFilePersistenceManager
+ * with the exception of a dependency on the JBoss ServerConfig Mbean.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MyStatefulSessionFilePersistenceManager implements StatefulSessionPersistenceManager
+{
+
+ /**
+ * The sub-directory name under the server data directory where
+ * session data is stored.
+ *
+ * @see #DEFAULT_STORE_DIRECTORY_NAME
+ * @see #setStoreDirectoryName
+ */
+ private String storeDirName = DEFAULT_STORE_DIRECTORY_NAME;
+
+ /**
+ * The base directory where sessions state files are stored for our container.
+ */
+ private File storeDir;
+
+ private Container con;
+
+ /**
+ * Enable purging leftover state files at create and destroy
+ * time (default is true).
+ */
+ private boolean purgeEnabled = true;
+
+ /**
+ * Set the sub-directory name under the server data directory
+ * where session data will be stored.
+ * <p/>
+ * <p/>
+ * This value will be appened to the value of
+ * <tt><em>jboss-server-data-dir</em></tt>.
+ * <p/>
+ * <p/>
+ * This value is only used during creation and will not dynamically
+ * change the store directory when set after the create step has finished.
+ *
+ * @param dirName A sub-directory name.
+ */
+ public void setStoreDirectoryName(final String dirName)
+ {
+ this.storeDirName = dirName;
+ }
+
+ /**
+ * Get the sub-directory name under the server data directory
+ * where session data is stored.
+ *
+ * @return A sub-directory name.
+ * @see #setStoreDirectoryName
+ */
+ public String getStoreDirectoryName()
+ {
+ return storeDirName;
+ }
+
+ /**
+ * Set the stale session state purge enabled flag.
+ *
+ * @param flag The toggle flag to enable or disable purging.
+ */
+ public void setPurgeEnabled(final boolean flag)
+ {
+ this.purgeEnabled = flag;
+ }
+
+ /**
+ * Get the stale session state purge enabled flag.
+ *
+ * @return True if purge is enabled.
+ */
+ public boolean getPurgeEnabled()
+ {
+ return purgeEnabled;
+ }
+
+ /**
+ * Returns the directory used to store session passivation state files.
+ *
+ * @return The directory used to store session passivation state files.
+ */
+ public File getStoreDirectory()
+ {
+ return storeDir;
+ }
+
+ public void setContainer(Container con)
+ {
+ this.con = con;
+ }
+
+ /**
+ * Setup the session data storage directory.
+ * <p/>
+ * <p>Purges any existing session data found.
+ */
+ public void initialize(Container con) throws Exception
+ {
+ this.con = con;
+ boolean debug = log.isDebugEnabled();
+
+ // Initialize the dataStore
+
+ String ejbName = con.getEjbName();
+
+ // Get the system data directory
+ //File dir = ServerConfigLocator.locate().getServerTempDir();
+ File dir = new File("./temp");
+
+ // Setup the reference to the session data store directory
+ dir = new File(dir, storeDirName);
+ // ejbName is not unique across all deployments, so use a unique token
+ dir = new File(dir, ejbName + "-" + new UID().toString());
+ storeDir = dir;
+
+ if (debug)
+ {
+ log.debug("Storing sessions for '" + ejbName + "' in: " + storeDir);
+ }
+
+ // if the directory does not exist then try to create it
+ if (!storeDir.exists())
+ {
+ if (MkdirsFileAction.mkdirs(storeDir) == false)
+ {
+ throw new IOException("Failed to create directory: " + storeDir);
+ }
+ }
+
+ // make sure we have a directory
+ if (!storeDir.isDirectory())
+ {
+ throw new IOException("File exists where directory expected: " + storeDir);
+ }
+
+ // make sure we can read and write to it
+ if (!storeDir.canWrite() || !storeDir.canRead())
+ {
+ throw new IOException("Directory must be readable and writable: " + storeDir);
+ }
+
+ // Purge state session state files, should be none, due to unique directory
+ purgeAllSessionData();
+ }
+
+ /**
+ * Removes any state files left in the storgage directory.
+ */
+ public void purgeAllSessionData()
+ {
+ if (!purgeEnabled) return;
+
+ log.debug("Purging all session data in: " + storeDir);
+
+ File[] sessions = storeDir.listFiles();
+ for (int i = 0; i < sessions.length; i++)
+ {
+ if (!sessions[i].delete())
+ {
+ log.warn("Failed to delete session state file: " + sessions[i]);
+ }
+ else
+ {
+ log.debug("Removed stale session state: " + sessions[i]);
+ }
+ }
+ }
+
+ /**
+ * Purge any data in the store, and then the store directory too.
+ */
+ public void destroy() throws Exception
+ {
+ // Purge data and attempt to delete directory
+ purgeAllSessionData();
+
+ // Nuke the directory too if purge is enabled
+ if (purgeEnabled && !storeDir.delete())
+ {
+ log.warn("Failed to delete session state storage directory: " + storeDir);
+ }
+ }
+
+ /**
+ * Make a session state file for the given instance id.
+ */
+ private File getFile(final Object id)
+ {
+ //
+ // jason: may have to translate id into a os-safe string, though
+ // the format of UID is safe on Unix and win32 already...
+ //
+
+ return new File(storeDir, String.valueOf(id) + ".ser");
+ }
+
+ /**
+ * Restores session state from the serialized file & invokes
+ * {@link javax.ejb.SessionBean#ejbActivate} on the target bean.
+ */
+ public StatefulBeanContext activateSession(Object id)
+ {
+ boolean debug = log.isDebugEnabled();
+ if (debug)
+ {
+ log.debug("Attempting to activate; id=" + id);
+ }
+
+ // Load state
+ File file = getFile(id);
+ if (!file.exists()) return null;
+
+ if (debug)
+ {
+ log.debug("Reading session state from: " + file);
+ }
+
+ StatefulBeanContext bean = null;
+ try
+ {
+ FileInputStream fis = FISAction.open(file);
+ // todo need to rewrite SessionObjectInputStream to support EJB3 classes
+ ObjectInputStream in;
+
+ in = new JBossObjectInputStream(new BufferedInputStream(fis));
+ try
+ {
+ bean = (StatefulBeanContext) in.readObject();
+ }
+ finally
+ {
+ fis.close();
+ in.close();
+ }
+ }
+ catch (EJBException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Could not activate; failed to " +
+ "restore state", e);
+ }
+
+ removePassivated(id);
+
+ bean.postActivate();
+ return bean;
+ }
+
+ public List<StatefulBeanContext> getPassivatedBeans()
+ {
+ List beans = new LinkedList();
+
+ File[] files = storeDir.listFiles();
+ for (File file : files)
+ {
+ try
+ {
+ ObjectInputStream in;
+
+ FileInputStream fis = FISAction.open(file);
+
+ in = new JBossObjectInputStream(new BufferedInputStream(fis));
+ try
+ {
+ StatefulBeanContext bean = (StatefulBeanContext) in.readObject();
+ beans.add(bean);
+ }
+ finally
+ {
+ fis.close();
+ in.close();
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("Could not read for timeout removal for file " + file.getName(), e);
+ }
+ }
+
+ return beans;
+ }
+
+ /**
+ * Invokes {@link javax.ejb.SessionBean#ejbPassivate} on the target bean and saves the
+ * state of the session to a file.
+ */
+ public void passivateSession(StatefulBeanContext ctx)
+ {
+ boolean debug = log.isDebugEnabled();
+ if (debug)
+ {
+ log.debug("Attempting to passivate; id=" + ctx.getId());
+ }
+
+ ctx.prePassivate();
+ // Store state
+
+ File file = getFile(ctx.getId());
+ if (debug)
+ {
+ log.debug("Saving session state to: " + file);
+ }
+
+ try
+ {
+ FileOutputStream fos = FOSAction.open(file);
+ // todo need to rewrite SessionObjectOutputStream to support EJB3 classes
+ ObjectOutputStream out;
+
+ out = new JBossObjectOutputStream(fos, false);
+
+ try
+ {
+ out.writeObject(ctx);
+ out.flush();
+ fos.flush();
+ fos.close();
+ }
+ finally
+ {
+ out.close();
+ }
+ }
+ catch (EJBException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Could not passivate; failed to save state", e);
+ }
+
+ if (debug)
+ {
+ log.debug("Passivation complete; id=" + ctx.getId());
+ }
+ }
+
+ /**
+ * Removes the saved state file (if any) for the given session id.
+ */
+ public void removePassivated(Object id)
+ {
+ boolean debug = log.isDebugEnabled();
+
+ File file = getFile(id);
+
+ // only attempt to delete if the file exists
+ if (file.exists())
+ {
+ if (debug)
+ {
+ log.debug("Removing passivated state file: " + file);
+ }
+
+ if (DeleteFileAction.delete(file) == false)
+ {
+ log.warn("Failed to delete passivated state file: " + file);
+ }
+ }
+ }
+
+ static class DeleteFileAction implements PrivilegedAction
+ {
+ File file;
+
+ DeleteFileAction(File file)
+ {
+ this.file = file;
+ }
+
+ public Object run()
+ {
+ boolean deleted = file.delete();
+ return new Boolean(deleted);
+ }
+
+ static boolean delete(File file)
+ {
+ DeleteFileAction action = new DeleteFileAction(file);
+ Boolean deleted = (Boolean) AccessController.doPrivileged(action);
+ return deleted.booleanValue();
+ }
+ }
+
+ static class MkdirsFileAction implements PrivilegedAction
+ {
+ File file;
+
+ MkdirsFileAction(File file)
+ {
+ this.file = file;
+ }
+
+ public Object run()
+ {
+ boolean ok = file.mkdirs();
+ return new Boolean(ok);
+ }
+
+ static boolean mkdirs(File file)
+ {
+ MkdirsFileAction action = new MkdirsFileAction(file);
+ Boolean ok = (Boolean) AccessController.doPrivileged(action);
+ return ok.booleanValue();
+ }
+ }
+
+ static class FISAction implements PrivilegedExceptionAction
+ {
+ File file;
+
+ FISAction(File file)
+ {
+ this.file = file;
+ }
+
+ public Object run() throws Exception
+ {
+ FileInputStream fis = new FileInputStream(file);
+ return fis;
+ }
+
+ static FileInputStream open(File file) throws FileNotFoundException
+ {
+ FISAction action = new FISAction(file);
+ FileInputStream fis = null;
+ try
+ {
+ fis = (FileInputStream) AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (FileNotFoundException) e.getException();
+ }
+
+ return fis;
+ }
+ }
+
+ static class FOSAction implements PrivilegedExceptionAction
+ {
+ File file;
+
+ FOSAction(File file)
+ {
+ this.file = file;
+ }
+
+ public Object run() throws Exception
+ {
+ FileOutputStream fis = new FileOutputStream(file);
+ return fis;
+ }
+
+ static FileOutputStream open(File file) throws FileNotFoundException
+ {
+ FOSAction action = new FOSAction(file);
+ FileOutputStream fos = null;
+ try
+ {
+ fos = (FileOutputStream) AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (FileNotFoundException) e.getException();
+ }
+
+ return fos;
+ }
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java 2007-08-27 13:39:40 UTC (rev 64888)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.test.cachepassivation.unit;
+
+import java.util.Hashtable;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.Ejb3Registry;
+import org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager;
+import org.jboss.ejb3.cache.simple.StatefulSessionPersistenceManager;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
+import org.jboss.ejb3.stateful.StatefulContainer;
+import org.jboss.ejb3.test.cachepassivation.MockBean;
+import org.jboss.ejb3.test.cachepassivation.MockDeploymentUnit;
+import org.jboss.ejb3.test.cachepassivation.MockEjb3Deployment;
+import org.jboss.ejb3.test.cachepassivation.MockStatefulContainer;
+import org.jboss.ejb3.test.cachepassivation.MyStatefulSessionFilePersistenceManager;
+import org.jboss.naming.JavaCompInitializer;
+
+import junit.framework.TestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CachePassivationUnitTestCase extends TestCase
+{
+ public void test1() throws Exception
+ {
+ new JavaCompInitializer().start();
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ String beanClassName = MockBean.class.getName();
+ String ejbName = "MockBean";
+ AspectManager aspectManager = new AspectManager();
+ Hashtable ctxProperties = null;
+ InterceptorInfoRepository interceptorRepository = new InterceptorInfoRepository();
+ Ejb3Deployment deployment = new MockEjb3Deployment(new MockDeploymentUnit(), null);
+ MockStatefulContainer container = new MockStatefulContainer(cl, beanClassName, ejbName, aspectManager, ctxProperties, interceptorRepository, deployment);
+ container.processMetadata();
+ System.out.println("injectors = " + container.getInjectors());
+ Ejb3Registry.register(container);
+ try
+ {
+ container.create();
+ container.setJaccContextId("none");
+ container.start();
+
+ Object id = container.createSession();
+
+ StatefulBeanContext ctx = container.getCache().get(id, false);
+
+ System.out.println("inUse = " + ctx.isInUse());
+ MockBean bean = (MockBean) ctx.getInstance();
+ System.out.println(bean.ctx);
+ ctx.setInUse(false);
+ ctx = null;
+
+ synchronized (MockBean.notification)
+ {
+ MockBean.notification.wait(5000);
+ }
+ Thread.sleep(500);
+
+ ctx = container.getCache().get(id, false);
+ bean = (MockBean) ctx.getInstance();
+
+ String a = ctx.getEJBContext().toString();
+ String b = bean.ctx.toString();
+ System.out.println(ctx.getEJBContext());
+ System.out.println(bean.ctx);
+ assertTrue(a.regionMatches(a.indexOf('{'), b, b.indexOf('{'), a.length() - a.indexOf('{')));
+ }
+ finally
+ {
+ container.stop();
+ container.destroy();
+ Ejb3Registry.unregister(container);
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list