Class RouteWatcherReloadStrategy

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.ReloadStrategy, org.apache.camel.spi.ResourceReloadStrategy, org.apache.camel.StatefulService, org.apache.camel.StaticService, org.apache.camel.SuspendableService
Direct Known Subclasses:
RouteOnDemandReloadStrategy

public class RouteWatcherReloadStrategy extends FileWatcherResourceReloadStrategy
Watcher strategy for triggering reloading of Camel routes in a running Camel application. The strategy watches a directory (and subdirectories) for file changes. By default, the strategy is matching Camel routes in XML or YAML files.
  • Field Details

    • RELOAD_RESOURCES

      public static final String RELOAD_RESOURCES
      Special when reloading routes(s) requires to also ensure other resources are reloaded together such as camel-java-joor-dsl to ensure all resources are compiled in the same compilation unit.
      See Also:
  • Constructor Details

    • RouteWatcherReloadStrategy

      public RouteWatcherReloadStrategy()
    • RouteWatcherReloadStrategy

      public RouteWatcherReloadStrategy(String directory)
    • RouteWatcherReloadStrategy

      public RouteWatcherReloadStrategy(String directory, boolean recursive)
  • Method Details

    • getPattern

      public String getPattern()
    • setPattern

      public void setPattern(String pattern)
      Used for inclusive filtering of routes from directories. Typical used for specifying to accept routes in XML or YAML files, such as *.yaml,*.xml. Multiple patterns can be specified separated by comma.
    • isRemoveAllRoutes

      public boolean isRemoveAllRoutes()
    • setRemoveAllRoutes

      public void setRemoveAllRoutes(boolean removeAllRoutes)
      When reloading routes should all existing routes be stopped and removed. By default, Camel will stop and remove all existing routes before reloading routes. This ensures that only the reloaded routes will be active. If disabled then only routes with the same route id is updated, and any existing routes are continued to run.
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class FileWatcherResourceReloadStrategy
      Throws:
      Exception
    • startupMessage

      protected String startupMessage(File dir)
      Overrides:
      startupMessage in class FileWatcherResourceReloadStrategy
    • onPropertiesReload

      protected boolean onPropertiesReload(org.apache.camel.spi.Resource resource, boolean reloadRoutes) throws Exception
      Throws:
      Exception
    • onRouteReload

      protected void onRouteReload(Collection<org.apache.camel.spi.Resource> resources, boolean removeEverything)