Update of /cvsroot/springnet/Spring.Net/examples/Spring/Spring.TxQuickStart/src/Spring/Spring.TxQuickStart/TxQuickStart/Services
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv22064/TxQuickStart/Services
Modified Files:
AccountManager.cs IAccountManager.cs
Log Message:
improved tx quickstart
Index: AccountManager.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/examples/Spring/Spring.TxQuickStart/src/Spring/Spring.TxQuickStart/TxQuickStart/Services/AccountManager.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** AccountManager.cs 9 Aug 2007 06:30:17 -0000 1.6
--- AccountManager.cs 7 Dec 2007 02:36:15 -0000 1.7
***************
*** 8,49 ****
public class AccountManager : IAccountManager
{
- private bool throwException = false;
! private IAccountCreditDao creditDao;
! private IAccountDebitDao debitDao;
!
! public bool ThrowException
! {
! get { return throwException; }
! set { throwException = value; }
! }
! public IAccountCreditDao AccountCreditDao
! {
! get { return creditDao; }
! set { creditDao = value; }
! }
! public IAccountDebitDao AccountDebitDao
{
! get { return debitDao; }
! set { debitDao = value; }
}
!
! [Transaction]
! public void DoTransfer(float creditAmount, float debitAmount)
{
! creditDao.CreateCredit(creditAmount);
!
! if (ThrowException)
! {
! throw new ArithmeticException("Couldn't do the math....");
! }
!
! debitDao.DebitAccount(debitAmount);
}
-
// The following rollback rule will result in commiting of only work done
--- 8,29 ----
public class AccountManager : IAccountManager
{
! private IAccountCreditDao accountCreditDao;
! private IAccountDebitDao accountDebitDao;
! private float maxTransferAmount = 1000000;
! public AccountManager(IAccountCreditDao accountCreditDao, IAccountDebitDao accountDebitDao)
{
! this.accountCreditDao = accountCreditDao;
! this.accountDebitDao = accountDebitDao;
}
! public float MaxTransferAmount
{
! get { return maxTransferAmount; }
! set { maxTransferAmount = value; }
}
// The following rollback rule will result in commiting of only work done
***************
*** 51,71 ****
// calling code.
! /*
! [Transaction(NoRollbackFor = new Type[] { typeof(ApplicationException) })]
public void DoTransfer(float creditAmount, float debitAmount)
{
! creditDao.CreateCredit(creditAmount);
! DoThrowException();
! debitDao.DebitAccount(debitAmount);
! }
! public void DoThrowException()
! {
! throw new ApplicationException("Testing No Rollback 'Rule'");
}
- */
-
-
}
--- 31,49 ----
// calling code.
! // [Transaction(NoRollbackFor = new Type[] { typeof(ArithmeticException) })]
!
! [Transaction]
public void DoTransfer(float creditAmount, float debitAmount)
{
! accountCreditDao.CreateCredit(creditAmount);
! if (creditAmount > maxTransferAmount || debitAmount > maxTransferAmount)
! {
! throw new ArithmeticException("see a teller big spender...");
! }
!
! accountDebitDao.DebitAccount(debitAmount);
}
}
Index: IAccountManager.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/examples/Spring/Spring.TxQuickStart/src/Spring/Spring.TxQuickStart/TxQuickStart/Services/IAccountManager.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IAccountManager.cs 6 Dec 2006 07:27:53 -0000 1.1
--- IAccountManager.cs 7 Dec 2007 02:36:15 -0000 1.2
***************
*** 4,7 ****
--- 4,8 ----
public interface IAccountManager
{
+
void DoTransfer(float creditAmount, float debitAmount);
}
|