1 | |
package org.seasar.cubby.controller.impl; |
2 | |
|
3 | |
import org.seasar.cubby.action.FormatPattern; |
4 | |
import org.seasar.cubby.action.impl.FormatPatternImpl; |
5 | |
import org.seasar.cubby.controller.CubbyConfiguration; |
6 | |
import org.seasar.cubby.controller.RequestParser; |
7 | |
import org.seasar.framework.container.ComponentDef; |
8 | |
import org.seasar.framework.container.S2Container; |
9 | |
import org.seasar.framework.log.Logger; |
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
public class CubbyConfigurationImpl implements CubbyConfiguration { |
17 | |
|
18 | 1 | private static final Logger logger = Logger |
19 | |
.getLogger(CubbyConfiguration.class); |
20 | |
|
21 | 1 | private static final RequestParser DEFAULT_REQUEST_PARSER = new DefaultRequestParserImpl(); |
22 | |
|
23 | |
private final RequestParser requestParser; |
24 | |
|
25 | |
private final FormatPattern formatPattern; |
26 | |
|
27 | |
public RequestParser getRequestParser() { |
28 | |
return requestParser; |
29 | |
} |
30 | |
|
31 | |
public FormatPattern getFormatPattern() { |
32 | 23 | return formatPattern; |
33 | |
} |
34 | |
|
35 | 21 | public CubbyConfigurationImpl(final S2Container container) { |
36 | 21 | final S2Container root = container.getRoot(); |
37 | |
|
38 | 21 | if (root.hasComponentDef(RequestParser.class)) { |
39 | 5 | final ComponentDef componentDef = root |
40 | |
.getComponentDef(RequestParser.class); |
41 | 5 | this.requestParser = (RequestParser) componentDef.getComponent(); |
42 | 5 | if (logger.isDebugEnabled()) { |
43 | 5 | logger.log("DCUB0009", new Object[] { RequestParser.class, |
44 | |
this.requestParser }); |
45 | |
} |
46 | 5 | } else { |
47 | 16 | this.requestParser = DEFAULT_REQUEST_PARSER; |
48 | 16 | if (logger.isDebugEnabled()) { |
49 | 16 | logger.log("DCUB0008", new Object[] { RequestParser.class, |
50 | |
this.requestParser }); |
51 | |
} |
52 | |
} |
53 | |
|
54 | 21 | if (root.hasComponentDef(FormatPattern.class)) { |
55 | 5 | final ComponentDef componentDef = root |
56 | |
.getComponentDef(FormatPattern.class); |
57 | 5 | this.formatPattern = (FormatPattern) componentDef.getComponent(); |
58 | 5 | if (logger.isDebugEnabled()) { |
59 | 5 | logger.log("DCUB0009", new Object[] { FormatPattern.class, |
60 | |
this.formatPattern }); |
61 | |
} |
62 | 5 | } else { |
63 | 16 | this.formatPattern = new FormatPatternImpl(); |
64 | 16 | if (logger.isDebugEnabled()) { |
65 | 16 | logger.log("DCUB0008", new Object[] { FormatPattern.class, |
66 | |
this.formatPattern }); |
67 | |
} |
68 | |
} |
69 | |
|
70 | 21 | } |
71 | |
|
72 | |
} |