EMMA Coverage Report (generated Tue May 06 07:29:23 PDT 2008)
[all classes][org.springframework.batch.core.step]

COVERAGE SUMMARY FOR SOURCE FILE [ThreadStepInterruptionPolicy.java]

nameclass, %method, %block, %line, %
ThreadStepInterruptionPolicy.java100% (1/1)100% (4/4)98%  (40/41)99%  (8.9/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ThreadStepInterruptionPolicy100% (1/1)100% (4/4)98%  (40/41)99%  (8.9/9)
<static initializer> 100% (1/1)91%  (10/11)90%  (0.9/1)
ThreadStepInterruptionPolicy (): void 100% (1/1)100% (3/3)100% (1/1)
checkInterrupted (StepExecution): void 100% (1/1)100% (10/10)100% (3/3)
isInterrupted (StepExecution): boolean 100% (1/1)100% (17/17)100% (4/4)

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.step;
18 
19import org.apache.commons.logging.Log;
20import org.apache.commons.logging.LogFactory;
21import org.springframework.batch.core.JobInterruptedException;
22import org.springframework.batch.core.StepExecution;
23 
24/**
25 * Policy that checks the current thread to see if it has been interrupted.
26 * 
27 * @author Lucas Ward
28 * @author Dave Syer
29 * 
30 */
31public class ThreadStepInterruptionPolicy implements StepInterruptionPolicy {
32 
33        protected static final Log logger = LogFactory
34        .getLog(ThreadStepInterruptionPolicy.class);
35 
36        
37        /**
38         * Returns if the current job lifecycle has been interrupted by checking if
39         * the current thread is interrupted.
40         */
41        public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException {
42 
43                if (isInterrupted(stepExecution)) {
44                        throw new JobInterruptedException("Job interrupted status detected.");
45                }
46                
47        }
48 
49        /**
50         * @param stepExecution the current context
51         * @return true if the job has been interrupted
52         */
53        private boolean isInterrupted(StepExecution stepExecution) {
54                boolean interrupted = (Thread.currentThread().isInterrupted() || stepExecution.isTerminateOnly());
55                if(interrupted){
56                        logger.error("Step interrupted");
57                }
58                return interrupted;
59        }
60 
61}

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