| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
Seasar.Extension.Tx\Impl\LocalRequiresNewTxHandler.cs | 50.0% | 100.0% | 100.0% | 94.4% |
|
1 | #region Copyright | |
2 | /* | |
3 | * Copyright 2005 the Seasar Foundation and the Others. | |
4 | * | |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
14 | * either express or implied. See the License for the specific language | |
15 | * governing permissions and limitations under the License. | |
16 | */ | |
17 | #endregion | |
18 | ||
19 | using System; | |
20 | ||
21 | using Seasar.Framework.Aop; | |
22 | ||
23 | namespace Seasar.Extension.Tx.Impl | |
24 | { | |
25 | /// <summary> | |
26 | /// LocalRequiresNewTxHandler の概要の説明です。 | |
27 | /// </summary> | |
28 | public class LocalRequiresNewTxHandler : AbstractLocalTxHandler | |
29 | { | |
30 | ||
31 | 5 | public override object Handle(IMethodInvocation invocation, bool alreadyInTransaction) |
32 | { | |
33 | 5 | using(ITransactionContext current = this.Context.Create()) |
34 | { | |
35 | 5 | ITransactionContext parent = this.Context.Current; |
36 | 5 | current.Parent = parent; |
37 | 5 | this.Context.Current = null; |
38 | 5 | current.Begin(); |
39 | 5 | this.Context.Current = current; |
40 | ||
41 | 5 | try |
42 | { | |
43 | 5 | object obj = invocation.Proceed(); |
44 | 4 | current.Commit(); |
45 | 4 | return obj; |
46 | } | |
47 | catch | |
48 | { | |
49 | 1 | current.Rollback(); |
50 | 1 | throw; |
51 | } | |
52 | finally | |
53 | { | |
54 | 5 | this.Context.Current = parent; |
55 | 5 | if(parent != null) this.Context.Current.Parent = null; |
56 | } | |
57 | } | |
58 | } | |
59 | } | |
60 | } | |
61 |
|