Search in sources :

Example 1 with RoutesLoader

use of org.apache.camel.spi.RoutesLoader in project camel-k-runtime by apache.

the class LoaderSupport method inspectSource.

public static JsonObject inspectSource(CamelContext context, String location, byte[] code) throws Exception {
    final Runtime runtime = Runtime.on(context);
    final RoutesLoader loader = context.adapt(ExtendedCamelContext.class).getRoutesLoader();
    final Collection<RoutesBuilder> builders = loader.findRoutesBuilders(ResourceHelper.fromBytes(location, code));
    for (RoutesBuilder builder : builders) {
        runtime.addRoutes(builder);
    }
    return Json.createObjectBuilder().add("components", extractComponents(context)).add("routes", extractRoutes(context)).add("endpoints", extractEndpoints(context)).build();
}
Also used : Runtime(org.apache.camel.k.Runtime) ExtendedCamelContext(org.apache.camel.ExtendedCamelContext) RoutesLoader(org.apache.camel.spi.RoutesLoader) RoutesBuilder(org.apache.camel.RoutesBuilder)

Aggregations

ExtendedCamelContext (org.apache.camel.ExtendedCamelContext)1 RoutesBuilder (org.apache.camel.RoutesBuilder)1 Runtime (org.apache.camel.k.Runtime)1 RoutesLoader (org.apache.camel.spi.RoutesLoader)1