User: oberg
Date: 00/12/01 05:07:23
Modified: src/main/org/jboss/ejb/plugins EnterpriseInstanceCache.java
BMPPersistenceManager.java
Log:
Optimized fBPK calls: if pk is active in cache then bypass ejbFBPK call to EJB
instance
Revision Changes Path
1.8 +9 -1
jboss/src/main/org/jboss/ejb/plugins/EnterpriseInstanceCache.java
Index: EnterpriseInstanceCache.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/EnterpriseInstanceCache.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- EnterpriseInstanceCache.java 2000/11/30 02:19:48 1.7
+++ EnterpriseInstanceCache.java 2000/12/01 13:07:22 1.8
@@ -37,7 +37,7 @@
* </ul>
*
* @author Simone Bordet ([EMAIL PROTECTED])
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public abstract class EnterpriseInstanceCache
implements InstanceCache, XmlLoadable
@@ -133,6 +133,7 @@
}
schedulePassivation(ctx);
}
+
/* From InstanceCache interface */
public void remove(Object id)
{
@@ -147,6 +148,13 @@
}
removeLock(id);
}
+
+ public boolean isActive(Object id)
+ {
+ // Check whether an object with the given id is available in the cache
+ return getCache().peek(id) != null;
+ }
+
/**
* Creates (if necessary) and returns an object used as mutex to sync
passivation
* activity with other activities. <br>
1.17 +9 -1 jboss/src/main/org/jboss/ejb/plugins/BMPPersistenceManager.java
Index: BMPPersistenceManager.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/BMPPersistenceManager.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- BMPPersistenceManager.java 2000/11/15 15:25:57 1.16
+++ BMPPersistenceManager.java 2000/12/01 13:07:22 1.17
@@ -36,7 +36,7 @@
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.16 $
+* @version $Revision: 1.17 $
*/
public class BMPPersistenceManager
implements EntityPersistenceManager
@@ -430,6 +430,14 @@
private Object callFinderMethod(Method finderMethod, Object[] args,
EntityEnterpriseContext ctx)
throws Exception
{
+ // Check if findByPrimaryKey
+ // If so we check if the entity is in cache first
+ if (finderMethod.getName().equals("findByPrimaryKey"))
+ {
+ if (!con.getInstanceCache().isActive(args[0]))
+ return args[0]; // Object is active -> it exists -> no need to call
finder
+ }
+
// get the finder method
Method callMethod = (Method)finderMethods.get(finderMethod);