| AnnotatedTxLockedPOJO.java |
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.test.aop.bean;
/**
*
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
* @version $Revision: 1.1 $
*/
public class AnnotatedTxLockedPOJO
{
public AnnotatedTxLockedPOJO()
{
field = 0;
}
private int field;
public int getField() { return field; }
/**
* @@org.jboss.aspects.tx.Tx (org.jboss.aspects.tx.TxType.REQUIRED)
* @@org.jboss.aspects.txlock.TxSynchronized
*
* @param val
*/
public void setField(int val)
{
if (val == 6 && field == 0)
{
throw new RuntimeException("TxLock didn't work. 2nd thread got there first.");
}
if (val == 5)
{
// Sleep to test the lock
try { Thread.sleep(5000); } catch (Exception ignored) { }
}
field = val;
}
}
| AnnotatedTxLockedPOJO.java |