org.apache.camel.spi.XMLRoutesDefinitionLoader Java Examples

The following examples show how to use org.apache.camel.spi.XMLRoutesDefinitionLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntegrationRouteBuilder.java    From syndesis with Apache License 2.0 6 votes vote down vote up
private static Object mandatoryLoadResource(CamelContext context, String resource) {
    Object instance = null;

    if (resource.startsWith("classpath:")) {
        try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, resource)) {
            ExtendedCamelContext extendedCamelContext = context.adapt(ExtendedCamelContext.class);
            XMLRoutesDefinitionLoader loader = extendedCamelContext.getXMLRoutesDefinitionLoader();
            instance = loader.loadRoutesDefinition(context, is);
        } catch (Exception e) {
            throw new IllegalArgumentException(e);
        }
    } else if (resource.startsWith("class:")) {
        Class<?> type = context.getClassResolver().resolveClass(resource.substring("class:".length()));
        instance = context.getInjector().newInstance(type);
    } else if (resource.startsWith("bean:")) {
        instance = context.getRegistry().lookupByName(resource.substring("bean:".length()));
    }

    if (instance == null) {
        throw new IllegalArgumentException("Unable to resolve resource: " + resource);
    }

    return instance;
}
 
Example #2
Source File: CamelContextRecorder.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<CamelContext> createContext(
        RuntimeValue<Registry> registry,
        RuntimeValue<TypeConverterRegistry> typeConverterRegistry,
        RuntimeValue<ModelJAXBContextFactory> contextFactory,
        RuntimeValue<XMLRoutesDefinitionLoader> xmlLoader,
        RuntimeValue<ModelToXMLDumper> xmlModelDumper,
        RuntimeValue<FactoryFinderResolver> factoryFinderResolver,
        BeanContainer beanContainer,
        String version,
        CamelConfig config) {

    FastCamelContext context = new FastCamelContext(
            factoryFinderResolver.getValue(),
            version,
            xmlLoader.getValue(),
            xmlModelDumper.getValue());

    context.setDefaultExtension(RuntimeCamelCatalog.class, () -> new CamelRuntimeCatalog(config.runtimeCatalog));
    context.setRegistry(registry.getValue());
    context.setTypeConverterRegistry(typeConverterRegistry.getValue());
    context.setLoadTypeConverters(false);
    context.setModelJAXBContextFactory(contextFactory.getValue());
    context.build();
    context.addLifecycleStrategy(new CamelLifecycleEventBridge());
    context.getManagementStrategy().addEventNotifier(new CamelManagementEventBridge());

    // register to the container
    beanContainer.instance(CamelProducers.class).setContext(context);

    return new RuntimeValue<>(context);
}
 
Example #3
Source File: CamelMainRecorder.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public RuntimeValue<RoutesCollector> newRoutesCollector(
        RuntimeValue<RegistryRoutesLoader> registryRoutesLoader,
        RuntimeValue<XMLRoutesDefinitionLoader> xmlRoutesLoader) {

    return new RuntimeValue<>(new CamelMainRoutesCollector(registryRoutesLoader.getValue(), xmlRoutesLoader.getValue()));
}
 
Example #4
Source File: CamelMainRoutesCollector.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public CamelMainRoutesCollector(RegistryRoutesLoader registryRoutesLoader, XMLRoutesDefinitionLoader xmlRoutesLoader) {
    this.registryRoutesLoader = registryRoutesLoader;
    this.xmlRoutesLoader = xmlRoutesLoader;
}
 
Example #5
Source File: CamelMainRoutesCollector.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public XMLRoutesDefinitionLoader getXmlRoutesLoader() {
    return xmlRoutesLoader;
}
 
Example #6
Source File: XmlIoRecorder.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public RuntimeValue<XMLRoutesDefinitionLoader> newIoXMLRoutesDefinitionLoader() {
    return new RuntimeValue<>(new ModelParserXMLRoutesDefinitionLoader());
}
 
Example #7
Source File: CamelRoutesLoaderBuildItems.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public Xml(RuntimeValue<XMLRoutesDefinitionLoader> value) {
    this.value = value;
}
 
Example #8
Source File: CamelRoutesLoaderBuildItems.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public RuntimeValue<XMLRoutesDefinitionLoader> getLoader() {
    return value;
}
 
Example #9
Source File: CamelRecorder.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public RuntimeValue<XMLRoutesDefinitionLoader> newDisabledXMLRoutesDefinitionLoader() {
    return new RuntimeValue<>(new DisabledXMLRoutesDefinitionLoader());
}