jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JBehave
  • JBEHAVE-260

Improve SpringStepsFactory to allow delegating the CandidateStep creation to other factories

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.5.1
  • Fix Version/s: 3.0.2
  • Component/s: Core
  • Labels:
    None

Description

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.

addSteps(new ParameterConverterStepsFactory().createCandidateSteps( new SpringStepsFactory(context).createStepsInstances() ));

And the simplified SpringStepsFactory :

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;
    }
}

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Mauro Talevi added a comment - 03/Apr/10 6:06 PM

We could have both methods in the SpringStepsFactory, one that returns Steps object instances and one that returns CandidateSteps.

Then one could choose which one to use. Would that work?

Show
Mauro Talevi added a comment - 03/Apr/10 6:06 PM We could have both methods in the SpringStepsFactory, one that returns Steps object instances and one that returns CandidateSteps. Then one could choose which one to use. Would that work?
Hide
Permalink
Mauro Talevi added a comment - 24/Sep/10 9:41 AM

SpringStepsFactory provides protected method:

protected List<Object> stepsInstances();
Show
Mauro Talevi added a comment - 24/Sep/10 9:41 AM SpringStepsFactory provides protected method:
protected List<Object> stepsInstances();

People

  • Assignee:
    Unassigned
    Reporter:
    Bruno Bieth
Vote (0)
Watch (0)

Dates

  • Created:
    03/Apr/10 5:14 PM
    Updated:
    24/Sep/10 9:41 AM
    Resolved:
    24/Sep/10 9:41 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.