EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[all classes][org.springframework.batch.support.transaction]

COVERAGE SUMMARY FOR SOURCE FILE [ResourcelessTransactionManager.java]

nameclass, %method, %block, %line, %
ResourcelessTransactionManager.java67%  (2/3)92%  (12/13)94%  (113/120)94%  (31/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourcelessTransactionManager$ResourcelessTransaction100% (1/1)80%  (4/5)85%  (17/20)86%  (6/7)
isActive (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
ResourcelessTransactionManager$ResourcelessTransaction (): void 100% (1/1)100% (6/6)100% (2/2)
ResourcelessTransactionManager$ResourcelessTransaction (ResourcelessTransacti... 100% (1/1)100% (3/3)100% (1/1)
begin (): void 100% (1/1)100% (4/4)100% (2/2)
clear (): void 100% (1/1)100% (4/4)100% (2/2)
     
class ResourcelessTransactionManager100% (1/1)100% (8/8)96%  (96/100)96%  (26/27)
isExistingTransaction (Object): boolean 100% (1/1)79%  (15/19)75%  (3/4)
ResourcelessTransactionManager (): void 100% (1/1)100% (3/3)100% (2/2)
doBegin (Object, TransactionDefinition): void 100% (1/1)100% (4/4)100% (2/2)
doCleanupAfterCompletion (Object): void 100% (1/1)100% (15/15)100% (6/6)
doCommit (DefaultTransactionStatus): void 100% (1/1)100% (15/15)100% (2/2)
doGetTransaction (): Object 100% (1/1)100% (28/28)100% (8/8)
doRollback (DefaultTransactionStatus): void 100% (1/1)100% (15/15)100% (2/2)
doSetRollbackOnly (DefaultTransactionStatus): void 100% (1/1)100% (1/1)100% (1/1)
     
class ResourcelessTransactionManager$10%   (0/1)100% (0/0)100% (0/0)100% (0/0)

1/*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17package org.springframework.batch.support.transaction;
18 
19import java.util.Stack;
20 
21import org.springframework.transaction.TransactionDefinition;
22import org.springframework.transaction.TransactionException;
23import org.springframework.transaction.support.AbstractPlatformTransactionManager;
24import org.springframework.transaction.support.DefaultTransactionStatus;
25import org.springframework.transaction.support.TransactionSynchronizationManager;
26 
27public class ResourcelessTransactionManager extends AbstractPlatformTransactionManager {
28 
29        protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
30                ((ResourcelessTransaction) transaction).begin();
31        }
32 
33        protected void doCommit(DefaultTransactionStatus status) throws TransactionException {
34                logger.debug("Committing resourceless transaction on [" + status.getTransaction() + "]");
35        }
36 
37        protected Object doGetTransaction() throws TransactionException {
38                Object transaction = new ResourcelessTransaction();
39                Stack<Object> resources;
40                if (!TransactionSynchronizationManager.hasResource(this)) {
41                        resources = new Stack<Object>();
42                        TransactionSynchronizationManager.bindResource(this, resources);
43                }
44                else {
45                        @SuppressWarnings("unchecked")
46                        Stack<Object> stack = (Stack<Object>) TransactionSynchronizationManager.getResource(this);
47                        resources = stack;
48                }
49                resources.push(transaction);
50                return transaction;
51        }
52 
53        protected void doRollback(DefaultTransactionStatus status) throws TransactionException {
54                logger.debug("Rolling back resourceless transaction on [" + status.getTransaction() + "]");
55        }
56 
57        protected boolean isExistingTransaction(Object transaction) throws TransactionException {
58                if (TransactionSynchronizationManager.hasResource(this)) {
59                        @SuppressWarnings("unchecked")
60                        Stack<Object> stack = (Stack<Object>) TransactionSynchronizationManager.getResource(this);
61                        return stack.size() > 1;
62                }
63                return ((ResourcelessTransaction) transaction).isActive();
64        }
65 
66        protected void doSetRollbackOnly(DefaultTransactionStatus status) throws TransactionException {
67        }
68 
69        protected void doCleanupAfterCompletion(Object transaction) {
70                @SuppressWarnings("unchecked")
71                Stack<Object> list = (Stack<Object>) TransactionSynchronizationManager.getResource(this);
72                Stack<Object> resources = list;
73                resources.clear();
74                TransactionSynchronizationManager.unbindResource(this);
75                ((ResourcelessTransaction) transaction).clear();
76        }
77 
78        private static class ResourcelessTransaction {
79 
80                private boolean active = false;
81 
82                public boolean isActive() {
83                        return active;
84                }
85 
86                public void begin() {
87                        active = true;
88                }
89 
90                public void clear() {
91                        active = false;
92                }
93 
94        }
95 
96}

[all classes][org.springframework.batch.support.transaction]
EMMA 2.0.5312 (C) Vladimir Roubtsov