| 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.net.URL; |
| 20 | |
import java.util.ArrayList; |
| 21 | |
import java.util.Iterator; |
| 22 | |
import java.util.List; |
| 23 | |
|
| 24 | |
import org.seasar.framework.log.Logger; |
| 25 | |
import org.seasar.framework.util.ClassLoaderUtil; |
| 26 | |
import org.seasar.framework.util.InputStreamUtil; |
| 27 | |
import org.seasar.framework.util.URLUtil; |
| 28 | |
import org.seasar.framework.xml.SaxHandlerParser; |
| 29 | |
import org.seasar.teeda.core.JsfConstants; |
| 30 | |
import org.seasar.teeda.core.config.faces.AbstractFacesConfigurator; |
| 31 | |
import org.seasar.teeda.core.config.faces.element.FacesConfig; |
| 32 | |
import org.seasar.teeda.core.util.IteratorUtil; |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
public class MetaInfFacesConfigurator extends AbstractFacesConfigurator { |
| 38 | |
|
| 39 | 1 | private static final Logger logger_ = Logger |
| 40 | 1 | .getLogger(MetaInfFacesConfigurator.class); |
| 41 | |
|
| 42 | 1 | private String path_ = JsfConstants.WEB_INF_LIB; |
| 43 | |
|
| 44 | 1 | public MetaInfFacesConfigurator() { |
| 45 | 1 | } |
| 46 | |
|
| 47 | |
public FacesConfig configure() { |
| 48 | 1 | String path = getPath(); |
| 49 | 1 | if (logger_.isDebugEnabled()) { |
| 50 | 0 | logger_.debug("target file path = " + path); |
| 51 | |
} |
| 52 | 1 | SaxHandlerParser parser = createSaxHandlerParser(); |
| 53 | 1 | List list = new ArrayList(); |
| 54 | 1 | ClassLoader loader = ClassLoaderUtil.getClassLoader(this.getClass()); |
| 55 | 1 | for (Iterator itr = IteratorUtil.getResourcesIterator(loader, |
| 56 | 2 | JsfConstants.FACES_CONFIG_RESOURCES); itr.hasNext();) { |
| 57 | 1 | URL url = (URL) itr.next(); |
| 58 | 1 | if (url.toExternalForm().indexOf(path) != -1) { |
| 59 | 1 | InputStream is = URLUtil.openStream(url); |
| 60 | |
try { |
| 61 | 1 | FacesConfig config = (FacesConfig) parser.parse(is, url |
| 62 | |
.toExternalForm()); |
| 63 | 1 | list.add(config); |
| 64 | |
} finally { |
| 65 | 1 | InputStreamUtil.close(is); |
| 66 | 1 | } |
| 67 | |
} |
| 68 | |
} |
| 69 | 1 | return FacesConfigUtil.collectAllFacesConfig(list); |
| 70 | |
} |
| 71 | |
|
| 72 | |
public String getPath() { |
| 73 | 1 | return path_; |
| 74 | |
} |
| 75 | |
|
| 76 | |
public void setPath(String path) { |
| 77 | 1 | path_ = path; |
| 78 | 1 | } |
| 79 | |
} |