Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.thetransactioncompany.cors.autoreconf;
CORS servlet filter which has the ability to automatically detect changes to the configuration file and reconfigure itself. The configuration file will be checked the next time the filter is invoked and the poll interval has elapsed since the last check.
 public class AutoReconfigurableCORSFilter implements Filter {

 	private static final Logger LOG = LogManager.getLogManager().getLogger("");

The current CORS filter.
 	private volatile CORSFilter filter;

The configuration file watcher.
 	private volatile CORSConfigurationWatcher watcher;

For loading the CORS filter configuration.
 	public void init(final FilterConfig filterConfig)
 		throws ServletException {
 		 = new CORSConfigurationLoader(filterConfig);
 		 = new CORSConfigurationFileWatcher(filterConfig);

Returns the current CORS filter.

The current CORS filter.
 	public CORSFilter getFilter() {
 		if (.reloadRequired() ||  == null) {
 			synchronized (AutoReconfigurableCORSFilter.class) {
 				if (.reloadRequired() ||  == null) {
 					try {
 						if ( == null) {
 							.info("CORS Filter: Initiated first configuration");
 						} else {
 							.info("CORS Filter: Initiated re-configuration");
 						final Filter oldFilter = ;
 						 = new CORSFilter(.load());
 						if (oldFilter != null) {
 					} catch (CORSConfigurationException e) {
 						.severe("CORS Filter: Failed to instantiate new CORS filter: " + e.getMessage());
 		return ;
	public void doFilter(final ServletRequest requestfinal ServletResponse responsefinal FilterChain chain)
	public void destroy() {
		if ( != null) {
New to GrepCode? Check out our FAQ X