1 | |
package org.jbehave.core.configuration.weld; |
2 | |
|
3 | |
import org.jbehave.core.annotations.weld.UsingWeld; |
4 | |
import org.jbehave.core.configuration.AnnotationBuilder; |
5 | |
import org.jbehave.core.configuration.AnnotationFinder; |
6 | |
import org.jbehave.core.configuration.AnnotationMonitor; |
7 | |
import org.jbehave.core.configuration.AnnotationRequired; |
8 | |
import org.jbehave.core.configuration.Configuration; |
9 | |
import org.jbehave.core.configuration.PrintStreamAnnotationMonitor; |
10 | |
import org.jbehave.core.steps.CompositeStepsFactory; |
11 | |
import org.jbehave.core.steps.InjectableStepsFactory; |
12 | |
import org.jbehave.core.steps.ParameterConverters; |
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
public class WeldAnnotationBuilder extends AnnotationBuilder { |
21 | |
|
22 | |
private Configuration configuration; |
23 | |
private InjectableStepsFactory stepsFactory; |
24 | |
|
25 | |
public WeldAnnotationBuilder(Class<?> annotatedClass) { |
26 | 27 | this(annotatedClass, new PrintStreamAnnotationMonitor()); |
27 | 27 | } |
28 | |
|
29 | |
public WeldAnnotationBuilder(Class<?> annotatedClass, AnnotationMonitor annotationMonitor) { |
30 | 27 | super(annotatedClass, annotationMonitor); |
31 | 27 | } |
32 | |
|
33 | |
public WeldAnnotationBuilder(Class<?> annotatedClass, Configuration configuration, |
34 | |
InjectableStepsFactory stepsFactory) { |
35 | 27 | this(annotatedClass); |
36 | 27 | this.configuration = configuration; |
37 | 27 | this.stepsFactory = stepsFactory; |
38 | 27 | } |
39 | |
|
40 | |
@Override |
41 | |
public Configuration buildConfiguration() throws AnnotationRequired { |
42 | 8 | AnnotationFinder finder = annotationFinder(); |
43 | 8 | if (finder.isAnnotationPresent(UsingWeld.class)) { |
44 | 6 | if (configuration == null) { |
45 | 0 | return super.buildConfiguration(); |
46 | |
} |
47 | 6 | return configuration; |
48 | |
} else { |
49 | 2 | annotationMonitor().annotationNotFound(UsingWeld.class, annotatedClass()); |
50 | |
} |
51 | 2 | return super.buildConfiguration(); |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public InjectableStepsFactory buildStepsFactory(Configuration configuration) { |
56 | 3 | InjectableStepsFactory factoryUsingSteps = super.buildStepsFactory(configuration); |
57 | 3 | if (stepsFactory != null) { |
58 | 3 | return new CompositeStepsFactory(stepsFactory, factoryUsingSteps); |
59 | |
} |
60 | 0 | return factoryUsingSteps; |
61 | |
} |
62 | |
|
63 | |
@Override |
64 | |
protected ParameterConverters parameterConverters(AnnotationFinder annotationFinder) { |
65 | 0 | ParameterConverters converters = super.parameterConverters(annotationFinder); |
66 | 0 | return converters; |
67 | |
} |
68 | |
} |