}
protected Endpoint createEndpoint(String uri, final String remaining, Map<String, Object> parameters) throws Exception {
String resourceUri = remaining;
LOG.debug("{} using schema resource: {}", this, resourceUri);
final XsltBuilder xslt = getCamelContext().getInjector().newInstance(XsltBuilder.class);
// lets allow the converter to be configured
XmlConverter converter = resolveAndRemoveReferenceParameter(parameters, "converter", XmlConverter.class);
if (converter == null) {
converter = getXmlConverter();
}
if (converter != null) {
xslt.setConverter(converter);
}
String transformerFactoryClassName = getAndRemoveParameter(parameters, "transformerFactoryClass", String.class);
TransformerFactory factory = null;
if (transformerFactoryClassName != null) {
// provide the class loader of this component to work in OSGi environments
Class<?> factoryClass = getCamelContext().getClassResolver().resolveClass(transformerFactoryClassName, XsltComponent.class.getClassLoader());
if (factoryClass != null) {
factory = (TransformerFactory) getCamelContext().getInjector().newInstance(factoryClass);
} else {
LOG.warn("Cannot find the TransformerFactoryClass with the class name: {}", transformerFactoryClassName);
}
}
if (parameters.get("transformerFactory") != null) {
factory = resolveAndRemoveReferenceParameter(parameters, "transformerFactory", TransformerFactory.class);
}
if (factory != null) {
xslt.getConverter().setTransformerFactory(factory);
}
ResultHandlerFactory resultHandlerFactory = resolveAndRemoveReferenceParameter(parameters, "resultHandlerFactory", ResultHandlerFactory.class);
if (resultHandlerFactory != null) {
xslt.setResultHandlerFactory(resultHandlerFactory);
}
Boolean failOnNullBody = getAndRemoveParameter(parameters, "failOnNullBody", Boolean.class);
if (failOnNullBody != null) {
xslt.setFailOnNullBody(failOnNullBody);
}
String output = getAndRemoveParameter(parameters, "output", String.class);
configureOutput(xslt, output);
Integer cs = getAndRemoveParameter(parameters, "transformerCacheSize", Integer.class, Integer.valueOf(0));
xslt.transformerCacheSize(cs);
// default to use the cache option from the component if the endpoint did not have the contentCache parameter
boolean cache = getAndRemoveParameter(parameters, "contentCache", Boolean.class, contentCache);
// if its a http uri, then append additional parameters as they are part of the uri
if (ResourceHelper.isHttpUri(resourceUri)) {
resourceUri = ResourceHelper.appendParameters(resourceUri, parameters);
}
// lookup custom resolver to use
URIResolver resolver = resolveAndRemoveReferenceParameter(parameters, "uriResolver", URIResolver.class);
if (resolver == null) {
// not in endpoint then use component specific resolver
resolver = getUriResolver();
}
if (resolver == null) {
// fallback to use a Camel specific resolver
resolver = new XsltUriResolver(getCamelContext().getClassResolver(), remaining);
}
// set resolver before input stream as resolver is used when loading the input stream
xslt.setUriResolver(resolver);
configureXslt(xslt, uri, remaining, parameters);
return new XsltEndpoint(uri, this, xslt, resourceUri, cache);
}