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:
dsyer
2007-08-23 19:46:28 +00:00
parent 4210297540
commit f19379e27b
3 changed files with 53 additions and 1 deletions

View File

@@ -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();
}

View File

@@ -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);
}
}

View File

@@ -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());
}
}