EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[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)97%  (464/480)97%  (36/37)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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