List<File> filesToWatch = configurationWatchList.getCopyOfFileWatchList(); if (filesToWatch == null || filesToWatch.isEmpty()) { addInfo("Empty watch file list. Disabling "); if (!configurationWatchList.changeDetected()) { return; URL mainConfigurationURL = configurationWatchList.getMainURL();
public static void setMainWatchURL(Context context, URL url) { ConfigurationWatchList cwl = getConfigurationWatchList(context); if (cwl == null) { cwl = new ConfigurationWatchList(); cwl.setContext(context); context.putObject(CoreConstants.CONFIGURATION_WATCH_LIST, cwl); } else { cwl.clear(); } setConfigurationWatchListResetFlag(context, true); cwl.setMainURL(url); }
private void addAsFileToWatch(URL url) { File file = convertToFile(url); if (file != null) { fileWatchList.add(file); lastModifiedList.add(file.lastModified()); } }
@Override public void start() { configurationWatchList = ConfigurationWatchListUtil.getConfigurationWatchList(context); if (configurationWatchList != null) { mainConfigurationURL = configurationWatchList.getMainURL(); if (mainConfigurationURL == null) { addWarn("Due to missing top level configuration file, automatic reconfiguration is impossible."); return; } List<File> watchList = configurationWatchList.getCopyOfFileWatchList(); long inSeconds = refreshPeriod / 1000; addInfo("Will scan for changes in [" + watchList + "] every " + inSeconds + " seconds. "); synchronized (configurationWatchList) { updateNextCheck(System.currentTimeMillis()); } super.start(); } else { addWarn("Empty ConfigurationWatchList in context"); } }
public static URL getMainWatchURL(Context context) { ConfigurationWatchList cwl = getConfigurationWatchList(context); if (cwl == null) { return null; } else { return cwl.getMainURL(); } }
/** * The mainURL for the configuration file. Null values are allowed. * @param mainURL */ public void setMainURL(URL mainURL) { // main url can be null this.mainURL = mainURL; if (mainURL != null) addAsFileToWatch(mainURL); }
@Test // See http://jira.qos.ch/browse/LBCORE-119 public void fileToURLAndBack() throws MalformedURLException { File file = new File("a b.xml"); URL url = file.toURI().toURL(); ConfigurationWatchList cwl = new ConfigurationWatchList(); File back = cwl.convertToFile(url); assertEquals(file.getName(), back.getName()); } }
public static void addToWatchList(Context context, URL url) { ConfigurationWatchList cwl = getConfigurationWatchList(context); if (cwl == null) { addWarn(context, "Null ConfigurationWatchList. Cannot add " + url); } else { addInfo(context, "Adding [" + url + "] to configuration watch list."); cwl.addToWatchList(url); } }
@SuppressWarnings("deprecation") File convertToFile(URL url) { String protocol = url.getProtocol(); if ("file".equals(protocol)) { return new File(URLDecoder.decode(url.getFile())); } else { addInfo("URL [" + url + "] is not of type file"); return null; } }
void detachReconfigurationToNewThread() { addInfo("Detected change in [" + configurationWatchList.getCopyOfFileWatchList() + "]"); context.getExecutorService().submit(new ReconfiguringThread()); }
public ConfigurationWatchList buildClone() { ConfigurationWatchList out = new ConfigurationWatchList(); out.mainURL = this.mainURL; out.fileWatchList = new ArrayList<File>(this.fileWatchList); out.lastModifiedList = new ArrayList<Long>(this.lastModifiedList); return out; }
@Override public void start() { configurationWatchList = ConfigurationWatchListUtil.getConfigurationWatchList(context); if (configurationWatchList != null) { mainConfigurationURL = configurationWatchList.getMainURL(); if(mainConfigurationURL == null) { addWarn("Due to missing top level configuration file, automatic reconfiguration is impossible."); return; } List<File> watchList = configurationWatchList.getCopyOfFileWatchList(); long inSeconds = refreshPeriod / 1000; addInfo("Will scan for changes in [" + watchList + "] every " + inSeconds + " seconds. "); synchronized (configurationWatchList) { updateNextCheck(System.currentTimeMillis()); } super.start(); } else { addWarn("Empty ConfigurationWatchList in context"); } }
public static URL getMainWatchURL(Context context) { ConfigurationWatchList cwl = getConfigurationWatchList(context); if (cwl == null) { return null; } else { return cwl.getMainURL(); } }
public void addToWatchList(URL url) { addAsFileToWatch(url); }
public static void addToWatchList(Context context, URL url) { ConfigurationWatchList cwl = getConfigurationWatchList(context); if (cwl == null) { addWarn(context, "Null ConfigurationWatchList. Cannot add " + url); } else { addInfo(context, "Adding [" + url + "] to configuration watch list."); cwl.addToWatchList(url); } }
@SuppressWarnings("deprecation") File convertToFile(URL url) { String protocol = url.getProtocol(); if ("file".equals(protocol)) { return new File(URLDecoder.decode(url.getFile())); } else { addInfo("URL [" + url + "] is not of type file"); return null; } }
void detachReconfigurationToNewThread() { addInfo("Detected change in [" + configurationWatchList.getCopyOfFileWatchList() + "]"); context.getExecutorService().submit(new ReconfiguringThread()); }
public ConfigurationWatchList buildClone() { ConfigurationWatchList out = new ConfigurationWatchList(); out.mainURL = this.mainURL; out.fileWatchList = new ArrayList<File>(this.fileWatchList); out.lastModifiedList = new ArrayList<Long>(this.lastModifiedList); return out; }
public static void setMainWatchURL(Context context, URL url) { ConfigurationWatchList cwl = getConfigurationWatchList(context); if (cwl == null) { cwl = new ConfigurationWatchList(); cwl.setContext(context); context.putObject(CoreConstants.CONFIGURATION_WATCH_LIST, cwl); } else { cwl.clear(); } //setConfigurationWatchListResetFlag(context, true); cwl.setMainURL(url); }
@Override public void run() { fireEnteredRunMethod(); ConfigurationWatchList configurationWatchList = ConfigurationWatchListUtil.getConfigurationWatchList(context); if (configurationWatchList == null) { addWarn("Empty ConfigurationWatchList in context"); return; } List<File> filesToWatch = configurationWatchList.getCopyOfFileWatchList(); if (filesToWatch == null || filesToWatch.isEmpty()) { addInfo("Empty watch file list. Disabling "); return; } if (!configurationWatchList.changeDetected()) { return; } fireChangeDetected(); URL mainConfigurationURL = configurationWatchList.getMainURL(); addInfo(DETECTED_CHANGE_IN_CONFIGURATION_FILES); addInfo(CoreConstants.RESET_MSG_PREFIX + "named [" + context.getName() + "]"); LoggerContext lc = (LoggerContext) context; if (mainConfigurationURL.toString().endsWith("xml")) { performXMLConfiguration(lc, mainConfigurationURL); } else if (mainConfigurationURL.toString().endsWith("groovy")) { addError("Groovy classes are not available on the class path. ABORTING INITIALIZATION."); } fireDoneReconfiguring(); }