| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.teeda.core.config.webapp.impl; |
| 17 | |
|
| 18 | |
import java.io.InputStream; |
| 19 | |
|
| 20 | |
import javax.xml.parsers.SAXParser; |
| 21 | |
|
| 22 | |
import org.seasar.framework.util.SAXParserFactoryUtil; |
| 23 | |
import org.seasar.framework.xml.SaxHandler; |
| 24 | |
import org.seasar.framework.xml.SaxHandlerParser; |
| 25 | |
import org.seasar.framework.xml.TagHandlerRule; |
| 26 | |
import org.seasar.teeda.core.config.webapp.WebappConfigBuilder; |
| 27 | |
import org.seasar.teeda.core.config.webapp.element.WebappConfig; |
| 28 | |
import org.seasar.teeda.core.config.webapp.rule.WebappTagHandlerRule; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | 4 | public class WebappConfigBuilderImpl implements WebappConfigBuilder { |
| 34 | |
|
| 35 | 1 | private static TagHandlerRule rule_ = new WebappTagHandlerRule(); |
| 36 | |
|
| 37 | |
private static final String DTD_PATH = "javax/servlet/resources/web-app_2_3.dtd"; |
| 38 | |
|
| 39 | |
private static final String PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"; |
| 40 | |
|
| 41 | |
public WebappConfig build(InputStream is, String path) { |
| 42 | 4 | SaxHandlerParser parser = createSaxHandlerParser(); |
| 43 | 4 | return (WebappConfig) parser.parse(is); |
| 44 | |
} |
| 45 | |
|
| 46 | |
private SaxHandlerParser createSaxHandlerParser() { |
| 47 | 4 | SAXParser saxParser = SAXParserFactoryUtil.newSAXParser(); |
| 48 | 4 | SaxHandler handler = new SaxHandler(rule_); |
| 49 | 4 | handler.registerDtdPath(PUBLIC_ID, DTD_PATH); |
| 50 | 4 | return new SaxHandlerParser(handler, saxParser); |
| 51 | |
} |
| 52 | |
|
| 53 | |
} |