EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.core.listener]

COVERAGE SUMMARY FOR SOURCE FILE [StepListenerMetaData.java]

nameclass, %method, %block, %line, %
StepListenerMetaData.java100% (1/1)85%  (11/13)96%  (492/512)97%  (37/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StepListenerMetaData100% (1/1)85%  (11/13)96%  (492/512)97%  (37/38)
taskletListenerMetaData (): ListenerMetaData [] 0%   (0/1)0%   (0/15)0%   (0/1)
valueOf (String): StepListenerMetaData 0%   (0/1)0%   (0/5)0%   (0/1)
<static initializer> 100% (1/1)100% (386/386)100% (22/22)
StepListenerMetaData (String, int, String, String, Class, Class, Class []): void 100% (1/1)100% (20/20)100% (7/7)
fromPropertyName (String): StepListenerMetaData 100% (1/1)100% (5/5)100% (1/1)
getAnnotation (): Class 100% (1/1)100% (3/3)100% (1/1)
getListenerInterface (): Class 100% (1/1)100% (3/3)100% (1/1)
getMethodName (): String 100% (1/1)100% (3/3)100% (1/1)
getParamTypes (): Class [] 100% (1/1)100% (3/3)100% (1/1)
getPropertyName (): String 100% (1/1)100% (3/3)100% (1/1)
itemListenerMetaData (): ListenerMetaData [] 100% (1/1)100% (51/51)100% (1/1)
stepExecutionListenerMetaData (): ListenerMetaData [] 100% (1/1)100% (11/11)100% (1/1)
values (): StepListenerMetaData [] 100% (1/1)100% (4/4)100% (1/1)

1/*
2 * Copyright 2002-2013 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.listener;
17 
18import java.lang.annotation.Annotation;
19import java.util.HashMap;
20import java.util.List;
21import java.util.Map;
22 
23import org.springframework.batch.core.ChunkListener;
24import org.springframework.batch.core.ItemProcessListener;
25import org.springframework.batch.core.ItemReadListener;
26import org.springframework.batch.core.ItemWriteListener;
27import org.springframework.batch.core.SkipListener;
28import org.springframework.batch.core.StepExecution;
29import org.springframework.batch.core.StepExecutionListener;
30import org.springframework.batch.core.StepListener;
31import org.springframework.batch.core.annotation.AfterChunk;
32import org.springframework.batch.core.annotation.AfterChunkError;
33import org.springframework.batch.core.annotation.AfterProcess;
34import org.springframework.batch.core.annotation.AfterRead;
35import org.springframework.batch.core.annotation.AfterStep;
36import org.springframework.batch.core.annotation.AfterWrite;
37import org.springframework.batch.core.annotation.BeforeChunk;
38import org.springframework.batch.core.annotation.BeforeProcess;
39import org.springframework.batch.core.annotation.BeforeRead;
40import org.springframework.batch.core.annotation.BeforeStep;
41import org.springframework.batch.core.annotation.BeforeWrite;
42import org.springframework.batch.core.annotation.OnProcessError;
43import org.springframework.batch.core.annotation.OnReadError;
44import org.springframework.batch.core.annotation.OnSkipInProcess;
45import org.springframework.batch.core.annotation.OnSkipInRead;
46import org.springframework.batch.core.annotation.OnSkipInWrite;
47import org.springframework.batch.core.annotation.OnWriteError;
48import org.springframework.batch.core.scope.context.ChunkContext;
49 
50/**
51 * Enumeration for {@link StepListener} meta data, which ties together the names
52 * of methods, their interfaces, annotation, and expected arguments.
53 *
54 * @author Lucas Ward
55 * @since 2.0
56 * @see StepListenerFactoryBean
57 */
58public enum StepListenerMetaData implements ListenerMetaData {
59 
60        BEFORE_STEP("beforeStep", "before-step-method", BeforeStep.class, StepExecutionListener.class, StepExecution.class),
61        AFTER_STEP("afterStep", "after-step-method", AfterStep.class, StepExecutionListener.class, StepExecution.class),
62        BEFORE_CHUNK("beforeChunk", "before-chunk-method", BeforeChunk.class, ChunkListener.class, ChunkContext.class),
63        AFTER_CHUNK("afterChunk", "after-chunk-method", AfterChunk.class, ChunkListener.class, ChunkContext.class),
64        AFTER_CHUNK_ERROR("afterChunkError", "after-chunk-error-method", AfterChunkError.class, ChunkListener.class, ChunkContext.class),
65        BEFORE_READ("beforeRead", "before-read-method", BeforeRead.class, ItemReadListener.class),
66        AFTER_READ("afterRead", "after-read-method", AfterRead.class, ItemReadListener.class, Object.class),
67        ON_READ_ERROR("onReadError", "on-read-error-method", OnReadError.class, ItemReadListener.class, Exception.class),
68        BEFORE_PROCESS("beforeProcess", "before-process-method", BeforeProcess.class, ItemProcessListener.class, Object.class),
69        AFTER_PROCESS("afterProcess", "after-process-method", AfterProcess.class, ItemProcessListener.class, Object.class, Object.class),
70        ON_PROCESS_ERROR("onProcessError", "on-process-error-method", OnProcessError.class, ItemProcessListener.class, Object.class, Exception.class),
71        BEFORE_WRITE("beforeWrite", "before-write-method", BeforeWrite.class, ItemWriteListener.class, List.class),
72        AFTER_WRITE("afterWrite", "after-write-method", AfterWrite.class, ItemWriteListener.class, List.class),
73        ON_WRITE_ERROR("onWriteError", "on-write-error-method", OnWriteError.class, ItemWriteListener.class, Exception.class, List.class),
74        ON_SKIP_IN_READ("onSkipInRead", "on-skip-in-read-method", OnSkipInRead.class, SkipListener.class, Throwable.class),
75        ON_SKIP_IN_PROCESS("onSkipInProcess", "on-skip-in-process-method", OnSkipInProcess.class, SkipListener.class, Object.class, Throwable.class),
76        ON_SKIP_IN_WRITE("onSkipInWrite", "on-skip-in-write-method", OnSkipInWrite.class, SkipListener.class, Object.class, Throwable.class);
77 
78        private final String methodName;
79        private final String propertyName;
80        private final Class<? extends Annotation> annotation;
81        private final Class<? extends StepListener> listenerInterface;
82        private final Class<?>[] paramTypes;
83        private static final Map<String, StepListenerMetaData> propertyMap;
84 
85        StepListenerMetaData(String methodName, String propertyName, Class<? extends Annotation> annotation, Class<? extends StepListener> listenerInterface, Class<?>... paramTypes) {
86                this.methodName = methodName;
87                this.propertyName = propertyName;
88                this.annotation = annotation;
89                this.listenerInterface = listenerInterface;
90                this.paramTypes = paramTypes;
91        }
92 
93        static{
94                propertyMap = new HashMap<String, StepListenerMetaData>();
95                for(StepListenerMetaData metaData : values()){
96                        propertyMap.put(metaData.getPropertyName(), metaData);
97                }
98        }
99 
100        @Override
101        public String getMethodName() {
102                return methodName;
103        }
104 
105        @Override
106        public Class<? extends Annotation> getAnnotation() {
107                return annotation;
108        }
109 
110        @Override
111        public Class<?> getListenerInterface() {
112                return listenerInterface;
113        }
114 
115        @Override
116        public Class<?>[] getParamTypes() {
117                return paramTypes;
118        }
119 
120        @Override
121        public String getPropertyName() {
122                return propertyName;
123        }
124 
125        /**
126         * Return the relevant meta data for the provided property name.
127         *
128         * @param propertyName
129         * @return meta data with supplied property name, null if none exists.
130         */
131        public static StepListenerMetaData fromPropertyName(String propertyName){
132                return propertyMap.get(propertyName);
133        }
134 
135        public static ListenerMetaData[] itemListenerMetaData() {
136                return new ListenerMetaData[] {BEFORE_WRITE, AFTER_WRITE, ON_WRITE_ERROR, BEFORE_PROCESS, AFTER_PROCESS, ON_PROCESS_ERROR, BEFORE_READ, AFTER_READ, ON_READ_ERROR, ON_SKIP_IN_WRITE, ON_SKIP_IN_PROCESS, ON_SKIP_IN_READ};
137        }
138 
139        public static ListenerMetaData[] stepExecutionListenerMetaData() {
140                return new ListenerMetaData[] {BEFORE_STEP, AFTER_STEP};
141        }
142 
143        public static ListenerMetaData[] taskletListenerMetaData() {
144                return new ListenerMetaData[] {BEFORE_CHUNK, AFTER_CHUNK, AFTER_CHUNK_ERROR};
145        }
146 
147}

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