RESOLVED - issue BATCH-218: StepConfiguration and JobConfiguration should not be BeanNameAware
http://opensource.atlassian.com/projects/spring/browse/BATCH-218
This commit is contained in:
@@ -59,12 +59,27 @@ public class JobConfiguration implements BeanNameAware {
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback from {@link BeanNameAware} comes after the setters, so it
|
||||
* will always overwrite the name with the bean id.
|
||||
* Set the name property if it is not already set. Because of the order of
|
||||
* the callbacks in a Spring container the name property will be set first
|
||||
* if it is present. Care is needed with bean definition inheritance - if a
|
||||
* parent bean has a name, then its children need an explicit name as well,
|
||||
* otherwise they will not be unique.
|
||||
*
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setBeanName(String name) {
|
||||
if (this.name==null) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name property. Always overrides the default value if this object
|
||||
* is a Spring bean.
|
||||
*
|
||||
* @see #setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,12 +59,27 @@ public class StepConfigurationSupport implements StepConfiguration,
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name property. Always overrides the default value if this
|
||||
* object is a Spring bean.
|
||||
* Set the name property if it is not already set. Because of the order of
|
||||
* the callbacks in a Spring container the name property will be set first
|
||||
* if it is present. Care is needed with bean definition inheritance - if a
|
||||
* parent bean has a name, then its children need an explicit name as well,
|
||||
* otherwise they will not be unique.
|
||||
*
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setBeanName(String name) {
|
||||
if (this.name==null) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name property. Always overrides the default value if this object
|
||||
* is a Spring bean.
|
||||
*
|
||||
* @see #setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class JobConfigurationTests extends TestCase {
|
||||
*/
|
||||
public void testSetBeanName() {
|
||||
configuration.setBeanName("foo");
|
||||
assertEquals("foo", configuration.getName());
|
||||
assertEquals("job", configuration.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,8 +47,8 @@ public class SpringBeanJobConfigurationTests extends TestCase {
|
||||
JobConfiguration configuration = (JobConfiguration) context
|
||||
.getBean("bean");
|
||||
assertNotNull(configuration.getName());
|
||||
assertEquals("bean", configuration.getName());
|
||||
configuration.setBeanName("foo");
|
||||
assertEquals("foo", configuration.getName());
|
||||
configuration.setBeanName("bar");
|
||||
assertEquals("foo", configuration.getName());
|
||||
}
|
||||
|
||||
@@ -62,8 +62,10 @@ public class SpringBeanJobConfigurationTests extends TestCase {
|
||||
JobConfiguration configuration = (JobConfiguration) context
|
||||
.getBean("bean");
|
||||
assertNotNull(configuration.getName());
|
||||
assertEquals("bean", configuration.getName());
|
||||
assertEquals("bar", configuration.getName());
|
||||
configuration.setBeanName("foo");
|
||||
assertEquals("bar", configuration.getName());
|
||||
configuration.setName("foo");
|
||||
assertEquals("foo", configuration.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,23 +61,6 @@ public class SimpleStepConfigurationTests extends TestCase {
|
||||
assertEquals(20, configuration.getCommitInterval());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.execution.step.AbstractStepConfiguration#setBeanName(java.lang.String)}.
|
||||
*/
|
||||
public void testSetBeanName() {
|
||||
configuration.setBeanName("bar");
|
||||
assertEquals("bar", configuration.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.execution.step.AbstractStepConfiguration#setBeanName(java.lang.String)}.
|
||||
*/
|
||||
public void testSetBeanNameOverrideNull() {
|
||||
configuration = new SimpleStepConfiguration();
|
||||
configuration.setBeanName("bar");
|
||||
assertEquals("bar", configuration.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.execution.step.AbstractStepConfiguration#getExceptionHandler()}.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user