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 | |
public class CubbyConfigurationImpl implements CubbyConfiguration { |
32 | |
|
33 | 1 | private static final Logger logger = Logger |
34 | |
.getLogger(CubbyConfiguration.class); |
35 | |
|
36 | 1 | private static final RequestParser DEFAULT_REQUEST_PARSER = new DefaultRequestParserImpl(); |
37 | |
|
38 | |
private final RequestParser requestParser; |
39 | |
|
40 | |
private final FormatPattern formatPattern; |
41 | |
|
42 | |
public RequestParser getRequestParser() { |
43 | 8 | return requestParser; |
44 | |
} |
45 | |
|
46 | |
public FormatPattern getFormatPattern() { |
47 | 78 | return formatPattern; |
48 | |
} |
49 | |
|
50 | 42 | public CubbyConfigurationImpl(final S2Container container) { |
51 | 42 | final S2Container root = container.getRoot(); |
52 | |
|
53 | 41 | if (root.hasComponentDef(RequestParser.class)) { |
54 | 12 | final ComponentDef componentDef = root |
55 | |
.getComponentDef(RequestParser.class); |
56 | 12 | this.requestParser = (RequestParser) componentDef.getComponent(); |
57 | 12 | if (logger.isDebugEnabled()) { |
58 | 12 | logger.log("DCUB0009", new Object[] { RequestParser.class, |
59 | |
this.requestParser }); |
60 | |
} |
61 | 12 | } else { |
62 | 29 | this.requestParser = DEFAULT_REQUEST_PARSER; |
63 | 29 | if (logger.isDebugEnabled()) { |
64 | 29 | logger.log("DCUB0008", new Object[] { RequestParser.class, |
65 | |
this.requestParser }); |
66 | |
} |
67 | |
} |
68 | |
|
69 | 41 | if (root.hasComponentDef(FormatPattern.class)) { |
70 | 12 | final ComponentDef componentDef = root |
71 | |
.getComponentDef(FormatPattern.class); |
72 | 12 | this.formatPattern = (FormatPattern) componentDef.getComponent(); |
73 | 12 | if (logger.isDebugEnabled()) { |
74 | 12 | logger.log("DCUB0009", new Object[] { FormatPattern.class, |
75 | |
this.formatPattern }); |
76 | |
} |
77 | 12 | } else { |
78 | 29 | this.formatPattern = new FormatPatternImpl(); |
79 | 29 | if (logger.isDebugEnabled()) { |
80 | 29 | logger.log("DCUB0008", new Object[] { FormatPattern.class, |
81 | |
this.formatPattern }); |
82 | |
} |
83 | |
} |
84 | |
|
85 | 41 | } |
86 | |
|
87 | |
} |