}
private NetUIConfig parse(final String resourcePath, final InputStream is) {
assert is != null;
NetUIConfig netuiConfig = null;
InputStream xsdInputStream = null;
try {
/* parse the config document */
xsdInputStream = SCHEMA_RESOLVER.getInputStream();
final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
dbf.setNamespaceAware(true);
dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
dbf.setAttribute(JAXP_SCHEMA_SOURCE, xsdInputStream);
DocumentBuilder db = dbf.newDocumentBuilder();
db.setErrorHandler(new ErrorHandler() {
public void warning(SAXParseException exception) {
if(LOGGER.isInfoEnabled())
LOGGER.info("Validation warning validating config file \"" + resourcePath +
"\" against XML Schema \"" + SCHEMA_RESOLVER.getResourcePath());
}
public void error(SAXParseException exception) {
throw new ConfigInitializationException("Validation errors occurred parsing the config file \"" +
resourcePath + "\". Cause: " + exception, exception);
}
public void fatalError(SAXParseException exception) {
throw new ConfigInitializationException("Validation errors occurred parsing the config file \"" +
resourcePath + "\". Cause: " + exception, exception);
}
});
db.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicId, String systemId) {
if(systemId.endsWith("/beehive-netui-config.xsd")) {
InputStream inputStream = NetUIConfigParser.class.getClassLoader().getResourceAsStream(CONFIG_SCHEMA);
return new InputSource(inputStream);
}
else return null;
}
});
Document document = db.parse(is);
PageFlowActionInterceptorsConfig pfActionInterceptorsConfig = parsePfActionInterceptorsConfig(document);
PageFlowHandlersConfig pfHandlersConfig = parsePfHandlersConfig(document);
PageFlowConfig pfConfig = parsePfConfig(document);
PageFlowFactoriesConfig pfFactoriesConfig = parsePfFactoriesConfig(document);
SharedFlowRefConfig[] sharedFlowRefConfigs = parseSharedFlowRefConfigs(document);
RequestInterceptorsConfig requestInterceptorsConfig = parseRequestInterceptorsConfig(document);
JspTagConfig jspTagConfig = parseJspTagConfig(document);
ExpressionLanguagesConfig elConfig = parseExpressionLanguageConfig(document);
TypeConverterConfig[] typeConvertersConfig = parseTypeConvertersConfig(document);
UrlConfig urlConfig = parseUrlConfig(document);
IteratorFactoryConfig[] iteratorFactories = parseIteratorFactoryConfig(document);
PrefixHandlerConfig[] prefixHandlers = parsePrefixHandlerConfig(document);
netuiConfig = new NetUIConfig(
pfActionInterceptorsConfig,
pfHandlersConfig,
pfConfig,
pfFactoriesConfig,
sharedFlowRefConfigs,