Package org.apache.camel.spi

Examples of org.apache.camel.spi.RouteContext


            // TOOD refactor to avoid this messyness...
            ArrayList<Route> list = new ArrayList<Route>();
            RouteDefinition route = new RouteDefinition();
            route.setCamelContext(first.getBuilder().getProcessBuilder().getContext());
            RouteContext routeContext = new DefaultRouteContext(route, null, list);

            overdueAction = overdueProcessors.createOutputsProcessor(routeContext);
        }
        return overdueAction;
    }
View Full Code Here


        if (handler != null) {
            setErrorHandlerBuilderIfNull(handler);
        }

        for (FromDefinition fromType : inputs) {
            RouteContext routeContext = addRoutes(routes, fromType);
            answer.add(routeContext);
        }
        return answer;
    }
View Full Code Here

    }

    // Implementation methods
    // -------------------------------------------------------------------------
    protected RouteContext addRoutes(Collection<Route> routes, FromDefinition fromType) throws Exception {
        RouteContext routeContext = new DefaultRouteContext(this, fromType, routes);

        // configure tracing
        if (trace != null) {
            routeContext.setTracing(isTrace());
            if (isTrace()) {
                if (log.isDebugEnabled()) {
                    log.debug("Tracing is enabled on route: " + this);
                }
                // only add a new tracer if not already a global configured on camel context
                if (Tracer.getTracer(camelContext) == null) {
                    Tracer tracer = Tracer.createTracer(camelContext);
                    addInterceptStrategy(tracer);
                }
            }
        }

        // configure stream caching
        if (streamCache != null) {
            routeContext.setStreamCaching(isStreamCache());
            if (isStreamCache()) {
                if (log.isDebugEnabled()) {
                    log.debug("StramCaching is enabled on route: " + this);
                }
                // only add a new stream cache if not already a global configured on camel context
                if (StreamCaching.getStreamCaching(camelContext) == null) {
                    addInterceptStrategy(new StreamCaching());
                }
            }
        }

        // configure handle fault
        if (handleFault != null) {
            routeContext.setHandleFault(isHandleFault());
            if (isHandleFault()) {
                if (log.isDebugEnabled()) {
                    log.debug("HandleFault is enabled on route: " + this);
                }
                // only add a new handle fault if not already a global configured on camel context
                if (HandleFault.getHandleFault(camelContext) == null) {
                    addInterceptStrategy(new HandleFault());
                }
            }
        }

        // configure delayer
        if (delayer != null) {
            routeContext.setDelayer(getDelayer());
            if (getDelayer() != null) {
                long millis = getDelayer();
                if (millis > 0) {
                    if (log.isDebugEnabled()) {
                        log.debug("Delayer is enabled with: " + millis + " ms. on route: " + this);
                    }
                    addInterceptStrategy(new Delayer(millis));
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Delayer is disabled on route: " + this);
                    }
                }
            }
        }

        // should inherit the intercept strategies we have defined
        routeContext.setInterceptStrategies(this.getInterceptStrategies());
        // force endpoint resolution
        routeContext.getEndpoint();
        if (camelContext != null) {
            camelContext.getLifecycleStrategy().onRouteContextCreate(routeContext);
        }

        List<ProcessorDefinition> list = new ArrayList<ProcessorDefinition>(outputs);
        for (ProcessorDefinition output : list) {
            output.addRoutes(routeContext, routes);
        }

        routeContext.commit();
        return routeContext;
    }
View Full Code Here

        testEndpointConfiguration();
    }
   
    public void testReferenceEndpointFromOtherCamelContext() throws Exception {
        CamelContext context = applicationContext.getBean("camel2", CamelContext.class);
        RouteContext routeContext = new DefaultRouteContext(context);
        try {
            routeContext.resolveEndpoint(null, "endpoint1");
            fail("Should have thrown exception");
        } catch (NoSuchEndpointException exception) {
            assertTrue("Get a wrong exception message", exception.getMessage().contains("make sure the endpoint has the same camel context as the route does"));
        }
    }
View Full Code Here

    }

    public Processor getOverdueAction() throws Exception {
        if (overdueAction == null && overdueProcessors != null) {
            RouteDefinition route = new RouteDefinition();
            RouteContext routeContext = new DefaultRouteContext(first.getBuilder().getProcessBuilder().getContext(),
                    route, null, new ArrayList<Route>());

            overdueAction = overdueProcessors.createOutputsProcessor(routeContext);
        }
        return overdueAction;
View Full Code Here

            if (isShareUnitOfWork()) {
                prepareSharedUnitOfWork(copy, exchange);
            }

            // and add the pair
            RouteContext routeContext = exchange.getUnitOfWork() != null ? exchange.getUnitOfWork().getRouteContext() : null;
            result.add(createProcessorExchangePair(index++, processor, copy, routeContext));
        }

        if (exchange.getException() != null) {
            // force any exceptions occurred during creation of exchange paris to be thrown
View Full Code Here

            if (isShareUnitOfWork()) {
                prepareSharedUnitOfWork(copy, exchange);
            }

            // and add the pair
            RouteContext routeContext = exchange.getUnitOfWork() != null ? exchange.getUnitOfWork().getRouteContext() : null;
            result.add(createProcessorExchangePair(index++, processor, copy, routeContext));
        }

        if (exchange.getException() != null) {
            // force any exceptions occurred during creation of exchange paris to be thrown
View Full Code Here

    }

    public Processor getOverdueAction() throws Exception {
        if (overdueAction == null && overdueProcessors != null) {
            RouteDefinition route = new RouteDefinition();
            RouteContext routeContext = new DefaultRouteContext(first.getBuilder().getProcessBuilder().getContext(),
                    route, null, new ArrayList<Route>());

            overdueAction = overdueProcessors.createOutputsProcessor(routeContext);
        }
        return overdueAction;
View Full Code Here

            if (exchange.getUnitOfWork() != null && exchange.getUnitOfWork().getRouteContext() != null) {
                // wrap the producer in error handler so we have fine grained error handling on
                // the output side instead of the input side
                // this is needed to support redelivery on that output alone and not doing redelivery
                // for the entire multicast block again which will start from scratch again
                RouteContext routeContext = exchange.getUnitOfWork().getRouteContext();
                ErrorHandlerBuilder builder = routeContext.getRoute().getErrorHandlerBuilder();

                // create error handler (create error handler directly to keep it light weight,
                // instead of using ProcessorDefinition.wrapInErrorHandler)
                producer = builder.createErrorHandler(routeContext, producer);
            }
View Full Code Here

        if (handler != null) {
            setErrorHandlerBuilderIfNull(handler);
        }

        for (FromDefinition fromType : inputs) {
            RouteContext routeContext;
            try {
                routeContext = addRoutes(routes, fromType);
            } catch (FailedToCreateRouteException e) {
                throw e;
            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.RouteContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.