1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.cubby.controller.impl; |
17 | |
|
18 | |
import org.seasar.cubby.action.FormatPattern; |
19 | |
import org.seasar.cubby.action.impl.FormatPatternImpl; |
20 | |
import org.seasar.cubby.controller.CubbyConfiguration; |
21 | |
import org.seasar.cubby.controller.RequestParser; |
22 | |
import org.seasar.framework.container.ComponentDef; |
23 | |
import org.seasar.framework.container.S2Container; |
24 | |
import org.seasar.framework.log.Logger; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class CubbyConfigurationImpl implements CubbyConfiguration { |
33 | |
|
34 | 1 | private static final Logger logger = Logger |
35 | |
.getLogger(CubbyConfiguration.class); |
36 | |
|
37 | |
|
38 | 1 | private static final RequestParser DEFAULT_REQUEST_PARSER = new DefaultRequestParserImpl(); |
39 | |
|
40 | |
|
41 | |
private final RequestParser requestParser; |
42 | |
|
43 | |
|
44 | |
private final FormatPattern formatPattern; |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
public RequestParser getRequestParser() { |
50 | 8 | return requestParser; |
51 | |
} |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
public FormatPattern getFormatPattern() { |
57 | 38 | return formatPattern; |
58 | |
} |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | 40 | public CubbyConfigurationImpl(final S2Container container) { |
70 | 40 | final S2Container root = container.getRoot(); |
71 | |
|
72 | 39 | if (root.hasComponentDef(RequestParser.class)) { |
73 | 11 | final ComponentDef componentDef = root |
74 | |
.getComponentDef(RequestParser.class); |
75 | 11 | this.requestParser = (RequestParser) componentDef.getComponent(); |
76 | 11 | if (logger.isDebugEnabled()) { |
77 | 11 | logger.log("DCUB0009", new Object[] { RequestParser.class, |
78 | |
this.requestParser }); |
79 | |
} |
80 | 11 | } else { |
81 | 28 | this.requestParser = DEFAULT_REQUEST_PARSER; |
82 | 28 | if (logger.isDebugEnabled()) { |
83 | 28 | logger.log("DCUB0008", new Object[] { RequestParser.class, |
84 | |
this.requestParser }); |
85 | |
} |
86 | |
} |
87 | |
|
88 | 39 | if (root.hasComponentDef(FormatPattern.class)) { |
89 | 11 | final ComponentDef componentDef = root |
90 | |
.getComponentDef(FormatPattern.class); |
91 | 11 | this.formatPattern = (FormatPattern) componentDef.getComponent(); |
92 | 11 | if (logger.isDebugEnabled()) { |
93 | 11 | logger.log("DCUB0009", new Object[] { FormatPattern.class, |
94 | |
this.formatPattern }); |
95 | |
} |
96 | 11 | } else { |
97 | 28 | this.formatPattern = new FormatPatternImpl(); |
98 | 28 | if (logger.isDebugEnabled()) { |
99 | 28 | logger.log("DCUB0008", new Object[] { FormatPattern.class, |
100 | |
this.formatPattern }); |
101 | |
} |
102 | |
} |
103 | |
|
104 | 39 | } |
105 | |
|
106 | |
} |