Search in sources :

Example 1 with CatalogLSResourceResolver

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();
        }
    };
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) RouteBuilder(org.apache.camel.builder.RouteBuilder) LSResourceResolver(org.w3c.dom.ls.LSResourceResolver) CatalogLSResourceResolver(org.apache.camel.processor.validation.CatalogLSResourceResolver) CatalogLSResourceResolver(org.apache.camel.processor.validation.CatalogLSResourceResolver) CatalogResolver(org.apache.xml.resolver.tools.CatalogResolver) URL(java.net.URL)

Aggregations

URL (java.net.URL)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 JndiRegistry (org.apache.camel.impl.JndiRegistry)1 CatalogLSResourceResolver (org.apache.camel.processor.validation.CatalogLSResourceResolver)1 CatalogResolver (org.apache.xml.resolver.tools.CatalogResolver)1 LSResourceResolver (org.w3c.dom.ls.LSResourceResolver)1