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