[jboss-cvs] JBossAS SVN: r67520 - in branches/Branch_4_2/ejb3/src: resources/test and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 27 18:06:34 EST 2007


Author: bstansberry at jboss.com
Date: 2007-11-27 18:06:34 -0500 (Tue, 27 Nov 2007)
New Revision: 67520

Added:
   branches/Branch_4_2/ejb3/src/resources/test/ejbthree1136/
   branches/Branch_4_2/ejb3/src/resources/test/ejbthree1136/jboss-service.xml
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/DoNothingBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/DoNothingRemote.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/SFSBCacheManipulator.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/SFSBCacheManipulatorMBean.java
Modified:
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
Log:
[EJBTHREE-1136] Always clear main cache tree in StatefulTreeCache.initialize().

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java	2007-11-27 22:52:57 UTC (rev 67519)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java	2007-11-27 23:06:34 UTC (rev 67520)
@@ -319,19 +319,11 @@
               config.maxSize());
       Region region = evictRegionManager.createRegion(cacheNode, element);
       
+      // JBCACHE-1136.  There's no reason to have state in an inactive region
+      cleanBeanRegion();
+      
       cache.registerClassLoader(cacheNode.toString(), cl);
-      try
-      {
-         cache.activateRegion(cacheNode.toString());
-      }
-      catch (RegionNotEmptyException e)
-      {
-         // this can happen with nested bean contexts if gravitation
-         // pulls a parent bean over after the parent region is stopped
-         // Clean up and try again
-         cleanBeanRegion();
-         cache.activateRegion(cacheNode.toString());
-      }
+      cache.activateRegion(cacheNode.toString());
       
       log.debug("initialize(): create eviction region: " +region + " for ejb: " +this.ejbContainer.getEjbName());
    

Added: branches/Branch_4_2/ejb3/src/resources/test/ejbthree1136/jboss-service.xml
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/test/ejbthree1136/jboss-service.xml	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/resources/test/ejbthree1136/jboss-service.xml	2007-11-27 23:06:34 UTC (rev 67520)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+
+   <mbean code="org.jboss.ejb3.test.ejbthree1136.SFSBCacheManipulator"
+      name="jboss.test:service=Ejb3SFSBCacheManipulator">
+
+      <depends optional-attribute-name="ClusteredBeanCache" proxy-type="attribute">jboss.cache:service=EJB3SFSBClusteredCache</depends>
+
+      <attribute name="RegionRoot">/jar=ejbthree1136.jar,name=DoNothingBean</attribute>
+   </mbean>
+
+</server>

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/DoNothingBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/DoNothingBean.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/DoNothingBean.java	2007-11-27 23:06:34 UTC (rev 67520)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.ejbthree1136;
+
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.ejb.Clustered;
+
+/**
+ * A meaningless bean, just so we can deploy a clustered SFSB and
+ * check the state of the SFSB cache thereafter.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 60635 $
+ */
+ at Stateful
+ at Clustered
+public class DoNothingBean implements DoNothingRemote
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   public void doNothing()
+   {
+      // TODO Auto-generated method stub      
+   }  
+   
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/DoNothingRemote.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/DoNothingRemote.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/DoNothingRemote.java	2007-11-27 23:06:34 UTC (rev 67520)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1136;
+
+import javax.ejb.Remote;
+
+/**
+ * A meaningless interface, just so we can deploy a clustered SFSB and
+ * check the state of the SFSB cache thereafter.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 60233 $
+ */
+ at Remote
+public interface DoNothingRemote
+{
+   void doNothing();
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/SFSBCacheManipulator.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/SFSBCacheManipulator.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/SFSBCacheManipulator.java	2007-11-27 23:06:34 UTC (rev 67520)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.ejbthree1136;
+
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCacheMBean;
+import org.jboss.cache.config.Option;
+
+/**
+ * MBean that stores a key/value in a cache during start
+ * and then allows a caller to check if the value is still there.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class SFSBCacheManipulator implements SFSBCacheManipulatorMBean
+{
+   public static final String VALUE = "VALUE";
+   
+   private TreeCacheMBean clusteredBeanCache;
+   private String regionRoot;
+   
+   public TreeCacheMBean getClusteredBeanCache()
+   {
+      return clusteredBeanCache;
+   }
+
+   public void setClusteredBeanCache(TreeCacheMBean clusteredBeanCache)
+   {
+      this.clusteredBeanCache = clusteredBeanCache;
+   }
+   
+   public String getRegionRoot()
+   {
+      return regionRoot;
+   }
+
+   public void setRegionRoot(String regionRoot)
+   {
+      this.regionRoot = regionRoot;
+   }
+   
+   public Fqn getTestFqn()
+   {
+      Fqn base = Fqn.fromString(regionRoot);
+      return new Fqn(base, "test");
+   }
+
+   public void start() throws Exception
+   {
+      Option opt = new Option();
+      opt.setCacheModeLocal(true);
+      Fqn fqn = getTestFqn();
+      clusteredBeanCache.put(fqn, "key", VALUE, opt);
+      // "Passivate" the data
+      clusteredBeanCache.evict(fqn);
+   }
+   
+   public void stop() throws Exception
+   {
+      Option opt = new Option();
+      opt.setCacheModeLocal(true);
+      clusteredBeanCache.remove(getTestFqn(), opt);
+   }
+   
+   public Object getFromBeanCache() throws CacheException
+   {
+      Fqn fqn = getTestFqn();
+      Object obj = clusteredBeanCache.get(fqn, "key");
+      // "Re-Passivate" the data
+      clusteredBeanCache.evict(fqn);
+      return obj;
+   }
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/SFSBCacheManipulatorMBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/SFSBCacheManipulatorMBean.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbthree1136/SFSBCacheManipulatorMBean.java	2007-11-27 23:06:34 UTC (rev 67520)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.ejbthree1136;
+
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCacheMBean;
+
+/**
+ * MBean that stores a key/value in a cache during start
+ * and then allows a caller to check if the value is still there.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface SFSBCacheManipulatorMBean
+{
+   TreeCacheMBean getClusteredBeanCache();
+
+   void setClusteredBeanCache(TreeCacheMBean clusteredBeanCache);
+
+   String getRegionRoot();
+
+   void setRegionRoot(String regionRoot);
+
+   Fqn getTestFqn();
+
+   void start() throws Exception;
+
+   void stop() throws Exception;
+
+   Object getFromBeanCache() throws CacheException;
+
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list