[jboss-cvs] JBossAS SVN: r60642 - branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 19 03:50:44 EST 2007
Author: bstansberry at jboss.com
Date: 2007-02-19 03:50:44 -0500 (Mon, 19 Feb 2007)
New Revision: 60642
Modified:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java
Log:
[EJBTHREE-867] Loosen coupling of lifecycle of nested SFSBs
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java 2007-02-19 08:50:18 UTC (rev 60641)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java 2007-02-19 08:50:44 UTC (rev 60642)
@@ -112,17 +112,34 @@
public StatefulBeanContext get(Object key) throws EJBException
{
+ return get(key, true);
+ }
+
+ public StatefulBeanContext get(Object key, boolean markInUse) throws EJBException
+ {
StatefulBeanContext entry = null;
synchronized (cacheMap)
{
entry = (StatefulBeanContext) cacheMap.get(key);
}
+
if (entry == null)
{
throw new NoSuchEJBException("Could not find Stateful bean: " + key);
+ }
+
+ if (markInUse)
+ {
+ if (entry.isRemoved())
+ {
+ throw new NoSuchEJBException("Could not find stateful bean: " + key +
+ " (bean was marked as removed");
+ }
+
+ entry.setInUse(true);
+ entry.lastUsed = System.currentTimeMillis();
}
- entry.inUse = true;
- entry.lastUsed = System.currentTimeMillis();
+
return entry;
}
@@ -130,7 +147,7 @@
{
synchronized (ctx)
{
- ctx.inUse = false;
+ ctx.setInUse(false);
ctx.lastUsed = System.currentTimeMillis();
}
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java 2007-02-19 08:50:18 UTC (rev 60641)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java 2007-02-19 08:50:44 UTC (rev 60642)
@@ -40,8 +40,41 @@
public StatefulBeanContext create(Class[] initTypes, Object[] initValues);
+ /**
+ * Gets the context with the given id.
+ * <p/>
+ * Same as <code>getContext(key, true)</code>
+ *
+ * @param key the id
+ * @return the context
+ *
+ * @throws NoSuchEJBException if no context with the given id exists or
+ * if the context exists but has been marked
+ * as removed
+ * @throws EJBException
+ */
public StatefulBeanContext get(Object key) throws EJBException;
+ /**
+ * Get the context with the given id, optionally marking the context as
+ * being in use.
+ *
+ * @param key the context's id
+ * @param markInUse if <code>true</code>, marks any returned context as
+ * being in use. If <code>false</code>, will return
+ * contexts that are marked as removed; otherwise will
+ * throw NoSuchEJBException if such a context is found
+ *
+ * @return the context
+ *
+ * @throws NoSuchEJBException if no context with the given id exists or
+ * if the context exists but has been marked
+ * as removed and <code>markInUse</code> is
+ * <code>true</code>
+ * @throws EJBException
+ */
+ public StatefulBeanContext get(Object key, boolean markInUse) throws EJBException;
+
public void remove(Object key);
public void finished(StatefulBeanContext ctx);
More information about the jboss-cvs-commits
mailing list