diff --git a/core/src/main/java/org/springframework/batch/core/executor/StepInterruptedException.java b/core/src/main/java/org/springframework/batch/core/executor/StepInterruptedException.java
index c83622bc4..7d84f6a1a 100644
--- a/core/src/main/java/org/springframework/batch/core/executor/StepInterruptedException.java
+++ b/core/src/main/java/org/springframework/batch/core/executor/StepInterruptedException.java
@@ -16,15 +16,22 @@
package org.springframework.batch.core.executor;
+import org.springframework.batch.io.exception.BatchCriticalException;
+
/**
- * Exception to indicate the the lifecycle has been interrupted.
+ * Exception to indicate the the lifecycle has been interrupted. The exception
+ * state indicated is not normally recoverable by batch application clients, but
+ * internally it is useful to force a check. The exception will be wrapped in a
+ * runtime exception (usually {@link BatchCriticalException} before reaching the
+ * client.
*
* @author Lucas Ward
- *
+ * @author Dave Syer
+ *
*/
public class StepInterruptedException extends Exception {
- public StepInterruptedException(String msg){
+ public StepInterruptedException(String msg) {
super(msg);
}
}
diff --git a/execution/src/main/java/org/springframework/batch/execution/bootstrap/BatchExecutionRequestEvent.java b/execution/src/main/java/org/springframework/batch/execution/bootstrap/BatchExecutionRequestEvent.java
index 3624b9a5b..72829dc09 100644
--- a/execution/src/main/java/org/springframework/batch/execution/bootstrap/BatchExecutionRequestEvent.java
+++ b/execution/src/main/java/org/springframework/batch/execution/bootstrap/BatchExecutionRequestEvent.java
@@ -15,13 +15,12 @@
*/
package org.springframework.batch.execution.bootstrap;
-import org.springframework.batch.execution.facade.JobExecutorFacade;
import org.springframework.batch.repeat.interceptor.RepeatOperationsApplicationEvent;
import org.springframework.context.ApplicationEvent;
/**
* {@link ApplicationEvent} that encodes a request from the execution layer to a
- * running {@link JobExecutorFacade}.
+ * running job.
*
* @author Dave Syer
*
@@ -32,7 +31,7 @@ public class BatchExecutionRequestEvent extends ApplicationEvent {
* Constructor for {@link BatchExecutionRequestEvent}. The source is the
* execution layer service implementation that is sending the signal.
*
- * TODO: the source sould be Serializable so really it should be just a
+ * TODO: the source should be Serializable so really it should be just a
* message about the request?
*
* Currently encodes a request to publish back a
diff --git a/execution/src/main/java/org/springframework/batch/execution/bootstrap/JobExecutionNotificationPublisher.java b/execution/src/main/java/org/springframework/batch/execution/bootstrap/JobExecutionNotificationPublisher.java
index 324d51fae..f728ffffc 100644
--- a/execution/src/main/java/org/springframework/batch/execution/bootstrap/JobExecutionNotificationPublisher.java
+++ b/execution/src/main/java/org/springframework/batch/execution/bootstrap/JobExecutionNotificationPublisher.java
@@ -16,9 +16,10 @@
package org.springframework.batch.execution.bootstrap;
-
import javax.management.Notification;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.springframework.batch.repeat.interceptor.RepeatOperationsApplicationEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
@@ -31,8 +32,11 @@ import org.springframework.jmx.export.notification.NotificationPublisherAware;
* @author Dave Syer
* @since 2.1
*/
-public class JobExecutionNotificationPublisher implements
- ApplicationListener, NotificationPublisherAware {
+public class JobExecutionNotificationPublisher implements ApplicationListener,
+ NotificationPublisherAware {
+
+ protected static final Log logger = LogFactory
+ .getLog(JobExecutionNotificationPublisher.class);
private NotificationPublisher notificationPublisher;
@@ -53,7 +57,7 @@ public class JobExecutionNotificationPublisher implements
* close we log the event at INFO level and send a JMX notification if we
* are also an MBean.
*
- * @see org.springframework.batch.execution.bootstrap.SimpleJobLauncher#onApplicationEvent(org.springframework.context.ApplicationEvent)
+ * @see org.springframework.batch.execution.launch.SimpleJobLauncher#onApplicationEvent(org.springframework.context.ApplicationEvent)
*/
public void onApplicationEvent(ApplicationEvent applicationEvent) {
if (applicationEvent instanceof RepeatOperationsApplicationEvent) {
@@ -64,7 +68,7 @@ public class JobExecutionNotificationPublisher implements
|| type == RepeatOperationsApplicationEvent.ERROR) {
String message = event.getMessage() + "; source="
+ event.getSource();
- SimpleJobLauncher.logger.info(message);
+ logger.info(message);
publish(message);
}
return;
diff --git a/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/BatchCommandLineLauncher.java b/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/BatchCommandLineLauncher.java
index f25fd63a4..3c81959d9 100644
--- a/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/BatchCommandLineLauncher.java
+++ b/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/BatchCommandLineLauncher.java
@@ -20,7 +20,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
import org.springframework.batch.core.executor.ExitCodeExceptionClassifier;
-import org.springframework.batch.execution.bootstrap.JobLauncher;
+import org.springframework.batch.execution.launch.JobLauncher;
import org.springframework.batch.execution.step.simple.SimpleExitCodeExceptionClassifier;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.beans.factory.access.BeanFactoryLocator;
diff --git a/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ExportedJobLauncher.java b/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ExportedJobLauncher.java
index 9a5aece1a..d10d77c14 100644
--- a/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ExportedJobLauncher.java
+++ b/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ExportedJobLauncher.java
@@ -16,7 +16,7 @@
package org.springframework.batch.execution.bootstrap.support;
-import org.springframework.batch.execution.bootstrap.JobLauncher;
+import org.springframework.batch.execution.launch.JobLauncher;
import org.springframework.batch.repeat.ExitStatus;
/**
diff --git a/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ThreadInterruptJobExecutionListener.java b/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ThreadInterruptJobExecutionListener.java
index 8bf99e7bc..97e12007b 100644
--- a/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ThreadInterruptJobExecutionListener.java
+++ b/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ThreadInterruptJobExecutionListener.java
@@ -16,8 +16,8 @@
package org.springframework.batch.execution.bootstrap.support;
import org.springframework.batch.core.domain.JobExecution;
-import org.springframework.batch.execution.facade.JobExecutionListener;
-import org.springframework.batch.execution.facade.JobExecutionListenerSupport;
+import org.springframework.batch.execution.launch.JobExecutionListener;
+import org.springframework.batch.execution.launch.JobExecutionListenerSupport;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.util.Assert;
@@ -42,7 +42,7 @@ public class ThreadInterruptJobExecutionListener extends
* 'processing thread'. If the container has already been started, no
* exception will be thrown.
*
- * @see org.springframework.batch.execution.facade.JobExecutionListenerSupport#before(org.springframework.batch.core.domain.JobExecution)
+ * @see org.springframework.batch.execution.launch.JobExecutionListenerSupport#before(org.springframework.batch.core.domain.JobExecution)
*/
public void before(JobExecution execution) {
Assert.isTrue(running == 0,
@@ -60,7 +60,7 @@ public class ThreadInterruptJobExecutionListener extends
* Interrupt the thread that is running the job if the {@link ExitStatus}
* indicates that it is still running.
*
- * @see org.springframework.batch.execution.facade.JobExecutionListenerSupport#stop(org.springframework.batch.core.domain.JobExecution)
+ * @see org.springframework.batch.execution.launch.JobExecutionListenerSupport#stop(org.springframework.batch.core.domain.JobExecution)
*/
public void stop(JobExecution execution) {
if (execution==null || execution.getExitStatus().isRunning()) {
@@ -71,7 +71,7 @@ public class ThreadInterruptJobExecutionListener extends
/**
* internal housekeeping.
*
- * @see org.springframework.batch.execution.facade.JobExecutionListenerSupport#after(org.springframework.batch.core.domain.JobExecution)
+ * @see org.springframework.batch.execution.launch.JobExecutionListenerSupport#after(org.springframework.batch.core.domain.JobExecution)
*/
public void after(JobExecution execution) {
running--;
diff --git a/execution/src/main/java/org/springframework/batch/execution/facade/JobExecutionListener.java b/execution/src/main/java/org/springframework/batch/execution/launch/JobExecutionListener.java
similarity index 92%
rename from execution/src/main/java/org/springframework/batch/execution/facade/JobExecutionListener.java
rename to execution/src/main/java/org/springframework/batch/execution/launch/JobExecutionListener.java
index e3fbdfa71..65c41e06c 100644
--- a/execution/src/main/java/org/springframework/batch/execution/facade/JobExecutionListener.java
+++ b/execution/src/main/java/org/springframework/batch/execution/launch/JobExecutionListener.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.batch.execution.facade;
+package org.springframework.batch.execution.launch;
import org.springframework.batch.core.domain.JobExecution;
diff --git a/execution/src/main/java/org/springframework/batch/execution/facade/JobExecutionListenerSupport.java b/execution/src/main/java/org/springframework/batch/execution/launch/JobExecutionListenerSupport.java
similarity index 82%
rename from execution/src/main/java/org/springframework/batch/execution/facade/JobExecutionListenerSupport.java
rename to execution/src/main/java/org/springframework/batch/execution/launch/JobExecutionListenerSupport.java
index 7417c25a1..52dfcb22e 100644
--- a/execution/src/main/java/org/springframework/batch/execution/facade/JobExecutionListenerSupport.java
+++ b/execution/src/main/java/org/springframework/batch/execution/launch/JobExecutionListenerSupport.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.batch.execution.facade;
+package org.springframework.batch.execution.launch;
import org.springframework.batch.core.domain.JobExecution;
@@ -29,7 +29,7 @@ public class JobExecutionListenerSupport implements JobExecutionListener {
/**
* No-op for subclasses to extend.
*
- * @see org.springframework.batch.execution.facade.JobExecutionListener#after(org.springframework.batch.core.domain.JobExecution)
+ * @see org.springframework.batch.execution.launch.JobExecutionListener#after(org.springframework.batch.core.domain.JobExecution)
*/
public void after(JobExecution execution) {
// no-op
@@ -38,7 +38,7 @@ public class JobExecutionListenerSupport implements JobExecutionListener {
/**
* No-op for subclasses to extend.
*
- * @see org.springframework.batch.execution.facade.JobExecutionListener#before(org.springframework.batch.core.domain.JobExecution)
+ * @see org.springframework.batch.execution.launch.JobExecutionListener#before(org.springframework.batch.core.domain.JobExecution)
*/
public void before(JobExecution execution) {
// no-op
@@ -47,7 +47,7 @@ public class JobExecutionListenerSupport implements JobExecutionListener {
/**
* No-op for subclasses to extend.
*
- * @see org.springframework.batch.execution.facade.JobExecutionListener#stop(org.springframework.batch.core.domain.JobExecution)
+ * @see org.springframework.batch.execution.launch.JobExecutionListener#stop(org.springframework.batch.core.domain.JobExecution)
*/
public void stop(JobExecution execution) {
// no-op
diff --git a/execution/src/main/java/org/springframework/batch/execution/facade/JobExecutorFacade.java b/execution/src/main/java/org/springframework/batch/execution/launch/JobExecutorFacade.java
similarity index 86%
rename from execution/src/main/java/org/springframework/batch/execution/facade/JobExecutorFacade.java
rename to execution/src/main/java/org/springframework/batch/execution/launch/JobExecutorFacade.java
index 797f093fd..ac20266fb 100644
--- a/execution/src/main/java/org/springframework/batch/execution/facade/JobExecutorFacade.java
+++ b/execution/src/main/java/org/springframework/batch/execution/launch/JobExecutorFacade.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.batch.execution.facade;
+package org.springframework.batch.execution.launch;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
import org.springframework.batch.core.domain.JobIdentifier;
@@ -22,14 +22,13 @@ import org.springframework.batch.repeat.ExitStatus;
/**
* Interface which defines a facade for running jobs. The interface is
- * intentionally minimal, and depends only on simple java types, so that the
- * facade can be used to launch a job from basic environments like a command
- * line or a JMX console. TODO: remove dependency on {@link JobIdentifier}?
+ * intentionally minimal and package private. It is convenient to be able to
+ * test a {@link JobLauncher} with stub implementations of this interface.
*
* @author Lucas Ward
* @author Dave Syer
*/
-public interface JobExecutorFacade {
+interface JobExecutorFacade {
/**
* Start a job execution identifiable by the {@link JobIdentifier}.
diff --git a/execution/src/main/java/org/springframework/batch/execution/bootstrap/JobLauncher.java b/execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java
similarity index 93%
rename from execution/src/main/java/org/springframework/batch/execution/bootstrap/JobLauncher.java
rename to execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java
index ab0845aec..e27070c3f 100644
--- a/execution/src/main/java/org/springframework/batch/execution/bootstrap/JobLauncher.java
+++ b/execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java
@@ -13,11 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.batch.execution.bootstrap;
+package org.springframework.batch.execution.launch;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
import org.springframework.batch.core.domain.JobIdentifier;
-import org.springframework.batch.execution.facade.JobExecutorFacade;
import org.springframework.batch.repeat.ExitStatus;
/**
diff --git a/execution/src/main/java/org/springframework/batch/execution/facade/NoSuchJobExecutionException.java b/execution/src/main/java/org/springframework/batch/execution/launch/NoSuchJobExecutionException.java
similarity index 90%
rename from execution/src/main/java/org/springframework/batch/execution/facade/NoSuchJobExecutionException.java
rename to execution/src/main/java/org/springframework/batch/execution/launch/NoSuchJobExecutionException.java
index 3fb6eeae8..aaef66f50 100644
--- a/execution/src/main/java/org/springframework/batch/execution/facade/NoSuchJobExecutionException.java
+++ b/execution/src/main/java/org/springframework/batch/execution/launch/NoSuchJobExecutionException.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.batch.execution.facade;
+package org.springframework.batch.execution.launch;
/**
* @author Dave Syer
diff --git a/execution/src/main/java/org/springframework/batch/execution/facade/SimpleJobExecutorFacade.java b/execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacade.java
similarity index 96%
rename from execution/src/main/java/org/springframework/batch/execution/facade/SimpleJobExecutorFacade.java
rename to execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacade.java
index df0111c44..6b626a9a4 100644
--- a/execution/src/main/java/org/springframework/batch/execution/facade/SimpleJobExecutorFacade.java
+++ b/execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacade.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.batch.execution.facade;
+package org.springframework.batch.execution.launch;
import java.util.ArrayList;
import java.util.Collections;
@@ -48,28 +48,32 @@ import org.springframework.util.Assert;
* run the job.
*
+ * Listeners can be registered for callbacks at the start and end of a job. + *
+ * * @author Lucas Ward * @author Dave Syer * */ -public class SimpleJobExecutorFacade implements JobExecutorFacade, +class SimpleJobExecutorFacade implements JobExecutorFacade, JobExecutionListener, StatisticsProvider { - private JobExecutor jobExecutor = new DefaultJobExecutor(); - - private JobRepository jobRepository; - private Map jobExecutionRegistry = new HashMap(); + private JobExecutor jobExecutor = new DefaultJobExecutor(); + + private JobRepository jobRepository; + // there is no sensible default for this private JobConfigurationLocator jobConfigurationLocator; + + private List listeners = new ArrayList(); private int running = 0; private Object mutex = new Object(); - private List listeners = new ArrayList(); - /** * Public setter for the listeners property. * @@ -102,11 +106,29 @@ public class SimpleJobExecutorFacade implements JobExecutorFacade, this.jobConfigurationLocator = jobConfigurationLocator; } + /** + * Setter for {@link JobExecutor}. + * + * @param jobExecutor + */ + public void setJobExecutor(JobExecutor jobExecutor) { + this.jobExecutor = jobExecutor; + } + + /** + * Setter for {@link JobRepository}. + * + * @param jobRepository + */ + public void setJobRepository(JobRepository jobRepository) { + this.jobRepository = jobRepository; + } + /** * Locates a {@link JobConfiguration} by using the name of the provided * {@link JobIdentifier} and the {@link JobConfigurationLocator}. * - * @see org.springframework.batch.execution.facade.JobExecutorFacade#start(org.springframework.batch.execution.common.domain.JobConfiguration, + * @see org.springframework.batch.execution.launch.JobExecutorFacade#start(org.springframework.batch.execution.common.domain.JobConfiguration, * org.springframework.batch.core.domain.JobIdentifier) * * @throws IllegalArgumentException @@ -235,24 +257,6 @@ public class SimpleJobExecutorFacade implements JobExecutorFacade, this.stop(execution); } - /** - * Setter for {@link JobExecutor}. - * - * @param jobExecutor - */ - public void setJobExecutor(JobExecutor jobExecutor) { - this.jobExecutor = jobExecutor; - } - - /** - * Setter for {@link JobRepository}. - * - * @param jobRepository - */ - public void setJobRepository(JobRepository jobRepository) { - this.jobRepository = jobRepository; - } - /** * @return a read-only view of the state of the running jobs. */ diff --git a/execution/src/main/java/org/springframework/batch/execution/bootstrap/SimpleJobLauncher.java b/execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java similarity index 81% rename from execution/src/main/java/org/springframework/batch/execution/bootstrap/SimpleJobLauncher.java rename to execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java index b2299be50..85840b8c7 100644 --- a/execution/src/main/java/org/springframework/batch/execution/bootstrap/SimpleJobLauncher.java +++ b/execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java @@ -14,24 +14,28 @@ * limitations under the License. */ -package org.springframework.batch.execution.bootstrap; +package org.springframework.batch.execution.launch; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.configuration.JobConfiguration; +import org.springframework.batch.core.configuration.JobConfigurationLocator; import org.springframework.batch.core.configuration.NoSuchJobConfigurationException; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobIdentifier; +import org.springframework.batch.core.executor.JobExecutor; +import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.runtime.JobIdentifierFactory; -import org.springframework.batch.execution.facade.JobExecutorFacade; -import org.springframework.batch.execution.facade.NoSuchJobExecutionException; +import org.springframework.batch.execution.job.DefaultJobExecutor; import org.springframework.batch.execution.runtime.ScheduledJobIdentifierFactory; import org.springframework.batch.io.exception.BatchConfigurationException; import org.springframework.batch.repeat.ExitStatus; @@ -60,7 +64,16 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean, protected static final Log logger = LogFactory .getLog(SimpleJobLauncher.class); - protected JobExecutorFacade jobExecutorFacade; + private JobExecutor jobExecutor = new DefaultJobExecutor(); + + private JobRepository jobRepository; + + // there is no sensible default for this + private JobConfigurationLocator jobConfigurationLocator; + + private List listeners = new ArrayList(); + + private JobExecutorFacade jobExecutorFacade; private String jobConfigurationName; @@ -109,13 +122,50 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean, public void setAutoStart(boolean autoStart) { this.autoStart = autoStart; } + + /** + * Public setter for the listeners property. + * + * @param listeners + * the listeners to set - a list of {@link JobExecutionListener}. + */ + public void setJobExecutionListeners(List listeners) { + this.listeners = listeners; + } /** - * Setter for {@link JobExecutorFacade}. Mandatory property. + * Setter for injection of {@link JobConfigurationLocator}. * - * @param batchContainer + * @param jobConfigurationLocator + * the jobConfigurationLocator to set */ - public void setJobExecutorFacade(JobExecutorFacade jobExecutorFacade) { + public void setJobConfigurationLocator( + JobConfigurationLocator jobConfigurationLocator) { + this.jobConfigurationLocator = jobConfigurationLocator; + } + + /** + * Setter for {@link JobExecutor}. + * + * @param jobExecutor + */ + public void setJobExecutor(JobExecutor jobExecutor) { + this.jobExecutor = jobExecutor; + } + + /** + * Setter for {@link JobRepository}. + * + * @param jobRepository + */ + public void setJobRepository(JobRepository jobRepository) { + this.jobRepository = jobRepository; + } + + /** + * Setter for {@link JobExecutorFacade}. + */ + void setJobExecutorFacade(JobExecutorFacade jobExecutorFacade) { this.jobExecutorFacade = jobExecutorFacade; } @@ -126,7 +176,15 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean, * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ public void afterPropertiesSet() throws Exception { - Assert.notNull(jobExecutorFacade); + if (jobExecutorFacade==null) { + logger.debug("Using SimpleJobExecutorFacade"); + SimpleJobExecutorFacade jobExecutorFacade = new SimpleJobExecutorFacade(); + jobExecutorFacade.setJobConfigurationLocator(jobConfigurationLocator); + jobExecutorFacade.setJobExecutionListeners(listeners); + jobExecutorFacade.setJobExecutor(jobExecutor); + jobExecutorFacade.setJobRepository(jobRepository); + this.jobExecutorFacade = jobExecutorFacade; + } } /** @@ -153,9 +211,9 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean, } /** - * Subclasses which need to make the call asynchronously should delegate to - * this method inside a Runnable or Callable, so that the internal - * housekeeping is done consistently. + * This method is wrapped in a Runnable by {@link #run(JobIdentifier)}, so + * that the internal housekeeping is done consistently. Subclasses should be + * careful to do the same. * * @param jobIdentifier * @return @@ -178,11 +236,35 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean, unregister(jobIdentifier); } - /* - * Subclasses don't explicitly have to take care of unregistering the - * jobIdentifier - they just have to call this method to make sure that - * it is done. - */ + } + + /** + * Start the job using the task executor provided. + * + * @see org.springframework.batch.execution.launch.SimpleJobLauncher#run(org.springframework.batch.core.domain.JobIdentifier) + */ + public ExitStatus run(final JobIdentifier jobIdentifier) { + + Assert.state(taskExecutor != null, "TaskExecutor must be provided"); + + taskExecutor.execute(new Runnable() { + public void run() { + try { + runInternal(jobIdentifier); + } catch (NoSuchJobConfigurationException e) { + applicationEventPublisher + .publishEvent(new RepeatOperationsApplicationEvent( + jobIdentifier, "No such job", + RepeatOperationsApplicationEvent.ERROR)); + logger.error( + "JobConfiguration could not be located inside Runnable for identifier: [" + + jobIdentifier + "]", e); + } + } + }); + + return ExitStatus.UNKNOWN; + } /** @@ -242,7 +324,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean, * * @throws NoSuchJobExecutionException * @see org.springframework.context.Lifecycle#stop() - * @see org.springframework.batch.execution.bootstrap.JobLauncher#stop() + * @see org.springframework.batch.execution.launch.JobLauncher#stop() */ final public void stop() { for (Iterator iter = new HashSet(registry.keySet()).iterator(); iter @@ -262,7 +344,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean, * * @throws NoSuchJobExecutionException * - * @see org.springframework.batch.execution.bootstrap.JobLauncher#stop(org.springframework.batch.core.domain.JobIdentifier) + * @see org.springframework.batch.execution.launch.JobLauncher#stop(org.springframework.batch.core.domain.JobIdentifier) * @see BatchContainer#stop(JobRuntimeInformation)) */ final public void stop(JobIdentifier runtimeInformation) @@ -278,7 +360,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean, * * @throws NoSuchJobExecutionException * - * @see org.springframework.batch.execution.bootstrap.JobLauncher#stop(java.lang.String) + * @see org.springframework.batch.execution.launch.JobLauncher#stop(java.lang.String) */ final public void stop(String name) throws NoSuchJobExecutionException { this.stop(jobIdentifierFactory.getJobIdentifier(name)); @@ -358,35 +440,6 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean, this.taskExecutor = taskExecutor; } - /** - * Start the job using the task executor provided. - * - * @see org.springframework.batch.execution.bootstrap.SimpleJobLauncher#run(org.springframework.batch.core.domain.JobIdentifier) - */ - public ExitStatus run(final JobIdentifier jobIdentifier) { - - Assert.state(taskExecutor != null, "TaskExecutor must be provided"); - - taskExecutor.execute(new Runnable() { - public void run() { - try { - runInternal(jobIdentifier); - } catch (NoSuchJobConfigurationException e) { - applicationEventPublisher - .publishEvent(new RepeatOperationsApplicationEvent( - jobIdentifier, "No such job", - RepeatOperationsApplicationEvent.ERROR)); - logger.error( - "JobConfiguration could not be located inside Runnable for identifier: [" - + jobIdentifier + "]", e); - } - } - }); - - return ExitStatus.UNKNOWN; - - } - /** * Accessor for the job executions passed back in response to a call to * {@link #requestContextNotification()}. Because the request is diff --git a/execution/src/main/java/org/springframework/batch/execution/facade/package.html b/execution/src/main/java/org/springframework/batch/execution/launch/package.html similarity index 100% rename from execution/src/main/java/org/springframework/batch/execution/facade/package.html rename to execution/src/main/java/org/springframework/batch/execution/launch/package.html diff --git a/execution/src/test/java/org/springframework/batch/execution/bootstrap/support/StubJobLauncher.java b/execution/src/test/java/org/springframework/batch/execution/bootstrap/support/StubJobLauncher.java index 890e98ff6..ee6a9cfe2 100644 --- a/execution/src/test/java/org/springframework/batch/execution/bootstrap/support/StubJobLauncher.java +++ b/execution/src/test/java/org/springframework/batch/execution/bootstrap/support/StubJobLauncher.java @@ -2,7 +2,7 @@ package org.springframework.batch.execution.bootstrap.support; import org.springframework.batch.core.configuration.NoSuchJobConfigurationException; import org.springframework.batch.core.domain.JobIdentifier; -import org.springframework.batch.execution.bootstrap.JobLauncher; +import org.springframework.batch.execution.launch.JobLauncher; import org.springframework.batch.repeat.ExitStatus; /** diff --git a/execution/src/test/java/org/springframework/batch/execution/facade/EmptyItemProcessor.java b/execution/src/test/java/org/springframework/batch/execution/launch/EmptyItemProcessor.java similarity index 97% rename from execution/src/test/java/org/springframework/batch/execution/facade/EmptyItemProcessor.java rename to execution/src/test/java/org/springframework/batch/execution/launch/EmptyItemProcessor.java index b6d27ae1a..b870c0398 100644 --- a/execution/src/test/java/org/springframework/batch/execution/facade/EmptyItemProcessor.java +++ b/execution/src/test/java/org/springframework/batch/execution/launch/EmptyItemProcessor.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.execution.facade; +package org.springframework.batch.execution.launch; import java.util.ArrayList; import java.util.List; diff --git a/execution/src/test/java/org/springframework/batch/execution/bootstrap/InterruptJobTests.java b/execution/src/test/java/org/springframework/batch/execution/launch/InterruptJobTests.java similarity index 93% rename from execution/src/test/java/org/springframework/batch/execution/bootstrap/InterruptJobTests.java rename to execution/src/test/java/org/springframework/batch/execution/launch/InterruptJobTests.java index 15f2a9d4d..243b60d29 100644 --- a/execution/src/test/java/org/springframework/batch/execution/bootstrap/InterruptJobTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/launch/InterruptJobTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.execution.bootstrap; +package org.springframework.batch.execution.launch; import java.util.Collections; @@ -26,8 +26,8 @@ import org.springframework.batch.core.executor.JobExecutor; import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.execution.bootstrap.support.ThreadInterruptJobExecutionListener; import org.springframework.batch.execution.configuration.MapJobConfigurationRegistry; -import org.springframework.batch.execution.facade.JobExecutorFacade; -import org.springframework.batch.execution.facade.SimpleJobExecutorFacade; +import org.springframework.batch.execution.launch.JobExecutorFacade; +import org.springframework.batch.execution.launch.SimpleJobExecutorFacade; import org.springframework.batch.execution.repository.SimpleJobRepository; import org.springframework.batch.execution.repository.dao.MapJobDao; import org.springframework.batch.execution.repository.dao.MapStepDao; diff --git a/execution/src/test/java/org/springframework/batch/execution/facade/JobExecutionListenerSupportTests.java b/execution/src/test/java/org/springframework/batch/execution/launch/JobExecutionListenerSupportTests.java similarity index 81% rename from execution/src/test/java/org/springframework/batch/execution/facade/JobExecutionListenerSupportTests.java rename to execution/src/test/java/org/springframework/batch/execution/launch/JobExecutionListenerSupportTests.java index e164f88cb..1065194ef 100644 --- a/execution/src/test/java/org/springframework/batch/execution/facade/JobExecutionListenerSupportTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/launch/JobExecutionListenerSupportTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.execution.facade; +package org.springframework.batch.execution.launch; import java.util.ArrayList; import java.util.List; @@ -21,8 +21,8 @@ import java.util.List; import junit.framework.TestCase; import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.execution.facade.JobExecutionListener; -import org.springframework.batch.execution.facade.JobExecutionListenerSupport; +import org.springframework.batch.execution.launch.JobExecutionListener; +import org.springframework.batch.execution.launch.JobExecutionListenerSupport; /** * @author Dave Syer @@ -34,7 +34,7 @@ public class JobExecutionListenerSupportTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.execution.facade.JobExecutionListenerSupport#after(org.springframework.batch.core.domain.JobExecution)}. + * {@link org.springframework.batch.execution.launch.JobExecutionListenerSupport#after(org.springframework.batch.core.domain.JobExecution)}. */ public void testAfter() { JobExecutionListener listener = new JobExecutionListenerSupport() { @@ -50,7 +50,7 @@ public class JobExecutionListenerSupportTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.execution.facade.JobExecutionListenerSupport#before(org.springframework.batch.core.domain.JobExecution)}. + * {@link org.springframework.batch.execution.launch.JobExecutionListenerSupport#before(org.springframework.batch.core.domain.JobExecution)}. */ public void testBefore() { JobExecutionListener listener = new JobExecutionListenerSupport() { @@ -66,7 +66,7 @@ public class JobExecutionListenerSupportTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.execution.facade.JobExecutionListenerSupport#before(org.springframework.batch.core.domain.JobExecution)}. + * {@link org.springframework.batch.execution.launch.JobExecutionListenerSupport#before(org.springframework.batch.core.domain.JobExecution)}. */ public void testStop() { JobExecutionListener listener = new JobExecutionListenerSupport() { diff --git a/execution/src/test/java/org/springframework/batch/execution/facade/SimpleJobExecutorFacadeTests.java b/execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacadeTests.java similarity index 97% rename from execution/src/test/java/org/springframework/batch/execution/facade/SimpleJobExecutorFacadeTests.java rename to execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacadeTests.java index 3ca1cda49..7a9a6a531 100644 --- a/execution/src/test/java/org/springframework/batch/execution/facade/SimpleJobExecutorFacadeTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacadeTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.execution.facade; +package org.springframework.batch.execution.launch; import java.lang.reflect.Field; import java.util.ArrayList; @@ -33,6 +33,9 @@ import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.executor.JobExecutor; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.runtime.SimpleJobIdentifier; +import org.springframework.batch.execution.launch.JobExecutionListenerSupport; +import org.springframework.batch.execution.launch.NoSuchJobExecutionException; +import org.springframework.batch.execution.launch.SimpleJobExecutorFacade; import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.batch.repeat.ExitStatus; import org.springframework.batch.repeat.context.RepeatContextSupport; diff --git a/execution/src/test/java/org/springframework/batch/execution/bootstrap/SimpleJobLauncherTests.java b/execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java similarity index 93% rename from execution/src/test/java/org/springframework/batch/execution/bootstrap/SimpleJobLauncherTests.java rename to execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java index a59cdb522..b834749be 100644 --- a/execution/src/test/java/org/springframework/batch/execution/bootstrap/SimpleJobLauncherTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.execution.bootstrap; +package org.springframework.batch.execution.launch; import junit.framework.TestCase; @@ -22,8 +22,9 @@ import org.springframework.batch.core.configuration.JobConfiguration; import org.springframework.batch.core.configuration.NoSuchJobConfigurationException; import org.springframework.batch.core.domain.JobIdentifier; import org.springframework.batch.core.runtime.SimpleJobIdentifierFactory; -import org.springframework.batch.execution.facade.JobExecutionListener; -import org.springframework.batch.execution.facade.JobExecutorFacade; +import org.springframework.batch.execution.launch.JobExecutionListener; +import org.springframework.batch.execution.launch.JobExecutorFacade; +import org.springframework.batch.execution.launch.SimpleJobLauncher; import org.springframework.batch.repeat.ExitStatus; public class SimpleJobLauncherTests extends TestCase { diff --git a/execution/src/test/java/org/springframework/batch/execution/facade/SimpleJobTests.java b/execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java similarity index 99% rename from execution/src/test/java/org/springframework/batch/execution/facade/SimpleJobTests.java rename to execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java index 6f5e64daf..41afbfb91 100644 --- a/execution/src/test/java/org/springframework/batch/execution/facade/SimpleJobTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.execution.facade; +package org.springframework.batch.execution.launch; import java.util.ArrayList; import java.util.Arrays; diff --git a/execution/src/test/java/org/springframework/batch/execution/bootstrap/TaskExecutorJobLauncherTests.java b/execution/src/test/java/org/springframework/batch/execution/launch/TaskExecutorJobLauncherTests.java similarity index 95% rename from execution/src/test/java/org/springframework/batch/execution/bootstrap/TaskExecutorJobLauncherTests.java rename to execution/src/test/java/org/springframework/batch/execution/launch/TaskExecutorJobLauncherTests.java index 6ef146660..8bebe89e4 100644 --- a/execution/src/test/java/org/springframework/batch/execution/bootstrap/TaskExecutorJobLauncherTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/launch/TaskExecutorJobLauncherTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.execution.bootstrap; +package org.springframework.batch.execution.launch; import java.util.ArrayList; import java.util.List; @@ -28,8 +28,9 @@ import org.springframework.batch.core.configuration.NoSuchJobConfigurationExcept import org.springframework.batch.core.domain.JobIdentifier; import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.core.runtime.SimpleJobIdentifierFactory; -import org.springframework.batch.execution.facade.JobExecutionListener; -import org.springframework.batch.execution.facade.JobExecutorFacade; +import org.springframework.batch.execution.launch.JobExecutionListener; +import org.springframework.batch.execution.launch.JobExecutorFacade; +import org.springframework.batch.execution.launch.SimpleJobLauncher; import org.springframework.batch.repeat.ExitStatus; import org.springframework.batch.statistics.StatisticsProvider; import org.springframework.batch.support.PropertiesConverter; diff --git a/execution/src/test/resources/job-configuration.xml b/execution/src/test/resources/job-configuration.xml index 64fd8db50..42e170dc7 100644 --- a/execution/src/test/resources/job-configuration.xml +++ b/execution/src/test/resources/job-configuration.xml @@ -24,7 +24,7 @@