public class Account
{
private float balance;
public Account(float balance)
{
this.balance=balance;
}
public void debit(float amount)
{
// Implementation to debit the account balance
...
}
public void credit(float amount)
{
// Implementation to credit the account balance
...
}
public String toString()
{
// Implementation to format the account description
...
}
}
The above class required to support concurrency invocation of the method debit,credit and toString method.
The concurrency code is refactored within the Read/Write Lock Aspect.So the new Aspect can be applied against any method using annotation or an XML file.
public class Account
{
private float balance;
public Account(float balance)
this.balance=balance;
}
/**
* @@org.jboss.aop.patterns.readwritelock.writeLockOperation
*/
public void debit(float amount)
{
// Implementation to debit the account balance
...
}
/**
* @@org.jboss.aop.patterns.readwritelock.writeLockOperation
*/
public void credit(float amount)
{
// Implementation to credit the account balance
...
}
/**
* @@org.jboss.aop.patterns.readwritelock.readLockOperation
*/
public String toString()
{
// Implementation to format the account description
...
}
}
The deployment description of the Read/Write Lock Aspect