Search code examples
jettywro4j

Is there a way to configure wro4j to pick up changed files without restart during development?


I am using Embedded Jetty, had the maxCachedFiles = 0 and useFileMappedBuffer=false, so on a Windows machine it picks up template file changes and js/css changes.

Now that we started using wro4j, we are loosing this handy hot-deployment feature.

Is there a way to configure wro4j to pick up changed files without restart during development?


Solution

  • There are a couple of configuration properties which can be used to achieve that:

    # explicitly invalidates the cache each 5 seconds
    cacheUpdatePeriod=5
    # check for changes each 5 seconds and invalidates the cache only when a change is detected
    resourceWatcherUpdatePeriod=5
    

    The "resourceWatcherUpdatePeriod" seems to be broken in 1.7.0, but will be fixed in next release. Also it is possible to explicitly invalidate the cache using a http endpoint (aka request handler) available in development mode only:

    /wro/wroAPI/reloadCache 
    

    or through JMX. More details about request handlers can be found here: https://code.google.com/p/wro4j/wiki/RequestHandler