/** {@inheritDoc} */ public String toString() { return getLocation(); }
null); configs.add(new FilesystemResource(config.getPath()));
/** {@inheritDoc} */ public InputStream getInputStream() throws ResourceException { try { FileInputStream ins = new FileInputStream(resource); return applyFilter(ins); } catch (FileNotFoundException e) { throw new ResourceException("Resource file does not exist: " + resource.getAbsolutePath()); } }
/** * Constructor. * * @param taskTimer resource watchdog task timer * @param loggingConfigurationFile logback configuration file * @param pollingFrequency frequency the configuration file should be checked for changes */ public LogbackLoggingService(Timer taskTimer, String loggingConfigurationFile, long pollingFrequency) { LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusManager statusManager = loggerContext.getStatusManager(); try{ Resource configResource = new FilesystemResource(loggingConfigurationFile); LogbackConfigurationChangeListener configChangeListener = new LogbackConfigurationChangeListener(); configChangeListener.onResourceCreate(configResource); ResourceChangeWatcher resourceWatcher = new ResourceChangeWatcher(configResource, pollingFrequency, 5); resourceWatcher.getResourceListeners().add(configChangeListener); taskTimer.schedule(resourceWatcher, 0, pollingFrequency); }catch(ResourceException e){ statusManager.add(new ErrorStatus("Error loading logging configuration file: " + loggingConfigurationFile, this, e)); } } }
/** {@inheritDoc} */ public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof FilesystemResource) { return getLocation().equals(((FilesystemResource) o).getLocation()); } return false; } }
/** {@inheritDoc} */ public int hashCode() { return getLocation().hashCode(); }