Make a SimpleJobIdentifierFactory for SimpleJobIdentifiers
OPEN - issue BATCH-58: Make JobStream and JobRun optional properties of Job (e.g. through join to optional table) http://opensource.atlassian.com/projects/spring/browse/BATCH-58
This commit is contained in:
@@ -16,9 +16,25 @@
|
||||
|
||||
package org.springframework.batch.core.runtime;
|
||||
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
|
||||
/**
|
||||
* Identifier strategy for {@link JobInstance}. Different batch projects can
|
||||
* have different approaches and requirements regarding the identity of a job.
|
||||
* The minimum requirement is to provide a unique name to identify a job. Other
|
||||
* applications or projects might add other properties like a schedule date, or
|
||||
* an additional label (code).
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface JobIdentifier {
|
||||
|
||||
|
||||
/**
|
||||
* A name property for jobs provided by the {@link JobIdentifier} strategy.
|
||||
*
|
||||
* @return the name of the job
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.springframework.batch.core.runtime;
|
||||
|
||||
|
||||
/**
|
||||
* Factory for {@link SimpleJobIdentifier} instances.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class SimpleJobIdentifierFactory implements JobIdentifierFactory {
|
||||
|
||||
/**
|
||||
* Create a {@link JobIdentifier} with the given name.
|
||||
*
|
||||
* @param name the name for the {@link JobIdentifier}
|
||||
* @return a {@link JobIdentifier} with the given name.
|
||||
*
|
||||
* @see org.springframework.batch.core.runtime.JobIdentifierFactory#getJobIdentifier(java.lang.String)
|
||||
*/
|
||||
public JobIdentifier getJobIdentifier(String name) {
|
||||
return new SimpleJobIdentifier(name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.springframework.batch.core.runtime;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class SimpleJobIdentifierFactoryTests extends TestCase {
|
||||
|
||||
public void testGetJobIdentifier() {
|
||||
JobIdentifier jobIdentifier = new SimpleJobIdentifierFactory().getJobIdentifier("foo");
|
||||
assertEquals("foo", jobIdentifier.getName());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user