Version 2.4 of the Java CORS Filter for handling cross-domain requests has added support for automatic reconfiguration. You can change your CORS policy at runtime without having to reload your web service or application. Kudos to Alexey Zvolinsky for contributing this cool new feature.
Automatic reconfiguration is provided by a special variant of the CORS Filter. Stick the following declaration into your
web.xml file to use it:
<filter> <filter-name>CORS</filter-name> <filter-class>com.thetransactioncompany.cors.autoreconf.AutoReconfigurableCORSFilter</filter-class> </filter>
This filter variant must be configured with an external Java properties file. The filter
init-param style configuration will not work here as the
web.xml file may not be modified at runtime.
The configuration file will be polled for changes every 20 seconds. If a change is detected the filter will automatically reload itself with the new configuration. If the new configuration is invalid an error message will be printed to the server log and the filter will continue operating with its previous intact settings.
Check out the CORS Filter docs for the complete instructions on setting up automatic reconfiguration.