001/* 002 * Copyright 2006-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.springframework.batch.core.listener; 017 018import java.util.List; 019 020import org.springframework.batch.core.ItemProcessListener; 021import org.springframework.batch.core.ItemReadListener; 022import org.springframework.batch.core.ItemWriteListener; 023import org.springframework.lang.Nullable; 024 025/** 026 * Basic no-op implementation of the {@link ItemReadListener}, 027 * {@link ItemProcessListener}, and {@link ItemWriteListener} interfaces. All 028 * are implemented, since it is very common that all may need to be implemented 029 * at once. 030 * 031 * @author Lucas Ward 032 * @author Mahmoud Ben Hassine 033 * 034 */ 035public class ItemListenerSupport<I, O> implements ItemReadListener<I>, ItemProcessListener<I, O>, ItemWriteListener<O> { 036 037 /* 038 * (non-Javadoc) 039 * 040 * @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object) 041 */ 042 @Override 043 public void afterRead(I item) { 044 } 045 046 /* 047 * (non-Javadoc) 048 * 049 * @see org.springframework.batch.core.domain.ItemReadListener#beforeRead() 050 */ 051 @Override 052 public void beforeRead() { 053 } 054 055 /* 056 * (non-Javadoc) 057 * 058 * @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception) 059 */ 060 @Override 061 public void onReadError(Exception ex) { 062 } 063 064 /* 065 * (non-Javadoc) 066 * 067 * @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, 068 * java.lang.Object) 069 */ 070 @Override 071 public void afterProcess(I item, @Nullable O result) { 072 } 073 074 /* 075 * (non-Javadoc) 076 * 077 * @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object) 078 */ 079 @Override 080 public void beforeProcess(I item) { 081 } 082 083 /* 084 * (non-Javadoc) 085 * 086 * @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, 087 * java.lang.Exception) 088 */ 089 @Override 090 public void onProcessError(I item, Exception e) { 091 } 092 093 /* 094 * (non-Javadoc) 095 * 096 * @see org.springframework.batch.core.domain.ItemWriteListener#afterWrite() 097 */ 098 @Override 099 public void afterWrite(List<? extends O> item) { 100 } 101 102 /* 103 * (non-Javadoc) 104 * 105 * @see org.springframework.batch.core.domain.ItemWriteListener#beforeWrite(java.lang.Object) 106 */ 107 @Override 108 public void beforeWrite(List<? extends O> item) { 109 } 110 111 /* 112 * (non-Javadoc) 113 * 114 * @see org.springframework.batch.core.domain.ItemWriteListener#onWriteError(java.lang.Exception, 115 * java.lang.Object) 116 */ 117 @Override 118 public void onWriteError(Exception ex, List<? extends O> item) { 119 } 120}