RESOLVED - issue BATCH-506: JobListener is not a BatchListener
Changed BatchListener to StepListener and renamed existing Job/StepListener as *ExecutionListener.
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
/**
|
||||
* Marker interface that acts as a parent to all Batch
|
||||
* domain listeners, such as: {@link StepListener},
|
||||
* {@link ChunkListener}, {@link ItemReadListener} and
|
||||
* {@link ItemWriteListener}
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public interface BatchListener {
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ package org.springframework.batch.core;
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public interface ChunkListener extends BatchListener {
|
||||
public interface ChunkListener extends StepListener {
|
||||
|
||||
/**
|
||||
* Callback before the chunk is executed, but inside the transaction.
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public interface ItemReadListener extends BatchListener {
|
||||
public interface ItemReadListener extends StepListener {
|
||||
|
||||
/**
|
||||
* Called before {@link ItemReader#read()}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public interface ItemWriteListener extends BatchListener {
|
||||
public interface ItemWriteListener extends StepListener {
|
||||
|
||||
/**
|
||||
* Called before {@link ItemWriter#write(Object)}
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.springframework.batch.core;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface JobListener {
|
||||
public interface JobExecutionListener {
|
||||
|
||||
/**
|
||||
* Initialise the state of the listener with the {@link JobExecution} from
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* Listener interface for the lifecycle of a {@link Step}.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface StepExecutionListener extends StepListener {
|
||||
|
||||
/**
|
||||
* Initialise the state of the listener with the {@link StepExecution} from
|
||||
* the current scope.
|
||||
* @param stepExecution
|
||||
*/
|
||||
void beforeStep(StepExecution stepExecution);
|
||||
|
||||
/**
|
||||
* The value returned will be combined with the normal exit status using
|
||||
* {@link ExitStatus#and(ExitStatus)}.
|
||||
*
|
||||
* @param e an exception thrown by the step execution
|
||||
*
|
||||
* @return an exit status to be combined with the normal one, or null
|
||||
*/
|
||||
ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e);
|
||||
|
||||
/**
|
||||
* Give a listener a chance to modify the exit status from a step. The value
|
||||
* returned will be combined with the normal exit status using
|
||||
* {@link ExitStatus#and(ExitStatus)}.
|
||||
*
|
||||
* @return an {@link ExitStatus} to combine with the normal value. Return
|
||||
* null to leave the old value unchanged.
|
||||
*/
|
||||
ExitStatus afterStep(StepExecution stepExecution);
|
||||
}
|
||||
@@ -15,41 +15,16 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* Listener interface for the lifecycle of a {@link Step}.
|
||||
* Marker interface that acts as a parent to all step
|
||||
* domain listeners, such as: {@link StepExecutionListener},
|
||||
* {@link ChunkListener}, {@link ItemReadListener} and
|
||||
* {@link ItemWriteListener}
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface StepListener extends BatchListener {
|
||||
public interface StepListener {
|
||||
|
||||
/**
|
||||
* Initialise the state of the listener with the {@link StepExecution} from
|
||||
* the current scope.
|
||||
* @param stepExecution
|
||||
*/
|
||||
void beforeStep(StepExecution stepExecution);
|
||||
|
||||
/**
|
||||
* The value returned will be combined with the normal exit status using
|
||||
* {@link ExitStatus#and(ExitStatus)}.
|
||||
*
|
||||
* @param e an exception thrown by the step execution
|
||||
*
|
||||
* @return an exit status to be combined with the normal one, or null
|
||||
*/
|
||||
ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e);
|
||||
|
||||
/**
|
||||
* Give a listener a chance to modify the exit status from a step. The value
|
||||
* returned will be combined with the normal exit status using
|
||||
* {@link ExitStatus#and(ExitStatus)}.
|
||||
*
|
||||
* @return an {@link ExitStatus} to combine with the normal value. Return
|
||||
* null to leave the old value unchanged.
|
||||
*/
|
||||
ExitStatus afterStep(StepExecution stepExecution);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobExecutionException;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
import org.springframework.batch.core.JobListener;
|
||||
import org.springframework.batch.core.JobExecutionListener;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.CompositeJobListener;
|
||||
import org.springframework.batch.core.listener.CompositeExecutionJobListener;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
@@ -47,26 +47,26 @@ public class SimpleJob extends AbstractJob {
|
||||
|
||||
private JobRepository jobRepository;
|
||||
|
||||
private CompositeJobListener listener = new CompositeJobListener();
|
||||
private CompositeExecutionJobListener listener = new CompositeExecutionJobListener();
|
||||
|
||||
/**
|
||||
* Public setter for injecting {@link JobListener}s. They will all be given
|
||||
* the {@link JobListener} callbacks at the appropriate point in the job.
|
||||
* Public setter for injecting {@link JobExecutionListener}s. They will all be given
|
||||
* the {@link JobExecutionListener} callbacks at the appropriate point in the job.
|
||||
*
|
||||
* @param listeners the listeners to set.
|
||||
*/
|
||||
public void setJobListeners(JobListener[] listeners) {
|
||||
public void setJobListeners(JobExecutionListener[] listeners) {
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
this.listener.register(listeners[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a single listener for the {@link JobListener} callbacks.
|
||||
* Register a single listener for the {@link JobExecutionListener} callbacks.
|
||||
*
|
||||
* @param listener a {@link JobListener}
|
||||
* @param listener a {@link JobExecutionListener}
|
||||
*/
|
||||
public void registerListener(JobListener listener) {
|
||||
public void registerListener(JobExecutionListener listener) {
|
||||
this.listener.register(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import org.springframework.batch.core.BatchListener;
|
||||
import org.springframework.batch.core.ChunkListener;
|
||||
import org.springframework.batch.core.ItemReadListener;
|
||||
import org.springframework.batch.core.ItemWriteListener;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* Basic no-op implementations of all {@link BatchListener} implementations.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class BatchListenerSupport implements StepListener, ChunkListener,
|
||||
ItemReadListener, ItemWriteListener {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#afterStep(StepExecution stepExecution)
|
||||
*/
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#beforeStep(org.springframework.batch.core.domain.StepExecution)
|
||||
*/
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#onErrorInStep(java.lang.Throwable)
|
||||
*/
|
||||
public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ChunkListener#afterChunk()
|
||||
*/
|
||||
public void afterChunk() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ChunkListener#beforeChunk()
|
||||
*/
|
||||
public void beforeChunk() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object)
|
||||
*/
|
||||
public void afterRead(Object item) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#beforeRead()
|
||||
*/
|
||||
public void beforeRead() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception)
|
||||
*/
|
||||
public void onReadError(Exception ex) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemWriteListener#afterWrite()
|
||||
*/
|
||||
public void afterWrite(Object item) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemWriteListener#beforeWrite(java.lang.Object)
|
||||
*/
|
||||
public void beforeWrite(Object item) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemWriteListener#onWriteError(java.lang.Exception, java.lang.Object)
|
||||
*/
|
||||
public void onWriteError(Exception ex, Object item) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,13 +21,13 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobListener;
|
||||
import org.springframework.batch.core.JobExecutionListener;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class CompositeJobListener implements JobListener {
|
||||
public class CompositeExecutionJobListener implements JobExecutionListener {
|
||||
|
||||
private List listeners = new ArrayList();
|
||||
|
||||
@@ -36,38 +36,38 @@ public class CompositeJobListener implements JobListener {
|
||||
*
|
||||
* @param listeners
|
||||
*/
|
||||
public void setListeners(JobListener[] listeners) {
|
||||
public void setListeners(JobExecutionListener[] listeners) {
|
||||
this.listeners = Arrays.asList(listeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register additional listener.
|
||||
*
|
||||
* @param jobListener
|
||||
* @param jobExecutionListener
|
||||
*/
|
||||
public void register(JobListener jobListener) {
|
||||
if (!listeners.contains(jobListener)) {
|
||||
listeners.add(jobListener);
|
||||
public void register(JobExecutionListener jobExecutionListener) {
|
||||
if (!listeners.contains(jobExecutionListener)) {
|
||||
listeners.add(jobExecutionListener);
|
||||
}
|
||||
}
|
||||
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
for (Iterator iterator = listeners.listIterator(); iterator.hasNext();) {
|
||||
JobListener listener = (JobListener) iterator.next();
|
||||
JobExecutionListener listener = (JobExecutionListener) iterator.next();
|
||||
listener.afterJob(jobExecution);
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeJob(JobExecution jobExecution) {
|
||||
for (Iterator iterator = listeners.listIterator(); iterator.hasNext();) {
|
||||
JobListener listener = (JobListener) iterator.next();
|
||||
JobExecutionListener listener = (JobExecutionListener) iterator.next();
|
||||
listener.beforeJob(jobExecution);
|
||||
}
|
||||
}
|
||||
|
||||
public void onError(JobExecution jobExecution, Throwable e) {
|
||||
for (Iterator iterator = listeners.listIterator(); iterator.hasNext();) {
|
||||
JobListener listener = (JobListener) iterator.next();
|
||||
JobExecutionListener listener = (JobExecutionListener) iterator.next();
|
||||
listener.onError(jobExecution, e);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CompositeJobListener implements JobListener {
|
||||
|
||||
public void onInterrupt(JobExecution jobExecution) {
|
||||
for (Iterator iterator = listeners.listIterator(); iterator.hasNext();) {
|
||||
JobListener listener = (JobListener) iterator.next();
|
||||
JobExecutionListener listener = (JobExecutionListener) iterator.next();
|
||||
listener.onInterrupt(jobExecution);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,15 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class CompositeStepListener implements StepListener {
|
||||
public class CompositeStepExecutionListener implements StepExecutionListener {
|
||||
|
||||
private List listeners = new ArrayList();
|
||||
|
||||
@@ -37,18 +38,18 @@ public class CompositeStepListener implements StepListener {
|
||||
*
|
||||
* @param listeners
|
||||
*/
|
||||
public void setListeners(StepListener[] listeners) {
|
||||
public void setListeners(StepExecutionListener[] listeners) {
|
||||
this.listeners = Arrays.asList(listeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register additional listener.
|
||||
*
|
||||
* @param stepListener
|
||||
* @param stepExecutionListener
|
||||
*/
|
||||
public void register(StepListener stepListener) {
|
||||
if (!listeners.contains(stepListener)) {
|
||||
listeners.add(stepListener);
|
||||
public void register(StepExecutionListener stepExecutionListener) {
|
||||
if (!listeners.contains(stepExecutionListener)) {
|
||||
listeners.add(stepExecutionListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ public class CompositeStepListener implements StepListener {
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
ExitStatus status = null;
|
||||
for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
|
||||
StepListener listener = (StepListener) iterator.next();
|
||||
StepExecutionListener listener = (StepExecutionListener) iterator.next();
|
||||
ExitStatus close = listener.afterStep(stepExecution);
|
||||
status = status!=null ? status.and(close): close;
|
||||
}
|
||||
@@ -70,7 +71,7 @@ public class CompositeStepListener implements StepListener {
|
||||
*/
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
|
||||
StepListener listener = (StepListener) iterator.next();
|
||||
StepExecutionListener listener = (StepExecutionListener) iterator.next();
|
||||
listener.beforeStep(stepExecution);
|
||||
}
|
||||
}
|
||||
@@ -81,7 +82,7 @@ public class CompositeStepListener implements StepListener {
|
||||
public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) {
|
||||
ExitStatus status = null;
|
||||
for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
|
||||
StepListener listener = (StepListener) iterator.next();
|
||||
StepExecutionListener listener = (StepExecutionListener) iterator.next();
|
||||
ExitStatus close = listener.onErrorInStep(stepExecution, e);
|
||||
status = status!=null ? status.and(close): close;
|
||||
}
|
||||
@@ -16,13 +16,13 @@
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobListener;
|
||||
import org.springframework.batch.core.JobExecutionListener;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class JobListenerSupport implements JobListener {
|
||||
public class JobExecutionListenerSupport implements JobExecutionListener {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.JobListener#afterJob()
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import org.springframework.batch.core.BatchListener;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.ChunkListener;
|
||||
import org.springframework.batch.core.ItemReadListener;
|
||||
import org.springframework.batch.core.ItemWriteListener;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
@@ -28,10 +28,10 @@ import org.springframework.batch.repeat.ExitStatus;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class MulticasterBatchListener implements StepListener, ChunkListener, ItemReadListener,
|
||||
public class MulticasterBatchListener implements StepExecutionListener, ChunkListener, ItemReadListener,
|
||||
ItemWriteListener {
|
||||
|
||||
private CompositeStepListener stepListener = new CompositeStepListener();
|
||||
private CompositeStepExecutionListener stepListener = new CompositeStepExecutionListener();
|
||||
|
||||
private CompositeChunkListener chunkListener = new CompositeChunkListener();
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MulticasterBatchListener implements StepListener, ChunkListener, It
|
||||
* @param listeners an array of listener objects of types known to the
|
||||
* multicaster.
|
||||
*/
|
||||
public void setListeners(BatchListener[] listeners) {
|
||||
public void setListeners(StepListener[] listeners) {
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
register(listeners[i]);
|
||||
}
|
||||
@@ -61,12 +61,12 @@ public class MulticasterBatchListener implements StepListener, ChunkListener, It
|
||||
|
||||
/**
|
||||
* Register the listener for callbacks on the appropriate interfaces
|
||||
* implemented. Any {@link BatchListener} can be provided, or an
|
||||
* implemented. Any {@link StepListener} can be provided, or an
|
||||
* {@link ItemStream}. Other types will be ignored.
|
||||
*/
|
||||
public void register(BatchListener listener) {
|
||||
if (listener instanceof StepListener) {
|
||||
this.stepListener.register((StepListener) listener);
|
||||
public void register(StepListener listener) {
|
||||
if (listener instanceof StepExecutionListener) {
|
||||
this.stepListener.register((StepExecutionListener) listener);
|
||||
}
|
||||
if (listener instanceof ChunkListener) {
|
||||
this.chunkListener.register((ChunkListener) listener);
|
||||
@@ -81,7 +81,7 @@ public class MulticasterBatchListener implements StepListener, ChunkListener, It
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see org.springframework.batch.core.listener.CompositeStepListener#afterStep()
|
||||
* @see org.springframework.batch.core.listener.CompositeStepExecutionListener#afterStep()
|
||||
*/
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return stepListener.afterStep(stepExecution);
|
||||
@@ -89,7 +89,7 @@ public class MulticasterBatchListener implements StepListener, ChunkListener, It
|
||||
|
||||
/**
|
||||
* @param stepExecution
|
||||
* @see org.springframework.batch.core.listener.CompositeStepListener#beforeStep(org.springframework.batch.core.StepExecution)
|
||||
* @see org.springframework.batch.core.listener.CompositeStepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution)
|
||||
*/
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
stepListener.beforeStep(stepExecution);
|
||||
@@ -98,7 +98,7 @@ public class MulticasterBatchListener implements StepListener, ChunkListener, It
|
||||
/**
|
||||
* @param e
|
||||
* @return
|
||||
* @see org.springframework.batch.core.listener.CompositeStepListener#onErrorInStep(java.lang.Throwable)
|
||||
* @see org.springframework.batch.core.listener.CompositeStepExecutionListener#onErrorInStep(java.lang.Throwable)
|
||||
*/
|
||||
public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) {
|
||||
return stepListener.onErrorInStep(stepExecution, e);
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepExecutionListenerSupport implements StepExecutionListener {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#afterStep(StepExecution stepExecution)
|
||||
*/
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#open(org.springframework.batch.item.ExecutionContext)
|
||||
*/
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#onError(java.lang.Throwable)
|
||||
*/
|
||||
public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,15 +15,22 @@
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.ChunkListener;
|
||||
import org.springframework.batch.core.ItemReadListener;
|
||||
import org.springframework.batch.core.ItemWriteListener;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* Basic no-op implementations of all {@link StepListener} implementations.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class StepListenerSupport implements StepListener {
|
||||
public class StepListenerSupport implements StepExecutionListener, ChunkListener,
|
||||
ItemReadListener, ItemWriteListener {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#afterStep(StepExecution stepExecution)
|
||||
@@ -33,15 +40,64 @@ public class StepListenerSupport implements StepListener {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#open(org.springframework.batch.item.ExecutionContext)
|
||||
* @see org.springframework.batch.core.domain.StepListener#beforeStep(org.springframework.batch.core.domain.StepExecution)
|
||||
*/
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#onError(java.lang.Throwable)
|
||||
* @see org.springframework.batch.core.domain.StepListener#onErrorInStep(java.lang.Throwable)
|
||||
*/
|
||||
public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ChunkListener#afterChunk()
|
||||
*/
|
||||
public void afterChunk() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ChunkListener#beforeChunk()
|
||||
*/
|
||||
public void beforeChunk() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object)
|
||||
*/
|
||||
public void afterRead(Object item) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#beforeRead()
|
||||
*/
|
||||
public void beforeRead() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception)
|
||||
*/
|
||||
public void onReadError(Exception ex) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemWriteListener#afterWrite()
|
||||
*/
|
||||
public void afterWrite(Object item) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemWriteListener#beforeWrite(java.lang.Object)
|
||||
*/
|
||||
public void beforeWrite(Object item) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemWriteListener#onWriteError(java.lang.Exception, java.lang.Object)
|
||||
*/
|
||||
public void onWriteError(Exception ex, Object item) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.listener.StepListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.SqlTypeValue;
|
||||
@@ -32,13 +32,13 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link PreparedStatementSetter} interface that also implements
|
||||
* {@link StepListener} and uses {@link JobParameters} to set the parameters on a
|
||||
* {@link StepExecutionListener} and uses {@link JobParameters} to set the parameters on a
|
||||
* PreparedStatement.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class JobParametersPreparedStatementSetter extends StepListenerSupport implements
|
||||
public class JobParametersPreparedStatementSetter extends StepExecutionListenerSupport implements
|
||||
PreparedStatementSetter, InitializingBean {
|
||||
|
||||
private List parameterKeys;
|
||||
|
||||
@@ -27,10 +27,10 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
|
||||
import org.springframework.batch.core.converter.JobParametersConverter;
|
||||
import org.springframework.batch.core.listener.StepListenerSupport;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.core.io.FileSystemResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -67,7 +67,7 @@ import org.springframework.util.StringUtils;
|
||||
* To use this resource it must be initialised with a {@link StepExecution}.
|
||||
* The best way to do that is to register it as a listener in the step that is
|
||||
* going to need it. For this reason the resource implements
|
||||
* {@link StepListener}.
|
||||
* {@link StepExecutionListener}.
|
||||
*
|
||||
* @author Tomas Slanina
|
||||
* @author Lucas Ward
|
||||
@@ -75,8 +75,8 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @see Resource
|
||||
*/
|
||||
public class StepExecutionResourceProxy extends StepListenerSupport implements Resource, ResourceLoaderAware,
|
||||
StepListener {
|
||||
public class StepExecutionResourceProxy extends StepExecutionListenerSupport implements Resource, ResourceLoaderAware,
|
||||
StepExecutionListener {
|
||||
|
||||
private static final String JOB_NAME_PATTERN = "%JOB_NAME%";
|
||||
|
||||
@@ -277,7 +277,7 @@ public class StepExecutionResourceProxy extends StepListenerSupport implements R
|
||||
* Collect the properties of the enclosing {@link StepExecution} that will
|
||||
* be needed to create a file name.
|
||||
*
|
||||
* @see org.springframework.batch.core.StepListener#beforeStep(org.springframework.batch.core.StepExecution)
|
||||
* @see org.springframework.batch.core.StepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution)
|
||||
*/
|
||||
public void beforeStep(StepExecution execution) {
|
||||
String stepName = execution.getStepName();
|
||||
|
||||
@@ -18,11 +18,11 @@ package org.springframework.batch.core.step.item;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.BatchListener;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.ChunkListener;
|
||||
import org.springframework.batch.core.ItemReadListener;
|
||||
import org.springframework.batch.core.ItemWriteListener;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.listener.CompositeChunkListener;
|
||||
import org.springframework.batch.core.listener.CompositeItemReadListener;
|
||||
import org.springframework.batch.core.listener.CompositeItemWriteListener;
|
||||
@@ -49,12 +49,12 @@ class BatchListenerFactoryHelper {
|
||||
* @param listeners
|
||||
* @return
|
||||
*/
|
||||
public ItemReader getItemReader(ItemReader itemReader, BatchListener[] listeners) {
|
||||
public ItemReader getItemReader(ItemReader itemReader, StepListener[] listeners) {
|
||||
|
||||
final CompositeItemReadListener multicaster = new CompositeItemReadListener();
|
||||
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
BatchListener listener = listeners[i];
|
||||
StepListener listener = listeners[i];
|
||||
if (listener instanceof ItemReadListener) {
|
||||
multicaster.register((ItemReadListener) listener);
|
||||
}
|
||||
@@ -83,11 +83,11 @@ class BatchListenerFactoryHelper {
|
||||
* @param listeners
|
||||
* @return
|
||||
*/
|
||||
public ItemWriter getItemWriter(ItemWriter itemWriter, BatchListener[] listeners) {
|
||||
public ItemWriter getItemWriter(ItemWriter itemWriter, StepListener[] listeners) {
|
||||
final CompositeItemWriteListener multicaster = new CompositeItemWriteListener();
|
||||
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
BatchListener listener = listeners[i];
|
||||
StepListener listener = listeners[i];
|
||||
if (listener instanceof ItemWriteListener) {
|
||||
multicaster.register((ItemWriteListener) listener);
|
||||
}
|
||||
@@ -116,14 +116,14 @@ class BatchListenerFactoryHelper {
|
||||
* @param listeners
|
||||
* @return
|
||||
*/
|
||||
public RepeatOperations addChunkListeners(RepeatOperations chunkOperations, BatchListener[] listeners) {
|
||||
public RepeatOperations addChunkListeners(RepeatOperations chunkOperations, StepListener[] listeners) {
|
||||
|
||||
final CompositeChunkListener multicaster = new CompositeChunkListener();
|
||||
|
||||
boolean hasChunkListener = false;
|
||||
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
BatchListener listener = listeners[i];
|
||||
StepListener listener = listeners[i];
|
||||
if (listener instanceof ChunkListener) {
|
||||
hasChunkListener = true;
|
||||
}
|
||||
@@ -158,15 +158,15 @@ class BatchListenerFactoryHelper {
|
||||
* @param listeners
|
||||
* @return
|
||||
*/
|
||||
public StepListener[] getStepListeners(BatchListener[] listeners) {
|
||||
public StepExecutionListener[] getStepListeners(StepListener[] listeners) {
|
||||
List list = new ArrayList();
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
BatchListener listener = listeners[i];
|
||||
if (listener instanceof StepListener) {
|
||||
StepListener listener = listeners[i];
|
||||
if (listener instanceof StepExecutionListener) {
|
||||
list.add(listener);
|
||||
}
|
||||
}
|
||||
return (StepListener[]) list.toArray(new StepListener[list.size()]);
|
||||
return (StepExecutionListener[]) list.toArray(new StepExecutionListener[list.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.UnexpectedJobExecutionException;
|
||||
import org.springframework.batch.core.launch.support.ExitCodeMapper;
|
||||
import org.springframework.batch.core.listener.CompositeStepListener;
|
||||
import org.springframework.batch.core.listener.CompositeStepExecutionListener;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.batch.core.step.AbstractStep;
|
||||
@@ -87,7 +87,7 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
|
||||
private CompositeItemStream stream = new CompositeItemStream();
|
||||
|
||||
private CompositeStepListener listener = new CompositeStepListener();
|
||||
private CompositeStepExecutionListener listener = new CompositeStepExecutionListener();
|
||||
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@@ -168,7 +168,7 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
*
|
||||
* @param listeners an array of listener objects of known types.
|
||||
*/
|
||||
public void setStepListeners(StepListener[] listeners) {
|
||||
public void setStepListeners(StepExecutionListener[] listeners) {
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
registerStepListener(listeners[i]);
|
||||
}
|
||||
@@ -178,9 +178,9 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
* Register a step listener for callbacks at the appropriate stages in a
|
||||
* step execution.
|
||||
*
|
||||
* @param listener a {@link StepListener}
|
||||
* @param listener a {@link StepExecutionListener}
|
||||
*/
|
||||
public void registerStepListener(StepListener listener) {
|
||||
public void registerStepListener(StepExecutionListener listener) {
|
||||
this.listener.register(listener);
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
|
||||
/**
|
||||
* Default mapping from throwable to {@link ExitStatus}. Clients can modify
|
||||
* the exit code using a {@link StepListener}.
|
||||
* the exit code using a {@link StepExecutionListener}.
|
||||
*
|
||||
* @param throwable the cause of teh failure
|
||||
* @return an {@link ExitStatus}
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import org.springframework.batch.core.BatchListener;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
@@ -36,7 +36,7 @@ public class RepeatOperationsStepFactoryBean extends AbstractStepFactoryBean {
|
||||
|
||||
private ItemStream[] streams = new ItemStream[0];
|
||||
|
||||
private BatchListener[] listeners = new BatchListener[0];
|
||||
private StepListener[] listeners = new StepListener[0];
|
||||
|
||||
private RepeatOperations chunkOperations = new RepeatTemplate();
|
||||
|
||||
@@ -55,12 +55,12 @@ public class RepeatOperationsStepFactoryBean extends AbstractStepFactoryBean {
|
||||
|
||||
/**
|
||||
* The listeners to inject into the {@link Step}. Any instance of
|
||||
* {@link BatchListener} can be used, and will then receive callbacks at the
|
||||
* {@link StepListener} can be used, and will then receive callbacks at the
|
||||
* appropriate stage in the step.
|
||||
*
|
||||
* @param listeners an array of listeners
|
||||
*/
|
||||
public void setListeners(BatchListener[] listeners) {
|
||||
public void setListeners(StepListener[] listeners) {
|
||||
this.listeners = listeners;
|
||||
}
|
||||
|
||||
@@ -107,19 +107,19 @@ public class RepeatOperationsStepFactoryBean extends AbstractStepFactoryBean {
|
||||
if (itemReader instanceof ItemStream) {
|
||||
step.registerStream((ItemStream) itemReader);
|
||||
}
|
||||
if (itemReader instanceof StepListener) {
|
||||
step.registerStepListener((StepListener) itemReader);
|
||||
if (itemReader instanceof StepExecutionListener) {
|
||||
step.registerStepListener((StepExecutionListener) itemReader);
|
||||
}
|
||||
if (itemWriter instanceof ItemStream) {
|
||||
step.registerStream((ItemStream) itemWriter);
|
||||
}
|
||||
if (itemWriter instanceof StepListener) {
|
||||
step.registerStepListener((StepListener) itemWriter);
|
||||
if (itemWriter instanceof StepExecutionListener) {
|
||||
step.registerStepListener((StepExecutionListener) itemWriter);
|
||||
}
|
||||
|
||||
BatchListenerFactoryHelper helper = new BatchListenerFactoryHelper();
|
||||
|
||||
StepListener[] stepListeners = helper.getStepListeners(listeners);
|
||||
StepExecutionListener[] stepListeners = helper.getStepListeners(listeners);
|
||||
itemReader = helper.getItemReader(itemReader, listeners);
|
||||
itemWriter = helper.getItemWriter(itemWriter, listeners);
|
||||
RepeatOperations stepOperations = helper.addChunkListeners(this.stepOperations, listeners);
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import org.springframework.batch.core.BatchListener;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.listener.MulticasterBatchListener;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
@@ -47,7 +47,7 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean {
|
||||
|
||||
private ItemStream[] streams = new ItemStream[0];
|
||||
|
||||
private BatchListener[] listeners = new BatchListener[0];
|
||||
private StepListener[] listeners = new StepListener[0];
|
||||
|
||||
private MulticasterBatchListener listener = new MulticasterBatchListener();
|
||||
|
||||
@@ -81,12 +81,12 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean {
|
||||
|
||||
/**
|
||||
* The listeners to inject into the {@link Step}. Any instance of
|
||||
* {@link BatchListener} can be used, and will then receive callbacks at the
|
||||
* {@link StepListener} can be used, and will then receive callbacks at the
|
||||
* appropriate stage in the step.
|
||||
*
|
||||
* @param listeners an array of listeners
|
||||
*/
|
||||
public void setListeners(BatchListener[] listeners) {
|
||||
public void setListeners(StepListener[] listeners) {
|
||||
this.listeners = listeners;
|
||||
}
|
||||
|
||||
@@ -152,9 +152,9 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean {
|
||||
step.setStreams(streams);
|
||||
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
BatchListener listener = listeners[i];
|
||||
if (listener instanceof StepListener) {
|
||||
step.registerStepListener((StepListener) listener);
|
||||
StepListener listener = listeners[i];
|
||||
if (listener instanceof StepExecutionListener) {
|
||||
step.registerStepListener((StepExecutionListener) listener);
|
||||
}
|
||||
else {
|
||||
this.listener.register(listener);
|
||||
@@ -170,14 +170,14 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean {
|
||||
if (itemReader instanceof ItemStream) {
|
||||
step.registerStream((ItemStream) itemReader);
|
||||
}
|
||||
if (itemReader instanceof StepListener) {
|
||||
step.registerStepListener((StepListener) itemReader);
|
||||
if (itemReader instanceof StepExecutionListener) {
|
||||
step.registerStepListener((StepExecutionListener) itemReader);
|
||||
}
|
||||
if (itemWriter instanceof ItemStream) {
|
||||
step.registerStream((ItemStream) itemWriter);
|
||||
}
|
||||
if (itemWriter instanceof StepListener) {
|
||||
step.registerStepListener((StepListener) itemWriter);
|
||||
if (itemWriter instanceof StepExecutionListener) {
|
||||
step.registerStepListener((StepExecutionListener) itemWriter);
|
||||
}
|
||||
|
||||
BatchListenerFactoryHelper helper = new BatchListenerFactoryHelper();
|
||||
@@ -189,7 +189,7 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean {
|
||||
step.setChunkOperations(chunkOperations);
|
||||
}
|
||||
|
||||
StepListener[] stepListeners = helper.getStepListeners(listeners);
|
||||
StepExecutionListener[] stepListeners = helper.getStepListeners(listeners);
|
||||
itemReader = helper.getItemReader(itemReader, listeners);
|
||||
itemWriter = helper.getItemWriter(itemWriter, listeners);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.batch.core.step.tasklet;
|
||||
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
@@ -29,7 +29,7 @@ import org.springframework.batch.repeat.ExitStatus;
|
||||
* stored procedure.<br/>
|
||||
*
|
||||
* Since the batch framework has no visibility inside the {@link #execute()}
|
||||
* method, developers should consider implementing {@link StepListener} and
|
||||
* method, developers should consider implementing {@link StepExecutionListener} and
|
||||
* check the {@link StepExecution#isTerminateOnly()} value for long lasting
|
||||
* processes to enable prompt termination of processing on user request.<br/>
|
||||
*
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.springframework.batch.core.UnexpectedJobExecutionException;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.listener.CompositeStepListener;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.listener.CompositeStepExecutionListener;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.step.AbstractStep;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
@@ -48,7 +48,7 @@ public class TaskletStep extends AbstractStep implements Step, InitializingBean,
|
||||
|
||||
private JobRepository jobRepository;
|
||||
|
||||
private CompositeStepListener listener = new CompositeStepListener();
|
||||
private CompositeStepExecutionListener listener = new CompositeStepExecutionListener();
|
||||
|
||||
/**
|
||||
* Set the name property if it is not already set. Because of the order of
|
||||
@@ -73,7 +73,7 @@ public class TaskletStep extends AbstractStep implements Step, InitializingBean,
|
||||
*
|
||||
* @param listeners an array of listener objects of known types.
|
||||
*/
|
||||
public void setStepListeners(StepListener[] listeners) {
|
||||
public void setStepListeners(StepExecutionListener[] listeners) {
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
this.listener.register(listeners[i]);
|
||||
}
|
||||
@@ -86,8 +86,8 @@ public class TaskletStep extends AbstractStep implements Step, InitializingBean,
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(jobRepository, "JobRepository is mandatory for TaskletStep");
|
||||
Assert.notNull(tasklet, "Tasklet is mandatory for TaskletStep");
|
||||
if (tasklet instanceof StepListener) {
|
||||
listener.register((StepListener) tasklet);
|
||||
if (tasklet instanceof StepExecutionListener) {
|
||||
listener.register((StepExecutionListener) tasklet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user