1 | |
package org.jbehave.core.steps.spring; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import org.jbehave.core.configuration.Configuration; |
7 | |
import org.jbehave.core.steps.AbstractStepsFactory; |
8 | |
import org.jbehave.core.steps.InjectableStepsFactory; |
9 | |
import org.springframework.context.ApplicationContext; |
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
public class SpringStepsFactory extends AbstractStepsFactory { |
20 | |
|
21 | |
private final ApplicationContext context; |
22 | |
|
23 | |
public SpringStepsFactory(Configuration configuration, ApplicationContext context) { |
24 | 5 | super(configuration); |
25 | 5 | this.context = context; |
26 | 5 | } |
27 | |
|
28 | |
@Override |
29 | |
protected List<Object> stepsInstances() { |
30 | 5 | List<Object> steps = new ArrayList<Object>(); |
31 | 24 | for (String name : context.getBeanDefinitionNames()) { |
32 | 19 | Object bean = context.getBean(name); |
33 | 19 | if (hasAnnotatedMethods(bean.getClass())) { |
34 | 4 | steps.add(bean); |
35 | |
} |
36 | |
} |
37 | 5 | return steps; |
38 | |
} |
39 | |
|
40 | |
} |