lburgazzoli commented on a change in pull request #4998: URL: https://github.com/apache/camel/pull/4998#discussion_r568802313
########## File path: core/camel-xml-jaxb/src/main/java/org/apache/camel/xml/jaxb/JaxbXmlRoutesBuilderLoader.java ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.xml.jaxb; + +import org.apache.camel.CamelContext; +import org.apache.camel.CamelContextAware; +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.RouteTemplatesDefinition; +import org.apache.camel.model.RoutesDefinition; +import org.apache.camel.model.rest.RestsDefinition; +import org.apache.camel.spi.Resource; +import org.apache.camel.spi.RoutesBuilderLoader; + +import static org.apache.camel.xml.jaxb.JaxbHelper.loadRestsDefinition; +import static org.apache.camel.xml.jaxb.JaxbHelper.loadRouteTemplatesDefinition; +import static org.apache.camel.xml.jaxb.JaxbHelper.loadRoutesDefinition; + +public class JaxbXmlRoutesBuilderLoader implements RoutesBuilderLoader, CamelContextAware { Review comment: So the `RoutesBuilderLoader` is not actually discovered using a service mechanism but in fact the default implementation is a facade to the real one which behind the scene does something like: ```java @Override public RoutesBuilder loadRoutesBuilder(Resource resource) throws Exception { // language is derived from the file extension final String language = FileUtil.onlyExt(resource.getLocation(), true); return getLoader(language).loadRoutesBuilder(resource); } private RoutesBuilderLoader getLoader(String language) { RoutesBuilderLoader answer = getCamelContext().getRegistry().lookupByNameAndType( language, RoutesBuilderLoader.class); if (answer == null) { // lookup the loader in // META-INF/services/org/apache/camel/routes-loaders/${language} } return answer; } ``` So it looks up the real loader using the file extension, and the real loader is supposed to be either bound to the registry or defined through `META-INF/services/org/apache/camel/routes-loaders`. I'm not very convinced by this patter so I'll split the loader interface from the language specific one. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org