Beispiel #1
0
 /**
  * Stops all the underlying services, jobs and worker threads.
  *
  * @throws LifecycleException in the face of termination failure(s).
  */
 public void destroy() {
   log.info("Destroying control channel.");
   try {
     getContext().stop();
   } catch (Exception e) {
     throw new LifecycleException(e.getLocalizedMessage(), e);
   }
 }
Beispiel #2
0
 /**
  * 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);
   }
 }
 private Resource getScriptResource(final String uri) {
   try {
     if (startsWithIgnoreCase(uri, "classpath:")) {
       final String classPathUri = substringAfter(uri, "classpath:");
       log.info("Loading route list from classpath uri {}.", classPathUri);
       Resource resource = new ClassPathResource(classPathUri);
       log.debug("Resolved '{}' to '{}'.", classPathUri, resource);
       return resource;
     }
     log.info("Loading route list from file system path {}.", uri);
     return new FileSystemResource(uri);
   } catch (Exception e) {
     throw new RuntimeException(e.getLocalizedMessage(), e);
   }
 }
Beispiel #4
0
  /**
   * 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);
    }
  }