EMMA Coverage Report (generated Fri Aug 21 15:59:46 BST 2009)
[all classes][org.springframework.batch.core.listener]

COVERAGE SUMMARY FOR SOURCE FILE [StepListenerMetaData.java]

nameclass, %method, %block, %line, %
StepListenerMetaData.java100% (1/1)90%  (9/10)99%  (414/419)99%  (33.8/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StepListenerMetaData100% (1/1)90%  (9/10)99%  (414/419)99%  (33.8/34)
valueOf (String): StepListenerMetaData 0%   (0/1)0%   (0/5)0%   (0/1)
<static initializer> 100% (1/1)100% (358/358)100% (20/20)
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)
values (): StepListenerMetaData [] 100% (1/1)100% (16/16)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, 
83                        Class<? extends StepListener> listenerInterface, Class<?>... paramTypes) {
84                this.methodName = methodName;
85                this.propertyName = propertyName;
86                this.annotation = annotation;
87                this.listenerInterface = listenerInterface;
88                this.paramTypes = paramTypes;
89        }
90        
91        static{
92                propertyMap = new HashMap<String, StepListenerMetaData>();
93                for(StepListenerMetaData metaData : values()){
94                        propertyMap.put(metaData.getPropertyName(), metaData);
95                }
96        }
97 
98        public String getMethodName() {
99                return methodName;
100        }
101 
102        public Class<? extends Annotation> getAnnotation() {
103                return annotation;
104        }
105 
106        public Class<?> getListenerInterface() {
107                return listenerInterface;
108        }
109 
110        public Class<?>[] getParamTypes() {
111                return paramTypes;
112        }
113        
114        public String getPropertyName() {
115                return propertyName;
116        }
117        
118        /**
119         * Return the relevant meta data for the provided property name.
120         * 
121         * @param propertyName
122         * @return meta data with supplied property name, null if none exists.
123         */
124        public static StepListenerMetaData fromPropertyName(String propertyName){
125                return propertyMap.get(propertyName);
126        }
127}

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