private Path extractPackedFile(JarFileResource configResource) throws IOException { String uri = configResource.getURI().toASCIIString(); int colon = uri.lastIndexOf(":"); int bang_slash = uri.indexOf("!/"); if (colon < 0 || bang_slash < 0 || colon > bang_slash) throw new IllegalArgumentException("Not resolved JarFile resource: " + uri); String entry_path = uri.substring(colon + 2).replace("!/", "__").replace('/', '_').replace('.', '_'); Path tmpDirectory = Files.createTempDirectory("users_store"); tmpDirectory.toFile().deleteOnExit(); Path extractedPath = Paths.get(tmpDirectory.toString(), entry_path); Files.deleteIfExists(extractedPath); extractedPath.toFile().deleteOnExit(); IO.copy(configResource.getInputStream(), new FileOutputStream(extractedPath.toFile())); if (isHotReload()) { LOG.warn("Cannot hot reload from packed configuration: {}", configResource); setHotReload(false); } return extractedPath; }
/** * Depending on the value of the refresh interval, this method will either start * up a scanner thread that will monitor the properties file for changes after * it has initially loaded it. Otherwise the users will be loaded and there will * be no active monitoring thread so changes will not be detected. */ @Override protected void doStart() throws Exception { super.doStart(); loadUsers(); if (isHotReload() && (_configPath != null)) { this._pathWatcher = new PathWatcher(); this._pathWatcher.watch(_configPath); this._pathWatcher.addListener(this); this._pathWatcher.setNotifyExistingOnStart(false); this._pathWatcher.start(); } }
private Path extractPackedFile( JarFileResource configResource ) throws IOException { String uri = configResource.getURI().toASCIIString(); int colon = uri.lastIndexOf(":"); int bang_slash = uri.indexOf("!/"); if (colon<0 || bang_slash<0 || colon>bang_slash) throw new IllegalArgumentException("Not resolved JarFile resource: "+uri); String entry_path = uri.substring(colon+2).replace("!/","__").replace('/','_').replace('.','_'); Path tmpDirectory = Files.createTempDirectory( "users_store" ); tmpDirectory.toFile().deleteOnExit(); Path extractedPath = Paths.get(tmpDirectory.toString(), entry_path); Files.deleteIfExists( extractedPath ); extractedPath.toFile().deleteOnExit(); IO.copy(configResource.getInputStream(),new FileOutputStream(extractedPath.toFile())); if (isHotReload()) { LOG.warn("Cannot hot reload from packed configuration: {}",configResource); setHotReload(false); } return extractedPath; }
/** * Depending on the value of the refresh interval, this method will either start up a scanner thread that will monitor the properties file for changes after * it has initially loaded it. Otherwise the users will be loaded and there will be no active monitoring thread so changes will not be detected. * * * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStart() throws Exception { super.doStart(); loadUsers(); if ( isHotReload() && (_configPath != null) ) { this._pathWatcher = new PathWatcher(); this._pathWatcher.watch(_configPath); this._pathWatcher.addListener(this); this._pathWatcher.setNotifyExistingOnStart(false); this._pathWatcher.start(); } }
/** * Depending on the value of the refresh interval, this method will either start up a scanner thread that will monitor the properties file for changes after * it has initially loaded it. Otherwise the users will be loaded and there will be no active monitoring thread so changes will not be detected. * * * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ protected void doStart() throws Exception { super.doStart(); loadUsers(); if ( isHotReload() && (_configPath != null) ) { this.pathWatcher = new PathWatcher(); this.pathWatcher.watch(_configPath); this.pathWatcher.addListener(this); this.pathWatcher.setNotifyExistingOnStart(false); this.pathWatcher.start(); } }