Java Code Examples for org.apache.camel.model.ModelCamelContext#addRouteDefinitions()

The following examples show how to use org.apache.camel.model.ModelCamelContext#addRouteDefinitions() . 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: SpringContextRouteLoader.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void addRoutesToCamelContext() throws Exception
{
    ModelCamelContext modelCamelContext = (ModelCamelContext) applicationContext.getBean(camelContextId);
    ArrayList<RouteDefinition> routeDefinitions = (ArrayList<RouteDefinition>) applicationContext.getBean(routeContextId);
    modelCamelContext.addRouteDefinitions(routeDefinitions);
}
 
Example 2
Source File: IntegrationRouteBuilder.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private void loadFragments(Step step) {
    if (StepKind.extension != step.getStepKind()) {
        return;
    }

    final StepAction action = step.getActionAs(StepAction.class)
                                  .orElseThrow(() -> new IllegalArgumentException(
                                          String.format("Missing step action on step: %s - %s", step.getId(), step.getName())));

    if (action.getDescriptor().getKind() == StepAction.Kind.ENDPOINT) {
        final ModelCamelContext context = getContext();
        final String resource = action.getDescriptor().getResource();

        if (ObjectHelper.isNotEmpty(resource) && resources.add(resource)) {
            final Object instance = mandatoryLoadResource(context, resource);
            final RoutesDefinition definitions = mandatoryConvertToRoutesDefinition(resource, instance);

            LOGGER.debug("Resolved resource: {} as {}", resource, instance.getClass());

            try {
                context.addRouteDefinitions(definitions.getRoutes());
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }
        }
    }
}
 
Example 3
Source File: XmlModel.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
public CamelContext createContext(Collection<RouteDefinition> routes) throws Exception {
    ModelCamelContext context = new DefaultCamelContext();
    context.addRouteDefinitions(routes);
    return context;
}