use of org.apache.camel.processor.validation.CatalogLSResourceResolver in project camel by apache.
the class ValidatorWithResourceResolverRouteTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
// we have to do it here, because we need the context created first
CatalogManager.getStaticManager().setIgnoreMissingProperties(true);
CatalogResolver catalogResolver = new CatalogResolver(true);
URL catalogUrl = ResourceHelper.resolveMandatoryResourceAsUrl(context.getClassResolver(), "org/apache/camel/component/validator/catalog.cat");
catalogResolver.getCatalog().parseCatalog(catalogUrl);
LSResourceResolver resourceResolver = new CatalogLSResourceResolver(catalogResolver);
JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
registry.bind("resourceResolver", resourceResolver);
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").doTry().to("validator:org/apache/camel/component/validator/report.xsd?resourceResolver=#resourceResolver").to("mock:valid").doCatch(ValidationException.class).to("mock:invalid").doFinally().to("mock:finally").end();
}
};
}
Aggregations