RESOLVED - issue BATCH-1338: Allow segregation of jobs by type or origin
CHange default separator to "."
This commit is contained in:
@@ -26,7 +26,7 @@ import org.springframework.batch.core.configuration.JobFactory;
|
||||
* job might be <code>overnightJob</code> and the group
|
||||
* <code>financeDepartment</code>, which would result in a {@link Job} with
|
||||
* identical functionality but named <code>financeDepartment$overnightJob</code>
|
||||
* . The use of a "$" separator for elements is deliberate, since it is a "safe"
|
||||
* . The use of a "." separator for elements is deliberate, since it is a "safe"
|
||||
* character in a <a href="http://www.w3.org/Addressing/URL">URL</a>.
|
||||
*
|
||||
*
|
||||
@@ -35,6 +35,11 @@ import org.springframework.batch.core.configuration.JobFactory;
|
||||
*/
|
||||
public abstract class AbstractGroupAwareJobFactory implements JobFactory {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final String SEPARATOR = ".";
|
||||
|
||||
private final String groupName;
|
||||
|
||||
private final String jobName;
|
||||
@@ -88,7 +93,7 @@ public abstract class AbstractGroupAwareJobFactory implements JobFactory {
|
||||
* @see org.springframework.batch.core.configuration.JobFactory#getJobName()
|
||||
*/
|
||||
public final String getJobName() {
|
||||
return groupName == null ? jobName : groupName + "$" + jobName;
|
||||
return groupName == null ? jobName : groupName + SEPARATOR + jobName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +127,7 @@ public abstract class AbstractGroupAwareJobFactory implements JobFactory {
|
||||
* @see org.springframework.batch.core.Job#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return groupName + "$" + delegate.getName();
|
||||
return groupName + SEPARATOR + delegate.getName();
|
||||
}
|
||||
|
||||
public boolean isRestartable() {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ApplicationContextJobFactoryTests {
|
||||
public void testGroupName() throws Exception {
|
||||
ApplicationContextJobFactory factory = new ApplicationContextJobFactory("jobs", "job",
|
||||
new StubApplicationContextFactory());
|
||||
assertEquals("jobs$job", factory.getJobName());
|
||||
assertEquals("jobs.job", factory.getJobName());
|
||||
}
|
||||
|
||||
private static class StubApplicationContextFactory implements ApplicationContextFactory {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GroupAwareJobFactoryTests {
|
||||
}
|
||||
};
|
||||
assertEquals(factory.getJobName(), factory.createJob().getName());
|
||||
assertEquals("jobs$foo", factory.getJobName());
|
||||
assertEquals("jobs.foo", factory.getJobName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class JobRegistryBeanPostProcessorTests {
|
||||
JobSupport job = new JobSupport();
|
||||
job.setBeanName("foo");
|
||||
assertEquals(job, processor.postProcessAfterInitialization(job, "bar"));
|
||||
assertEquals("[jobs$foo]", registry.getJobNames().toString());
|
||||
assertEquals("[jobs.foo]", registry.getJobNames().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ReferenceJobFactoryTests {
|
||||
@Test
|
||||
public void testGroupName() throws Exception {
|
||||
ReferenceJobFactory factory = new ReferenceJobFactory("jobs", new JobSupport("foo"));
|
||||
assertEquals("jobs$foo", factory.getJobName());
|
||||
assertEquals("jobs.foo", factory.getJobName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user