RESOLVED - issue BATCH-180: JobConfigurations do not get their names set if they are child beans
http://opensource.atlassian.com/projects/spring/browse/BATCH-180 Removed setName() from *Configuration - you have to use the bean id or setBeanName().
This commit is contained in:
@@ -29,7 +29,7 @@ import org.springframework.beans.factory.BeanNameAware;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class AbstractStepConfiguration extends StepConfigurationSupport implements BeanNameAware {
|
||||
public class AbstractStepConfiguration extends StepConfigurationSupport {
|
||||
|
||||
private int skipLimit = 0;
|
||||
|
||||
@@ -43,25 +43,13 @@ public class AbstractStepConfiguration extends StepConfigurationSupport implemen
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenent constructor for setting only the name property.
|
||||
* Convenient constructor for setting only the name property.
|
||||
* @param name
|
||||
*/
|
||||
public AbstractStepConfiguration(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name property if it has not already been set explicitly (and is
|
||||
* therefore not null).
|
||||
*
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setBeanName(String name) {
|
||||
if (getName() == null) {
|
||||
setName(name);
|
||||
}
|
||||
}
|
||||
|
||||
public ExceptionHandler getExceptionHandler() {
|
||||
return exceptionHandler;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class JobConfigurationRegistryBeanPostProcessorTests extends TestCase {
|
||||
MapJobConfigurationRegistry registry = new MapJobConfigurationRegistry();
|
||||
processor.setJobConfigurationRegistry(registry);
|
||||
JobConfiguration configuration = new JobConfiguration();
|
||||
configuration.setName("foo");
|
||||
configuration.setBeanName("foo");
|
||||
assertEquals(configuration, processor.postProcessAfterInitialization(configuration, "bar"));
|
||||
assertEquals(configuration, registry.getJobConfiguration("foo"));
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class JobConfigurationRegistryBeanPostProcessorTests extends TestCase {
|
||||
MapJobConfigurationRegistry registry = new MapJobConfigurationRegistry();
|
||||
processor.setJobConfigurationRegistry(registry);
|
||||
JobConfiguration configuration = new JobConfiguration();
|
||||
configuration.setName("foo");
|
||||
configuration.setBeanName("foo");
|
||||
processor.postProcessAfterInitialization(configuration, "bar");
|
||||
try {
|
||||
processor.postProcessAfterInitialization(configuration, "spam");
|
||||
@@ -81,7 +81,7 @@ public class JobConfigurationRegistryBeanPostProcessorTests extends TestCase {
|
||||
MapJobConfigurationRegistry registry = new MapJobConfigurationRegistry();
|
||||
processor.setJobConfigurationRegistry(registry);
|
||||
JobConfiguration configuration = new JobConfiguration();
|
||||
configuration.setName("foo");
|
||||
configuration.setBeanName("foo");
|
||||
assertEquals(configuration, processor.postProcessAfterInitialization(configuration, "bar"));
|
||||
processor.destroy();
|
||||
try {
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.execution.facade;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.configuration.JobConfiguration;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
|
||||
public class JobConfigurationTests extends TestCase {
|
||||
|
||||
public void testBeanName() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
JobConfiguration configuration = new JobConfiguration();
|
||||
context.getAutowireCapableBeanFactory().initializeBean(configuration, "bean");
|
||||
assertNotNull(configuration.getName());
|
||||
configuration.setName("foo");
|
||||
context.getAutowireCapableBeanFactory().initializeBean(configuration, "bean");
|
||||
assertEquals("foo", configuration.getName());
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class SimpleJobExecutorFacadeTests extends TestCase {
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
super.setUp();
|
||||
jobConfiguration.setName("TestJob");
|
||||
jobConfiguration.setBeanName("TestJob");
|
||||
jobExecutorFacade.setJobExecutor(jobExecutor);
|
||||
jobRepository = (JobRepository) jobRepositoryControl.getMock();
|
||||
jobExecutorFacade.setJobRepository(jobRepository);
|
||||
|
||||
@@ -116,10 +116,8 @@ public class DefaultJobExecutorTests extends TestCase {
|
||||
}
|
||||
});
|
||||
|
||||
stepConfiguration1 = new SimpleStepConfiguration();
|
||||
stepConfiguration1.setName("TestStep1");
|
||||
stepConfiguration2 = new SimpleStepConfiguration();
|
||||
stepConfiguration2.setName("TestStep2");
|
||||
stepConfiguration1 = new SimpleStepConfiguration("TestStep1");
|
||||
stepConfiguration2 = new SimpleStepConfiguration("TestStep2");
|
||||
List stepConfigurations = new ArrayList();
|
||||
stepConfigurations.add(stepConfiguration1);
|
||||
stepConfigurations.add(stepConfiguration2);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
jobRuntimeInformation = new SimpleJobIdentifier("RepositoryTest");
|
||||
|
||||
jobConfiguration = new JobConfiguration();
|
||||
jobConfiguration.setName("RepositoryTest");
|
||||
jobConfiguration.setBeanName("RepositoryTest");
|
||||
jobConfiguration.setRestartable(true);
|
||||
|
||||
stepConfiguration1 = new StepConfigurationSupport("TestStep1");
|
||||
|
||||
@@ -66,7 +66,7 @@ public class SimpleStepConfigurationTests extends TestCase {
|
||||
*/
|
||||
public void testSetBeanName() {
|
||||
configuration.setBeanName("bar");
|
||||
assertEquals("foo", configuration.getName());
|
||||
assertEquals("bar", configuration.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,7 +64,7 @@ public class StepExecutorInterruptionTests extends TestCase {
|
||||
stepConfiguration = new SimpleStepConfiguration();
|
||||
jobConfiguration.addStep(stepConfiguration);
|
||||
JobIdentifier runtimeInformation = new SimpleJobIdentifier("TestJob");
|
||||
jobConfiguration.setName("testJob");
|
||||
jobConfiguration.setBeanName("testJob");
|
||||
job = jobRepository.findOrCreateJob(jobConfiguration, runtimeInformation);
|
||||
executor = new SimpleStepExecutor();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
</bean>
|
||||
|
||||
<bean id="test-job" class="org.springframework.batch.core.configuration.JobConfiguration">
|
||||
<property name="name" value="test-job"/>
|
||||
<property name="steps">
|
||||
<bean id="step1" class="org.springframework.batch.execution.step.SimpleStepConfiguration">
|
||||
<constructor-arg>
|
||||
|
||||
Reference in New Issue
Block a user