1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Services
.Transaction
17 public delegate void TransactionCreationInfoDelegate(ITransaction transaction
, TransactionMode transactionMode
, IsolationMode isolationMode
, bool distributedTransaction
);
19 public delegate void TransactionDelegate(ITransaction transaction
);
21 public delegate void TransactionErrorDelegate(ITransaction transaction
, TransactionException transactionError
);
24 /// Manages the creation and disposal of <see cref="ITransaction"/> instances.
26 public interface ITransactionManager
29 /// Raised when a top level transaction was created
31 event TransactionCreationInfoDelegate TransactionCreated
;
34 /// Raised when a child transaction was created
36 event TransactionCreationInfoDelegate ChildTransactionCreated
;
39 /// Raised when the transaction was committed successfully
41 event TransactionDelegate TransactionCommitted
;
44 /// Raised when the transaction was rolledback successfully
46 event TransactionDelegate TransactionRolledback
;
49 /// Raised when the transaction was disposed
51 event TransactionDelegate TransactionDisposed
;
54 /// Raised when the transaction has failed on commit/rollback
56 event TransactionErrorDelegate TransactionFailed
;
59 /// Creates a transaction.
61 /// <param name="transactionMode">The transaction mode.</param>
62 /// <param name="isolationMode">The isolation mode.</param>
63 /// <returns></returns>
64 ITransaction
CreateTransaction(TransactionMode transactionMode
, IsolationMode isolationMode
);
67 /// Creates a transaction.
69 /// <param name="transactionMode">The transaction mode.</param>
70 /// <param name="isolationMode">The isolation mode.</param>
71 /// <param name="distributedTransaction">if set to <c>true</c>, the TM will create a distributed transaction.</param>
72 /// <returns></returns>
73 ITransaction
CreateTransaction(TransactionMode transactionMode
, IsolationMode isolationMode
, bool distributedTransaction
);
76 /// Returns the current <see cref="ITransaction"/>.
77 /// The transaction manager will probably need to
78 /// hold the created transaction in the thread or in
79 /// some sort of context.
81 ITransaction CurrentTransaction { get; }
84 /// Should guarantee the correct disposal of transaction
87 /// <param name="transaction"></param>
88 void Dispose(ITransaction transaction
);