EMMA Coverage Report (generated Fri Aug 21 15:59:46 BST 2009)
[all classes][org.springframework.batch.core.repository.dao]

COVERAGE SUMMARY FOR SOURCE FILE [MapExecutionContextDao.java]

nameclass, %method, %block, %line, %
MapExecutionContextDao.java100% (1/1)100% (10/10)100% (58/58)100% (19/19)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MapExecutionContextDao100% (1/1)100% (10/10)100% (58/58)100% (19/19)
<static initializer> 100% (1/1)100% (5/5)100% (5/5)
MapExecutionContextDao (): void 100% (1/1)100% (3/3)100% (1/1)
clear (): void 100% (1/1)100% (5/5)100% (3/3)
copy (ExecutionContext): ExecutionContext 100% (1/1)100% (5/5)100% (1/1)
getExecutionContext (JobExecution): ExecutionContext 100% (1/1)100% (7/7)100% (1/1)
getExecutionContext (StepExecution): ExecutionContext 100% (1/1)100% (7/7)100% (1/1)
saveExecutionContext (JobExecution): void 100% (1/1)100% (4/4)100% (2/2)
saveExecutionContext (StepExecution): void 100% (1/1)100% (4/4)100% (2/2)
updateExecutionContext (JobExecution): void 100% (1/1)100% (9/9)100% (2/2)
updateExecutionContext (StepExecution): void 100% (1/1)100% (9/9)100% (2/2)

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.core.repository.dao;
18 
19import java.util.Map;
20 
21import org.apache.commons.lang.SerializationUtils;
22import org.springframework.batch.core.JobExecution;
23import org.springframework.batch.core.StepExecution;
24import org.springframework.batch.item.ExecutionContext;
25import org.springframework.batch.support.transaction.TransactionAwareProxyFactory;
26 
27/**
28 * In-memory implementation of {@link ExecutionContextDao} backed by static
29 * maps.
30 *
31 * @author Robert Kasanicky
32 */
33public class MapExecutionContextDao implements ExecutionContextDao {
34 
35        private static Map<Long, ExecutionContext> contextsByStepExecutionId = TransactionAwareProxyFactory
36                        .createTransactionalMap();
37 
38        private static Map<Long, ExecutionContext> contextsByJobExecutionId = TransactionAwareProxyFactory
39                        .createTransactionalMap();
40 
41        public static void clear() {
42                contextsByJobExecutionId.clear();
43                contextsByStepExecutionId.clear();
44        }
45 
46        private static ExecutionContext copy(ExecutionContext original) {
47                return (ExecutionContext) SerializationUtils.deserialize(SerializationUtils.serialize(original));
48        }
49 
50        public ExecutionContext getExecutionContext(StepExecution stepExecution) {
51                return copy(contextsByStepExecutionId.get(stepExecution.getId()));
52        }
53 
54        public void updateExecutionContext(StepExecution stepExecution) {
55                contextsByStepExecutionId.put(stepExecution.getId(), copy(stepExecution.getExecutionContext()));
56        }
57 
58        public ExecutionContext getExecutionContext(JobExecution jobExecution) {
59                return copy(contextsByJobExecutionId.get(jobExecution.getId()));
60        }
61 
62        public void updateExecutionContext(JobExecution jobExecution) {
63                contextsByJobExecutionId.put(jobExecution.getId(), copy(jobExecution.getExecutionContext()));
64        }
65 
66        public void saveExecutionContext(JobExecution jobExecution) {
67                updateExecutionContext(jobExecution);
68        }
69 
70        public void saveExecutionContext(StepExecution stepExecution) {
71                updateExecutionContext(stepExecution);
72        }
73 
74}

[all classes][org.springframework.batch.core.repository.dao]
EMMA 2.0.5312 (C) Vladimir Roubtsov