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 private static final Logger logger = Logger
35 .getLogger(CubbyConfiguration.class);
36
37
38 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 return requestParser;
51 }
52
53
54
55
56 public FormatPattern getFormatPattern() {
57 return formatPattern;
58 }
59
60
61
62
63
64
65
66
67
68
69 public CubbyConfigurationImpl(final S2Container container) {
70 final S2Container root = container.getRoot();
71
72 if (root.hasComponentDef(RequestParser.class)) {
73 final ComponentDef componentDef = root
74 .getComponentDef(RequestParser.class);
75 this.requestParser = (RequestParser) componentDef.getComponent();
76 if (logger.isDebugEnabled()) {
77 logger.log("DCUB0009", new Object[] { RequestParser.class,
78 this.requestParser });
79 }
80 } else {
81 this.requestParser = DEFAULT_REQUEST_PARSER;
82 if (logger.isDebugEnabled()) {
83 logger.log("DCUB0008", new Object[] { RequestParser.class,
84 this.requestParser });
85 }
86 }
87
88 if (root.hasComponentDef(FormatPattern.class)) {
89 final ComponentDef componentDef = root
90 .getComponentDef(FormatPattern.class);
91 this.formatPattern = (FormatPattern) componentDef.getComponent();
92 if (logger.isDebugEnabled()) {
93 logger.log("DCUB0009", new Object[] { FormatPattern.class,
94 this.formatPattern });
95 }
96 } else {
97 this.formatPattern = new FormatPatternImpl();
98 if (logger.isDebugEnabled()) {
99 logger.log("DCUB0008", new Object[] { FormatPattern.class,
100 this.formatPattern });
101 }
102 }
103
104 }
105
106 }