Improve SpringStepsFactory to allow delegating the CandidateStep creation to
other factories
--------------------------------------------------------------------------------------------
Key: JBEHAVE-260
URL: http://jira.codehaus.org/browse/JBEHAVE-260
Project: JBehave
Issue Type: Improvement
Components: Core
Affects Versions: 2.5.1
Reporter: Bruno Bieth
Change the SpringStepsFactory so it doesn't create CandidateSteps but rather
return bean instances. That way I can have a different way of instanciating
CandidateSteps.
{code}
addSteps(new ParameterConverterStepsFactory().createCandidateSteps( new
SpringStepsFactory(context).createStepsInstances() ));
{code}
And the simplified SpringStepsFactory :
{code}
public class SpringStepsFactory {
private final ListableBeanFactory parent;
public SpringStepsFactory(ListableBeanFactory parent) {
this.parent = parent;
}
public Object[] createStepsInstances() {
List<Object> steps = new ArrayList<Object>();
for (String name : parent.getBeanDefinitionNames()) {
Object bean = parent.getBean(name);
if (containsScenarioAnnotations(bean.getClass())) {
steps.add(bean);
}
}
return steps.toArray(new Object[steps.size()]);
}
private boolean containsScenarioAnnotations(Class<?> componentClass) {
for (Method method : componentClass.getMethods()) {
for (Annotation annotation : method.getAnnotations()) {
if
(annotation.annotationType().getName().startsWith("org.jbehave.scenario.annotations"))
{
return true;
}
}
}
return false;
}
}
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email