User: patriot1burke
Date: 01/06/14 20:37:29
Added: src/main/org/jboss/ejb TxEntityMap.java
Log:
With this class, you can find out the entities that are associated with a given
transaction.
Each EntityContainer contains an instance of this class.
EntitySynchronizationInterceptor and InstanceSynchronization use this class to
storeEntities before an ejbFind<METHOD> is called.
The EJB spec 2.0 reads.... 9.6.4
"Before invoking the ejbFind<METHOD>(...) method,
the container must first synchronize the state of any entity bean instances
that are participating in the same transaction context as is used to execute
the ejbFind<METHOD>(...) by invoking the ejbStore() method on those entity
bean instances."
Revision Changes Path
1.1 jboss/src/main/org/jboss/ejb/TxEntityMap.java
Index: TxEntityMap.java
===================================================================
package org.jboss.ejb;
import java.util.HashMap;
import javax.transaction.Transaction;
/**
* This class provides a way to find out what entities
* are contained in what transaction. It is used, to find which entities
* to call ejbStore() on when a ejbFind() method is called within a transaction. EJB
2.0- 9.6.4
* Used in EntitySynchronizationInterceptor
* @author <a href="[EMAIL PROTECTED]">Bill Burke</a>
* @version $Revision: 1.1 $
*/
public class TxEntityMap
{
protected HashMap m_map = new HashMap();
/**
* associate entity with transaction
*/
public synchronized void associate(Transaction tx, EntityEnterpriseContext
entity)
{
HashMap entityMap = (HashMap)m_map.get(tx);
if (entityMap == null)
{
entityMap = new HashMap();
m_map.put(tx, entityMap);
}
entityMap.put(entity.getCacheKey(), entity);
}
/**
* disassociate entity with transaction. When the transaction has no more
entities.
* it is removed from this class's internal HashMap.
*/
public synchronized void disassociate(Transaction tx, EntityEnterpriseContext
ctx)
{
HashMap entityMap = (HashMap)m_map.get(tx);
if (entityMap == null)
{
return;
}
entityMap.remove(ctx.getCacheKey());
// When all entities are gone, cleanup!
// cleanup involves removing the transaction
// from the map
if (entityMap.size() <= 0)
{
m_map.remove(tx);
}
}
/**
* get all EntityEnterpriseContext that are involved with a transaction.
*/
public synchronized Object[] getEntities(Transaction tx)
{
HashMap entityMap = (HashMap)m_map.get(tx);
if (entityMap == null) // there are no entities associated
{
return new Object[0];
}
return entityMap.values().toArray();
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development