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 private static final Logger logger = Logger
19 .getLogger(CubbyConfiguration.class);
20
21 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 return formatPattern;
33 }
34
35 public CubbyConfigurationImpl(final S2Container container) {
36 final S2Container root = container.getRoot();
37
38 if (root.hasComponentDef(RequestParser.class)) {
39 final ComponentDef componentDef = root
40 .getComponentDef(RequestParser.class);
41 this.requestParser = (RequestParser) componentDef.getComponent();
42 if (logger.isDebugEnabled()) {
43 logger.log("DCUB0009", new Object[] { RequestParser.class,
44 this.requestParser });
45 }
46 } else {
47 this.requestParser = DEFAULT_REQUEST_PARSER;
48 if (logger.isDebugEnabled()) {
49 logger.log("DCUB0008", new Object[] { RequestParser.class,
50 this.requestParser });
51 }
52 }
53
54 if (root.hasComponentDef(FormatPattern.class)) {
55 final ComponentDef componentDef = root
56 .getComponentDef(FormatPattern.class);
57 this.formatPattern = (FormatPattern) componentDef.getComponent();
58 if (logger.isDebugEnabled()) {
59 logger.log("DCUB0009", new Object[] { FormatPattern.class,
60 this.formatPattern });
61 }
62 } else {
63 this.formatPattern = new FormatPatternImpl();
64 if (logger.isDebugEnabled()) {
65 logger.log("DCUB0008", new Object[] { FormatPattern.class,
66 this.formatPattern });
67 }
68 }
69
70 }
71
72 }