public boolean isModified() { return watcher != null && watcher.isStale(); }
/** * Ensure the user data map matches the information in the user data file. This should be called * automatically, so that no code outside of this class needs to access this method. */ private void update() { try { if (myWatcher != null && myWatcher.isStale()) { Properties prop = myWatcher.getProperties(); UserAttributeEditor uae = new UserAttributeEditor(); myDetailStorage.clear(); Iterator<Object> it = prop.keySet().iterator(); while (it.hasNext()) { String username = (String) it.next(); uae.setAsText(prop.getProperty(username)); UserAttribute attrs = (UserAttribute) uae.getValue(); if (attrs != null) { myDetailStorage.put(username, makeUser(username, attrs)); } } } } catch (IOException ioe) { // TODO: handle the exception properly myDetailStorage.clear(); createDefaultUser(); } }
/** * Either loads the default property file on the first access, or reloads it if it has been * modified since last access. * * @throws DataAccessResourceFailureException */ void checkUserMap() throws DataAccessResourceFailureException { try { if ((userMap == null) || userDefinitionsFile == null || userDefinitionsFile.isStale()) { if (userDefinitionsFile == null) { Resource propFile = findUserProperties(); userDefinitionsFile = new PropertyFileWatcher(propFile); } userMap = loadUsersFromProperties(userDefinitionsFile.getProperties()); } } catch (Exception e) { LOGGER.log(Level.SEVERE, "An error occurred loading user definitions", e); } }
public boolean isStale() { return configFile.isStale(); }
@Override public void run() { if (watcher.isStale()) { // reload RemoteProcessFactoryConfiguration newConfiguration = loadConfiguration(); if (newConfiguration != null) { synchronized (newConfiguration) { configuration = newConfiguration; if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("New configuration loaded:\n" + configuration); } } } } }
@Override public void run() { if (watcher.isStale()) { // reload DownloadServiceConfiguration newConfiguration = loadConfiguration(); if (newConfiguration != null) { synchronized (newConfiguration) { configuration = newConfiguration; if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("New configuration loaded:\n" + configuration); } } } } }
private boolean isBlackListed(HttpServletRequest httpRequest) throws IOException { if(configFile != null && configFile.isStale()){ synchronized(configFile){ if(configFile.isStale()){ this.blackListedAddresses = reloadConfiguration(); } } } if(blackListedAddresses.isEmpty()){ return false; } String incomingIp = IpFlowController.getRemoteAddr(httpRequest); boolean blocked = blackListedAddresses.contains(incomingIp); return blocked; }
public ClusterConfig get() { if (watcher.isStale()) { try { config = (ClusterConfig) watcher.read(); } catch (IOException e) { LOGGER.log(Level.WARNING, "Error reading " + watcher.getFile().getPath(), e); } } return config; } }
if ((userMap == null) || userDefinitionsFile == null || userDefinitionsFile.isStale()) { try { if (userDefinitionsFile == null) {