RESOLVED - issue BATCH-1338: Allow segregation of jobs by type or origin

CHange default separator to "."
This commit is contained in:
dsyer
2009-09-08 08:00:21 +00:00
parent f9b186ada3
commit 9f0fba98d7
5 changed files with 12 additions and 7 deletions

View File

@@ -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() {

View File

@@ -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 {

View File

@@ -50,7 +50,7 @@ public class GroupAwareJobFactoryTests {
}
};
assertEquals(factory.getJobName(), factory.createJob().getName());
assertEquals("jobs$foo", factory.getJobName());
assertEquals("jobs.foo", factory.getJobName());
}
}

View File

@@ -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

View File

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