/** * Adds a set of routing/configuration rules to the host {@link CamelContext} using the supplied * {@link RouteLoader}. * * @param loader The loader for the routes you wish to load. */ public void load(final RouteLoader loader) { notNull(loader, "Route loader cannot be null."); try { log.debug("Adding routes to context {}.", hostContext.getName()); hostContext.addRoutes(loader.load()); } catch (Exception e) { throw new LifecycleException(e.getLocalizedMessage(), e); } }
/** * Store a notification of the application state and hour * * @param context of the Camel app */ @Override public void onContextStop(CamelContext context) { log.debug("Stopped " + context.getName()); InstanceState instanceState = new InstanceState(); instanceState.setName(context.getName()); instanceState.setState(State.Stopped); instanceState.setTimestamp(DateTime.now().toString()); repository.save(instanceState); }
/** * Activates the control channel, which will from now on behave in accordance with the routes you * set up in your bootstrap script(s). * * <p>See {@link ControlChannel#waitShutdown} and {@link ControlChannel#sendShutdownSignal()} for * instructions on shutting down an activated channel. */ public void activate() { try { log.info("Activating control channel."); final CamelContext context = getContext(); log.info("Configuring trace interceptor for {}.", context.getName()); TraceBuilder builder = new TraceBuilder(getConfig(), tracer); context.addInterceptStrategy(builder.build()); log.debug("Starting underlying camel context."); context.start(); } catch (Exception e) { throw new LifecycleException(e.getLocalizedMessage(), e); } }
public ControlChannel( final CamelContext hostContext, final Tracer tracer, final Configuration config) { this( hostContext, tracer, config, hostContext.getRegistry().lookup(Environment.SHUTDOWN_CHANNEL_ID, ShutdownChannel.class)); }
/** * Constructs a dispatching interceptor * * @param camelContext Camel context */ public ConsumerDispatchingInterceptor(CamelContext camelContext) { super(); try { camelContext.addStartupListener(this); } catch (Exception e) { throw new RuntimeCamelException(e); } }
/** * Dynamically find all {@link MllpTransactionEndpoint} containing a reference to this instance * and append it to the routeId list * * @param camelContext camel context */ private void collectTransactionTargets(CamelContext camelContext) { for (Route route : camelContext.getRoutes()) { if (route.getEndpoint() instanceof MllpTransactionEndpoint) { MllpTransactionEndpoint<?> endpoint = (MllpTransactionEndpoint<?>) route.getEndpoint(); if (endpoint.getDispatcher() == this) { addTransactionRoutes(route.getId()); } } } }
private boolean addTargets(CamelContext camelContext) throws CamelException { for (String routeId : routeIds) { try { Mina2Consumer consumer = (Mina2Consumer) camelContext.getRoute(routeId).getConsumer(); Hl7v2Interceptor interceptor = (Hl7v2Interceptor) consumer.getProcessor(); while (!(interceptor instanceof ConsumerStringProcessingInterceptor)) { interceptor = (Hl7v2Interceptor) interceptor.getWrappedProcessor(); } LOG.debug("Adding MLLP transaction route {} to dispatcher", routeId); map.put(routeId, (Hl7v2Interceptor) interceptor.getWrappedProcessor()); } catch (NullPointerException e) { throw new CamelException( "Route with ID='" + routeId + "' not found or is not an IPF MLLP route", e); } catch (ClassCastException e) { throw new CamelException("Route with ID='" + routeId + "' is not an IPF MLLP route", e); } } return !map.isEmpty(); }