1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.teeda.core.config.faces.impl; |
17 | |
|
18 | |
import java.io.InputStream; |
19 | |
import java.util.LinkedList; |
20 | |
import java.util.List; |
21 | |
|
22 | |
import javax.faces.internal.FacesConfigOptions; |
23 | |
|
24 | |
import org.seasar.framework.container.factory.WebResourceResolver; |
25 | |
import org.seasar.framework.log.Logger; |
26 | |
import org.seasar.framework.util.InputStreamUtil; |
27 | |
import org.seasar.framework.util.StringUtil; |
28 | |
import org.seasar.framework.xml.SaxHandlerParser; |
29 | |
import org.seasar.teeda.core.config.faces.AbstractFacesConfigurator; |
30 | |
import org.seasar.teeda.core.config.faces.element.FacesConfig; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
public class ConfigFilesFacesConfigurator extends AbstractFacesConfigurator { |
36 | |
|
37 | 1 | private static final Logger logger_ = Logger |
38 | 1 | .getLogger(ConfigFilesFacesConfigurator.class); |
39 | |
|
40 | |
private static final String FACES_CONFIG_DELIMETER = ","; |
41 | |
|
42 | 1 | public ConfigFilesFacesConfigurator() { |
43 | 1 | setResourceResolver(new WebResourceResolver()); |
44 | 1 | } |
45 | |
|
46 | |
public FacesConfig configure() { |
47 | 1 | List configs = new LinkedList(); |
48 | 1 | String path = getPath(); |
49 | 1 | if (logger_.isDebugEnabled()) { |
50 | 0 | logger_.debug("target file path = " + path); |
51 | |
} |
52 | 1 | if (path == null) { |
53 | 0 | return null; |
54 | |
} |
55 | 1 | String[] paths = StringUtil.split(path, FACES_CONFIG_DELIMETER); |
56 | |
|
57 | 3 | for (int i = 0; i < paths.length; i++) { |
58 | 2 | final String targetPath = paths[i]; |
59 | 2 | final SaxHandlerParser parser = createSaxHandlerParser(); |
60 | 2 | InputStream is = resourceResolver_ |
61 | |
.getInputStream(targetPath.trim()); |
62 | |
try { |
63 | 2 | configs.add(parser.parse(is, targetPath)); |
64 | |
} finally { |
65 | 2 | InputStreamUtil.close(is); |
66 | 2 | } |
67 | |
} |
68 | 1 | return FacesConfigUtil.collectAllFacesConfig(configs); |
69 | |
} |
70 | |
|
71 | |
public String getPath() { |
72 | 1 | return FacesConfigOptions.getConfigFiles(); |
73 | |
} |
74 | |
} |