[jboss-cvs] JBossAS SVN: r60613 - trunk/ejb3/src/main/org/jboss/ejb3/cache.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Feb 18 22:43:14 EST 2007
Author: bstansberry at jboss.com
Date: 2007-02-18 22:43:14 -0500 (Sun, 18 Feb 2007)
New Revision: 60613
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
trunk/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java
Log:
[EJBTHREE-867] Loosen coupling of lifecycle of nested SFSBs
Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java 2007-02-19 03:41:38 UTC (rev 60612)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java 2007-02-19 03:43:14 UTC (rev 60613)
@@ -110,17 +110,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;
}
@@ -128,7 +145,7 @@
{
synchronized (ctx)
{
- ctx.inUse = false;
+ ctx.setInUse(false);
ctx.lastUsed = System.currentTimeMillis();
}
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java 2007-02-19 03:41:38 UTC (rev 60612)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java 2007-02-19 03:43:14 UTC (rev 60613)
@@ -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