1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package javax.faces.internal; |
17 | |
|
18 | |
import java.util.Map; |
19 | |
|
20 | |
import javax.faces.internal.ValidatorResource.ValidatorPair; |
21 | |
import javax.faces.validator.Validator; |
22 | |
|
23 | |
import org.seasar.framework.beans.util.BeanUtil; |
24 | |
import org.seasar.framework.container.S2Container; |
25 | |
import org.seasar.framework.container.factory.SingletonS2ContainerFactory; |
26 | |
import org.seasar.framework.container.hotdeploy.HotdeployUtil; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class HotDeployValidatorBuilderImpl implements ValidatorBuilder { |
33 | |
|
34 | |
private S2Container container; |
35 | |
|
36 | 4 | public HotDeployValidatorBuilderImpl() { |
37 | 4 | container = SingletonS2ContainerFactory.getContainer(); |
38 | 4 | } |
39 | |
|
40 | 0 | public HotDeployValidatorBuilderImpl(S2Container container) { |
41 | 0 | this.container = container; |
42 | 0 | } |
43 | |
|
44 | |
public Validator build(String expression, ValidatorPair[] pairs) { |
45 | 9 | if (pairs == null || pairs.length == 0) { |
46 | 0 | return null; |
47 | |
} |
48 | 9 | if (pairs.length == 1) { |
49 | 5 | return getSingleValidator(pairs[0]); |
50 | |
} |
51 | 4 | final ValidatorChain chain = new ValidatorChain(); |
52 | 12 | for (int i = 0; i < pairs.length; i++) { |
53 | 8 | chain.add(getSingleValidator(pairs[i])); |
54 | |
} |
55 | 4 | return chain; |
56 | |
} |
57 | |
|
58 | |
protected Validator getSingleValidator(ValidatorPair pair) { |
59 | 13 | Map properties = pair.properties; |
60 | 13 | if (HotdeployUtil.isHotdeploy()) { |
61 | 0 | properties = EnumUtil.convertNameToEnum(properties); |
62 | |
} |
63 | 13 | final Validator validator = (Validator) container |
64 | |
.getComponent(pair.validatorName); |
65 | 13 | BeanUtil.copyProperties(properties, validator); |
66 | 13 | return validator; |
67 | |
} |
68 | |
|
69 | |
public void setContainer(S2Container container) { |
70 | 4 | this.container = container; |
71 | 4 | } |
72 | |
|
73 | |
public void clearAll() { |
74 | |
|
75 | 0 | } |
76 | |
|
77 | |
public void clearValidator(String expression) { |
78 | |
|
79 | 0 | } |
80 | |
|
81 | |
} |