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

COVERAGE SUMMARY FOR SOURCE FILE [TaskletAdapter.java]

nameclass, %method, %block, %line, %
TaskletAdapter.java100% (1/1)100% (3/3)100% (16/16)100% (5/5)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TaskletAdapter100% (1/1)100% (3/3)100% (16/16)100% (5/5)
TaskletAdapter (): void 100% (1/1)100% (3/3)100% (1/1)
execute (): ExitStatus 100% (1/1)100% (5/5)100% (1/1)
mapResult (Object): ExitStatus 100% (1/1)100% (8/8)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 */
16package org.springframework.batch.core.step.tasklet;
17 
18import org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator;
19import org.springframework.batch.repeat.ExitStatus;
20 
21/**
22 * A {@link Tasklet} that wraps a method in a POJO. By default the return value
23 * is {@link ExitStatus#FINISHED} unless the delegate POJO itself returns an
24 * {@link ExitStatus}. The POJO method is usually going to have no arguments,
25 * but a static argument or array of arguments can be used by setting the
26 * arguments property.
27 * 
28 * @see AbstractMethodInvokingDelegator
29 * 
30 * @author Dave Syer
31 * 
32 */
33public class TaskletAdapter extends AbstractMethodInvokingDelegator implements Tasklet {
34 
35        /**
36         * Delegate execution to the target object and translate the return value to
37         * an {@link ExitStatus} by invoking a method in the delegate POJO.
38         * 
39         * @see org.springframework.batch.core.step.tasklet.Tasklet#execute()
40         */
41        public ExitStatus execute() throws Exception {
42                return mapResult(invokeDelegateMethod());
43        }
44 
45        /**
46         * If the result is an {@link ExitStatus} already just return that,
47         * otherwise return {@link ExitStatus#FINISHED}.
48         * 
49         * @param result the value returned by the delegate method
50         * @return an {@link ExitStatus} consistent with the result
51         */
52        protected ExitStatus mapResult(Object result) {
53                if (result instanceof ExitStatus) {
54                        return (ExitStatus) result;
55                }
56                return ExitStatus.FINISHED;
57        }
58 
59}

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