org.apache.camel.catalog.RuntimeCamelCatalog Java Examples

The following examples show how to use org.apache.camel.catalog.RuntimeCamelCatalog. 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: TaskHelper.java    From camel-kafka-connector with Apache License 2.0 5 votes vote down vote up
public static String buildUrl(RuntimeCamelCatalog rcc, Map<String, String> props, String componentSchema, String endpointPropertiesPrefix, String pathPropertiesPrefix) throws URISyntaxException {
    Map<String, String> filteredProps = new HashMap<>();
    props.keySet().stream()
            .filter(k -> k.startsWith(endpointPropertiesPrefix) || k.startsWith(pathPropertiesPrefix))
            .forEach(k -> filteredProps.put(k.replace(endpointPropertiesPrefix, "").replace(pathPropertiesPrefix, ""), props.get(k)));
    return rcc.asEndpointUri(componentSchema, filteredProps, false);
}
 
Example #2
Source File: TaskHelperTest.java    From camel-kafka-connector with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildUrlWithRuntimeCatalog() throws URISyntaxException {
    DefaultCamelContext dcc = new DefaultCamelContext();
    RuntimeCamelCatalog rcc = dcc.adapt(ExtendedCamelContext.class).getRuntimeCamelCatalog();
    Map<String, String> props = new HashMap<String, String>() {
        {
            put("camel.source.path.name", "test");
            put("camel.source.endpoint.synchronous", "true");
        }
    };

    String result = TaskHelper.buildUrl(rcc, props, "direct", "camel.source.endpoint.", "camel.source.path.");

    assertEquals("direct:test?synchronous=true", result);

    props = new HashMap<String, String>() {
        {
            put("camel.source.path.port", "8080");
            put("camel.source.path.keyspace", "test");
            put("camel.source.path.hosts", "localhost");
        }
    };

    result = TaskHelper.buildUrl(rcc, props, "cql", "camel.source.endpoint.", "camel.source.path.");

    assertEquals("cql:localhost:8080/test", result);
}
 
Example #3
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 #4
Source File: IntegrationRouteBuilder.java    From syndesis with Apache License 2.0 5 votes vote down vote up
/**
 * If the integration has a scheduler, start the route with a timer or quartz2
 * endpoint.
 */
private ProcessorDefinition<?> configureRouteScheduler(final Flow flow) throws URISyntaxException {
    if (flow.getScheduler().isPresent()) {
        Scheduler scheduler = flow.getScheduler().get();

        // We now support simple timer only, cron support will be supported
        // later on.
        if (scheduler.isTimer()) {
            Map<String, String> properties = new HashMap<>();
            properties.put("timerName", "integration");
            properties.put("period", scheduler.getExpression());

            final RuntimeCamelCatalog catalog = getContext().adapt(ExtendedCamelContext.class).getRuntimeCamelCatalog();
            final String uri = catalog.asEndpointUri("timer", properties, false);

            RouteDefinition route = this.from(uri);
            route.getInput().setId("integration-scheduler");
            flow.getId().ifPresent(route::setId);

            return route;
        }

        throw new IllegalArgumentException("Unsupported scheduler type: " + scheduler.getType());
    }

    return null;
}
 
Example #5
Source File: CamelMainSupport.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public RuntimeCamelCatalog getRuntimeCamelCatalog() {
    return camel.adapt(ExtendedCamelContext.class).getRuntimeCamelCatalog();
}
 
Example #6
Source File: FastCamelContext.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
protected RuntimeCamelCatalog createRuntimeCamelCatalog() {
    return new DefaultRuntimeCamelCatalog();
}