EMMA Coverage Report (generated Fri Jan 30 13:20:29 EST 2009)
[all classes][org.springframework.batch.retry.support]

COVERAGE SUMMARY FOR SOURCE FILE [RetrySynchronizationManager.java]

nameclass, %method, %block, %line, %
RetrySynchronizationManager.java100% (1/1)80%  (4/5)91%  (32/35)91%  (10/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RetrySynchronizationManager100% (1/1)80%  (4/5)91%  (32/35)91%  (10/11)
RetrySynchronizationManager (): void 0%   (0/1)0%   (0/3)0%   (0/1)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
clear (): RetryContext 100% (1/1)100% (14/14)100% (4/4)
getContext (): RetryContext 100% (1/1)100% (6/6)100% (2/2)
register (RetryContext): RetryContext 100% (1/1)100% (7/7)100% (3/3)

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.retry.support;
18 
19import org.springframework.batch.repeat.RepeatOperations;
20import org.springframework.batch.retry.RetryCallback;
21import org.springframework.batch.retry.RetryContext;
22import org.springframework.batch.retry.RetryOperations;
23 
24/**
25 * Global variable support for retry clients. Normally it is not necessary for
26 * clients to be aware of the surrounding environment because a
27 * {@link RetryCallback} can always use the context it is passed by the
28 * enclosing {@link RetryOperations}. But occasionally it might be helpful to
29 * have lower level access to the ongoing {@link RetryContext} so we provide a
30 * global accessor here. The mutator methods ({@link #clear()} and
31 * {@link #register(RetryContext)} should not be used except internally by
32 * {@link RetryOperations} implementations.
33 * 
34 * @author Dave Syer
35 * 
36 */
37public class RetrySynchronizationManager {
38 
39        private RetrySynchronizationManager() {}
40 
41        private static final ThreadLocal context = new ThreadLocal();
42 
43        /**
44         * Public accessor for the locally enclosing {@link RetryContext}.
45         * 
46         * @return the current retry context, or null if there isn't one
47         */
48        public static RetryContext getContext() {
49                RetryContext result = (RetryContext) context.get();
50                return result;
51        }
52 
53        /**
54         * Method for registering a context - should only be used by
55         * {@link RetryOperations} implementations to ensure that
56         * {@link #getContext()} always returns the correct value.
57         * 
58         * @param context the new context to register
59         * @return the old context if there was one
60         */
61        public static RetryContext register(RetryContext context) {
62                RetryContext oldContext = getContext();
63                RetrySynchronizationManager.context.set(context);
64                return oldContext;
65        }
66 
67        /**
68         * Clear the current context at the end of a batch - should only be used by
69         * {@link RepeatOperations} implementations.
70         * 
71         * @return the old value if there was one.
72         */
73        public static RetryContext clear() {
74                RetryContext value = getContext();
75                RetryContext parent = value == null ? null : value.getParent();
76                RetrySynchronizationManager.context.set(parent);
77                return value;
78        }
79 
80}

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