OPEN - issue BATCH-429: Combine the core and execution modules
Consolidate some random packages and classes with odd names.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Specific implementations of facade concerns.
|
||||
Interfaces and simple implementations of launch concerns.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.configuration.JobLocator;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.runtime.DefaultJobParametersFactory;
|
||||
import org.springframework.batch.core.runtime.JobParametersFactory;
|
||||
import org.springframework.batch.core.support.DefaultJobParametersConverter;
|
||||
import org.springframework.batch.core.support.JobParametersConverter;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
@@ -127,7 +127,7 @@ public class CommandLineJobRunner {
|
||||
|
||||
private SystemExiter systemExiter = new JvmSystemExiter();
|
||||
|
||||
private JobParametersFactory jobParametersFactory = new DefaultJobParametersFactory();
|
||||
private JobParametersConverter jobParametersConverter = new DefaultJobParametersConverter();
|
||||
|
||||
/**
|
||||
* Injection setter for the {@link JobLauncher}.
|
||||
@@ -190,7 +190,7 @@ public class CommandLineJobRunner {
|
||||
job = (Job) context.getBean(jobName);
|
||||
}
|
||||
|
||||
JobParameters jobParameters = jobParametersFactory
|
||||
JobParameters jobParameters = jobParametersConverter
|
||||
.getJobParameters(StringUtils
|
||||
.splitArrayElementsIntoProperties(parameters, "="));
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.runtime.JobParametersFactory;
|
||||
import org.springframework.batch.core.support.JobParametersConverter;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class ScheduledJobParametersFactory implements JobParametersFactory {
|
||||
public class ScheduledJobParametersFactory implements JobParametersConverter {
|
||||
|
||||
public static String SCHEDULE_DATE_KEY = "schedule.date";
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ScheduledJobParametersFactory implements JobParametersFactory {
|
||||
* Convert schedule date to Date, and assume all other parameters can be
|
||||
* represented by their default string value.
|
||||
*
|
||||
* @see org.springframework.batch.core.runtime.JobParametersFactory#getProperties(org.springframework.batch.core.JobParameters)
|
||||
* @see org.springframework.batch.core.support.JobParametersConverter#getProperties(org.springframework.batch.core.JobParameters)
|
||||
*/
|
||||
public Properties getProperties(JobParameters params) {
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.batch.core.runtime.DefaultJobParametersFactory;
|
||||
import org.springframework.batch.core.runtime.JobParametersFactory;
|
||||
import org.springframework.batch.core.support.DefaultJobParametersConverter;
|
||||
import org.springframework.batch.core.support.JobParametersConverter;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -47,7 +47,7 @@ public class SimpleExportedJobLauncher implements ExportedJobLauncher, Initializ
|
||||
|
||||
private Map registry = new HashMap();
|
||||
|
||||
private JobParametersFactory jobParametersFactory = new DefaultJobParametersFactory();
|
||||
private JobParametersConverter jobParametersConverter = new DefaultJobParametersConverter();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
@@ -75,10 +75,10 @@ public class SimpleExportedJobLauncher implements ExportedJobLauncher, Initializ
|
||||
|
||||
/**
|
||||
* Public setter for the JobParametersFactory.
|
||||
* @param jobParametersFactory the jobParametersFactory to set
|
||||
* @param jobParametersConverter the jobParametersFactory to set
|
||||
*/
|
||||
public void setJobParametersFactory(JobParametersFactory jobParametersFactory) {
|
||||
this.jobParametersFactory = jobParametersFactory;
|
||||
public void setJobParametersFactory(JobParametersConverter jobParametersConverter) {
|
||||
this.jobParametersConverter = jobParametersConverter;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -153,7 +153,7 @@ public class SimpleExportedJobLauncher implements ExportedJobLauncher, Initializ
|
||||
|
||||
JobParameters jobParameters = new JobParameters();
|
||||
if (params != null) {
|
||||
jobParameters = jobParametersFactory.getJobParameters(PropertiesConverter.stringToProperties(params));
|
||||
jobParameters = jobParametersConverter.getJobParameters(PropertiesConverter.stringToProperties(params));
|
||||
}
|
||||
|
||||
JobExecution execution;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.launch;
|
||||
package org.springframework.batch.core.launch.support;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -21,6 +21,7 @@ import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Support classes for use in bootstrap implementations or configurations.
|
||||
Support classes for use in bootstrap and launch implementations or configurations.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Generic implementations of core batch listener interfaces.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Interfaces and generic implementations of runtime concerns.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.runtime;
|
||||
package org.springframework.batch.core.step;
|
||||
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.support.ExceptionClassifier;
|
||||
@@ -27,7 +27,6 @@ import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.UnexpectedJobExecutionException;
|
||||
import org.springframework.batch.core.listener.CompositeStepListener;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.io.StringWriter;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
import org.springframework.batch.core.launch.support.ExitCodeMapper;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.runtime;
|
||||
package org.springframework.batch.core.support;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Factory for {@link JobParameters} instances using a simple naming convention
|
||||
* Converter for {@link JobParameters} instances using a simple naming convention
|
||||
* for property keys. Key names ending with "(<type>)" where type is one
|
||||
* of string, date, long are converted to the corresponding type. The default
|
||||
* type is string. E.g.
|
||||
@@ -47,7 +47,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class DefaultJobParametersFactory implements JobParametersFactory {
|
||||
public class DefaultJobParametersConverter implements JobParametersConverter {
|
||||
|
||||
public static String DATE_TYPE = "(date)";
|
||||
|
||||
@@ -66,7 +66,7 @@ public class DefaultJobParametersFactory implements JobParametersFactory {
|
||||
* @throws IllegalArgumentException if a number or date is passed in that
|
||||
* cannot be parsed, or cast to the correct type.
|
||||
*
|
||||
* @see org.springframework.batch.core.runtime.JobParametersFactory#getJobParameters(java.util.Properties)
|
||||
* @see org.springframework.batch.core.support.JobParametersConverter#getJobParameters(java.util.Properties)
|
||||
*/
|
||||
public JobParameters getJobParameters(Properties props) {
|
||||
|
||||
@@ -124,7 +124,7 @@ public class DefaultJobParametersFactory implements JobParametersFactory {
|
||||
* Use the same suffixes to create properties (omitting the string suffix
|
||||
* because it is the default).
|
||||
*
|
||||
* @see org.springframework.batch.core.runtime.JobParametersFactory#getProperties(org.springframework.batch.core.JobParameters)
|
||||
* @see org.springframework.batch.core.support.JobParametersConverter#getProperties(org.springframework.batch.core.JobParameters)
|
||||
*/
|
||||
public Properties getProperties(JobParameters params) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.runtime;
|
||||
package org.springframework.batch.core.support;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -22,34 +22,30 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
|
||||
/**
|
||||
* A factory for {@link JobParameters} instances. A job can be
|
||||
* executed with many possible runtime parameters, which identify the instance
|
||||
* of the job. This factory allows job identifiers to be created with different
|
||||
* properties according to the {@link JobParameters} strategy required. For
|
||||
* example some projects or jobs need a schedule date as part of the
|
||||
* {@link JobParameters} and some do not (e.g. for an ad-hoc execution a simple
|
||||
* label might be enough).
|
||||
* A factory for {@link JobParameters} instances. A job can be executed with
|
||||
* many possible runtime parameters, which identify the instance of the job.
|
||||
* This converter allows job parameters to be to and from Properties.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @see JobParametersBuilder
|
||||
*
|
||||
*/
|
||||
public interface JobParametersFactory {
|
||||
public interface JobParametersConverter {
|
||||
|
||||
/**
|
||||
* Get a new {@link JobParameters} instance. If given null, or an empty
|
||||
* Get a new {@link JobParameters} instance. If given null, or an empty
|
||||
* properties, an empty JobParameters will be returned.
|
||||
*
|
||||
* @param properties
|
||||
* the runtime parameters in the form of String literals.
|
||||
* @return a {@link JobParameters} properties converted to the correct types.
|
||||
* @param properties the runtime parameters in the form of String literals.
|
||||
* @return a {@link JobParameters} properties converted to the correct
|
||||
* types.
|
||||
*/
|
||||
public JobParameters getJobParameters(Properties properties);
|
||||
|
||||
/**
|
||||
* The inverse operation: get a {@link Properties} instance. If given
|
||||
* null or empty JobParameters, an empty Properties should be returned.
|
||||
* The inverse operation: get a {@link Properties} instance. If given null
|
||||
* or empty JobParameters, an empty Properties should be returned.
|
||||
*
|
||||
* @param params
|
||||
* @return a representation of the parameters as properties
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.resource;
|
||||
package org.springframework.batch.core.support;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -29,8 +29,6 @@ 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.runtime.DefaultJobParametersFactory;
|
||||
import org.springframework.batch.core.runtime.JobParametersFactory;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.core.io.FileSystemResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -61,11 +59,12 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* Note that the default pattern does not start with a separator. Because of the
|
||||
* implementation of the Spring Core Resource abstractions, it would need to
|
||||
* start with a double forward slash "//" to resolve to an absolute directory.<br/>
|
||||
* start with a double forward slash "//" to resolve to an absolute directory
|
||||
* (or else use a full URL with the file: prefix).<br/>
|
||||
*
|
||||
* 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. It is to enable this usage that the resource implements
|
||||
* going to need it. For this reason the resource implements
|
||||
* {@link StepListener}.
|
||||
*
|
||||
* @author Tomas Slanina
|
||||
@@ -74,7 +73,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @see Resource
|
||||
*/
|
||||
public class StepExecutionProxyResource extends StepListenerSupport implements Resource, ResourceLoaderAware,
|
||||
public class StepExecutionResourceProxy extends StepListenerSupport implements Resource, ResourceLoaderAware,
|
||||
StepListener {
|
||||
|
||||
private static final String JOB_NAME_PATTERN = "%JOB_NAME%";
|
||||
@@ -85,7 +84,7 @@ public class StepExecutionProxyResource extends StepListenerSupport implements R
|
||||
|
||||
private String filePattern = DEFAULT_PATTERN;
|
||||
|
||||
private JobParametersFactory jobParametersFactory = new DefaultJobParametersFactory();
|
||||
private JobParametersConverter jobParametersConverter = new DefaultJobParametersConverter();
|
||||
|
||||
private ResourceLoader resourceLoader = new FileSystemResourceLoader();
|
||||
|
||||
@@ -197,13 +196,13 @@ public class StepExecutionProxyResource extends StepListenerSupport implements R
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the {@link JobParametersFactory} used to translate
|
||||
* Public setter for the {@link JobParametersConverter} used to translate
|
||||
* {@link JobParameters} into {@link Properties}. Defaults to a
|
||||
* {@link DefaultJobParametersFactory}.
|
||||
* @param jobParametersFactory the {@link JobParametersFactory} to set
|
||||
* {@link DefaultJobParametersConverter}.
|
||||
* @param jobParametersConverter the {@link JobParametersConverter} to set
|
||||
*/
|
||||
public void setJobParametersFactory(JobParametersFactory jobParametersFactory) {
|
||||
this.jobParametersFactory = jobParametersFactory;
|
||||
public void setJobParametersFactory(JobParametersConverter jobParametersConverter) {
|
||||
this.jobParametersConverter = jobParametersConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,7 +280,7 @@ public class StepExecutionProxyResource extends StepListenerSupport implements R
|
||||
public void beforeStep(StepExecution execution) {
|
||||
String stepName = execution.getStepName();
|
||||
String jobName = execution.getJobExecution().getJobInstance().getJobName();
|
||||
Properties properties = jobParametersFactory.getProperties(execution.getJobExecution().getJobInstance()
|
||||
Properties properties = jobParametersConverter.getProperties(execution.getJobExecution().getJobInstance()
|
||||
.getJobParameters());
|
||||
delegate = resourceLoader.getResource(createFileName(jobName, stepName, properties));
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>Support classes for implementations of the batch APIs. Things
|
||||
like converters and resource location and management concerns.</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user