1 // Copyright 2004-2007 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
);
22 /// Manages the creation and disposal of <see cref="ITransaction"/> instances.
24 public interface ITransactionManager
27 /// Raised when a top level transaction was created
29 event TransactionCreationInfoDelegate TransactionCreated
;
32 /// Raised when a child transaction was created
34 event TransactionCreationInfoDelegate ChildTransactionCreated
;
37 /// Raised when the transaction was committed successfully
39 event TransactionDelegate TransactionCommitted
;
42 /// Raised when the transaction was rolledback successfully
44 event TransactionDelegate TransactionRolledback
;
47 /// Raised when the transaction was disposed
49 event TransactionDelegate TransactionDisposed
;
52 /// Creates a transaction.
54 /// <param name="transactionMode">The transaction mode.</param>
55 /// <param name="isolationMode">The isolation mode.</param>
56 /// <returns></returns>
57 ITransaction
CreateTransaction(TransactionMode transactionMode
, IsolationMode isolationMode
);
60 /// Creates a transaction.
62 /// <param name="transactionMode">The transaction mode.</param>
63 /// <param name="isolationMode">The isolation mode.</param>
64 /// <param name="distributedTransaction">if set to <c>true</c>, the TM will create a distributed transaction.</param>
65 /// <returns></returns>
66 ITransaction
CreateTransaction(TransactionMode transactionMode
, IsolationMode isolationMode
, bool distributedTransaction
);
69 /// Returns the current <see cref="ITransaction"/>.
70 /// The transaction manager will probably need to
71 /// hold the created transaction in the thread or in
72 /// some sort of context.
74 ITransaction CurrentTransaction { get; }
77 /// Should guarantee the correct disposal of transaction
80 /// <param name="transaction"></param>
81 void Dispose(ITransaction transaction
);