User: starksm
Date: 02/03/08 00:12:45
Modified: src/main/org/jboss/ejb EntityEnterpriseContext.java
TxEntityMap.java
Log:
Drop the use of CacheKey as its useless and having to wrap the
entity keys in a CacheKey was causing problems with the client interceptors.
Revision Changes Path
1.26 +9 -9 jboss/src/main/org/jboss/ejb/EntityEnterpriseContext.java
Index: EntityEnterpriseContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/EntityEnterpriseContext.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- EntityEnterpriseContext.java 19 Dec 2001 05:20:03 -0000 1.25
+++ EntityEnterpriseContext.java 8 Mar 2002 08:12:45 -0000 1.26
@@ -26,7 +26,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel OConnor</a>
- * @version $Revision: 1.25 $
+ * @version $Revision: 1.26 $
*
* <p><b>Revisions</b>
* <p>20010703 marcf
@@ -64,7 +64,7 @@
private Object persistenceCtx;
/** The cacheKey for this context */
- CacheKey key;
+ Object key;
// Constructors --------------------------------------------------
@@ -122,10 +122,11 @@
public void setCacheKey(Object key)
{
- this.key = (CacheKey) key;
+ this.key = key;
}
- public CacheKey getCacheKey() {
+ public Object getCacheKey()
+ {
return key;
}
@@ -182,14 +183,13 @@
if (((EntityContainer)con).getContainerInvoker()==null)
throw new IllegalStateException( "No remote interface defined." );
- if (ejbObject == null) {
-
+ if (ejbObject == null)
+ {
// Create a new CacheKey
Object cacheKey =
((EntityCache)((EntityContainer)con).getInstanceCache()).createCacheKey(id);
- ejbObject = (EJBObject)
((EntityContainer)con).getContainerInvoker().getEntityEJBObject(cacheKey);
-
+ ejbObject = (EJBObject)
((EntityContainer)con).getContainerInvoker().getEntityEJBObject(cacheKey);
}
-
+
return ejbObject;
}
1.9 +97 -97 jboss/src/main/org/jboss/ejb/TxEntityMap.java
Index: TxEntityMap.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/TxEntityMap.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TxEntityMap.java 13 Feb 2002 02:35:08 -0000 1.8
+++ TxEntityMap.java 8 Mar 2002 08:12:45 -0000 1.9
@@ -1,97 +1,97 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.ejb;
-
-import java.util.HashMap;
-import javax.transaction.Transaction;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Synchronization;
-
-/**
- * This class provides a way to find out what entities of a certain type that are
contained in
- * within a transaction. It is attached to a specific instance of a container.
- *<no longer - global only holds possibly dirty> This class interfaces with the
static GlobalTxEntityMap. EntitySynchronizationInterceptor
- * registers tx/entity pairs through this class.
- * Used in EntitySynchronizationInterceptor.
- *
- * @author <a href="[EMAIL PROTECTED]">Bill Burke</a>
- * @version $Revision: 1.8 $
- *
- * Revisions:
- *
- * <p><b>Revisions:</b><br>
- * <p><b>2001/08/06: billb</b>
- * <ol>
- * <li>Got rid of disassociate and added a javax.transaction.Synchronization.
The sync will clean up the map now.
- * <li>This class now interacts with GlobalTxEntityMap available.
- * </ol>
- */
-public class TxEntityMap
-{
- protected HashMap m_map = new HashMap();
-
- /**
- * associate entity with transaction
- */
- public synchronized void associate(Transaction tx,
- EntityEnterpriseContext entity) throws
RollbackException, SystemException
- {
- HashMap entityMap = (HashMap)m_map.get(tx);
- if (entityMap == null)
- {
- entityMap = new HashMap();
- m_map.put(tx, entityMap);
- tx.registerSynchronization(new TxEntityMapCleanup(this, tx));
- }
- //EntityContainer.getGlobalTxEntityMap().associate(tx, entity);
- entityMap.put(entity.getCacheKey(), entity);
- }
-
- public synchronized EntityEnterpriseContext getCtx(Transaction tx,
- CacheKey key)
- {
- HashMap entityMap = (HashMap)m_map.get(tx);
- if (entityMap == null) return null;
- return (EntityEnterpriseContext)entityMap.get(key);
- }
-
- /**
- * Cleanup tx/entity map on tx commit/rollback
- */
- private class TxEntityMapCleanup implements Synchronization
- {
- TxEntityMap map;
- Transaction tx;
-
- public TxEntityMapCleanup(TxEntityMap map,
- Transaction tx)
- {
- this.map = map;
- this.tx = tx;
- }
-
- // Synchronization implementation -----------------------------
-
- public void beforeCompletion()
- {
- /* complete */
- }
-
- public void afterCompletion(int status)
- {
- synchronized(map)
- {
- HashMap entityMap = (HashMap)m_map.remove(tx);
- if (entityMap != null)
- {
- entityMap.clear();
- }
- }
- }
- }
-}
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.ejb;
+
+import java.util.HashMap;
+import javax.transaction.Transaction;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Synchronization;
+
+/**
+ * This class provides a way to find out what entities of a certain type that are
contained in
+ * within a transaction. It is attached to a specific instance of a container.
+ *<no longer - global only holds possibly dirty> This class interfaces with the
static GlobalTxEntityMap. EntitySynchronizationInterceptor
+ * registers tx/entity pairs through this class.
+ * Used in EntitySynchronizationInterceptor.
+ *
+ * @author <a href="[EMAIL PROTECTED]">Bill Burke</a>
+ * @version $Revision: 1.9 $
+ *
+ * Revisions:
+ *
+ * <p><b>Revisions:</b><br>
+ * <p><b>2001/08/06: billb</b>
+ * <ol>
+ * <li>Got rid of disassociate and added a javax.transaction.Synchronization.
The sync will clean up the map now.
+ * <li>This class now interacts with GlobalTxEntityMap available.
+ * </ol>
+ */
+public class TxEntityMap
+{
+ protected HashMap m_map = new HashMap();
+
+ /**
+ * associate entity with transaction
+ */
+ public synchronized void associate(Transaction tx,
+ EntityEnterpriseContext entity) throws
RollbackException, SystemException
+ {
+ HashMap entityMap = (HashMap)m_map.get(tx);
+ if (entityMap == null)
+ {
+ entityMap = new HashMap();
+ m_map.put(tx, entityMap);
+ tx.registerSynchronization(new TxEntityMapCleanup(this, tx));
+ }
+ //EntityContainer.getGlobalTxEntityMap().associate(tx, entity);
+ entityMap.put(entity.getCacheKey(), entity);
+ }
+
+ public synchronized EntityEnterpriseContext getCtx(Transaction tx,
+ Object key)
+ {
+ HashMap entityMap = (HashMap)m_map.get(tx);
+ if (entityMap == null) return null;
+ return (EntityEnterpriseContext)entityMap.get(key);
+ }
+
+ /**
+ * Cleanup tx/entity map on tx commit/rollback
+ */
+ private class TxEntityMapCleanup implements Synchronization
+ {
+ TxEntityMap map;
+ Transaction tx;
+
+ public TxEntityMapCleanup(TxEntityMap map,
+ Transaction tx)
+ {
+ this.map = map;
+ this.tx = tx;
+ }
+
+ // Synchronization implementation -----------------------------
+
+ public void beforeCompletion()
+ {
+ /* complete */
+ }
+
+ public void afterCompletion(int status)
+ {
+ synchronized(map)
+ {
+ HashMap entityMap = (HashMap)m_map.remove(tx);
+ if (entityMap != null)
+ {
+ entityMap.clear();
+ }
+ }
+ }
+ }
+}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development