public FManager() { loaded = Collections.synchronizedSet( new HashSet<File>() { @Override public boolean add(File e) { synchronized (loadedObserver) { loadedObserver.setChanged(); loadedObserver.notifyObservers(e); } return super.add(e); } }); pending = Collections.synchronizedSet(new HashSet<>()); filterChange = new InvokeObservable(this); loadedObserver = new InvokeObservable(this); activityObserver = new InvokeObservable(this); autoLoad = true; verbose = true; activity = IDLE; stdErr = Optional.empty(); stdOut = Optional.empty(); FPC fpcObject = null; try { fpcObject = new FPC(DataDetails.class); fpcObject.onFilterChange(this::setActiveFilter); } catch (Exception ex) { Logger.getLogger(FManager.class.getName()).log(Level.SEVERE, null, ex); } fpc = fpcObject; checkProperties(); }
private void clearEx() { try { notify(BUSY); notify(CLEARING); fpc.clear(); loaded.clear(); pending.clear(); } catch (Exception ex) { Logger.getLogger(FManager.class.getName()).log(Level.SEVERE, null, ex); } finally { done(); } }
public Collection<String> getFingerprintNames() { return fpc.getFingerprintNames(); }
private void load() { if (fpc == null) { LogEmitter.factory .get() .emit( this, Core.ALERT.DANGER, "Fingerprint Compiler is disabled. Do you have the correct JDK installed?"); return; } try { notify(FManager.BUSY); pending.removeIf( f -> { try { if (loaded.contains(f)) { loadedObserver.setChanged(); loadedObserver.notifyObservers(f); notify(FManager.BUSY); lastReportedProgress = getProgressInt(); return true; } else { loaded.remove(f); fpc.generateOnComplete(f, fpc::compile); loaded.add(f); lastReportedProgress = getProgressInt(); return true; } } catch (Exception ex) { Logger.getLogger(FManager.class.getName()).log(Level.SEVERE, null, ex); LogEmitter.factory .get() .emit( this, Core.ALERT.DANGER, f.getName() + " did not load because " + ex.getLocalizedMessage()); return false; } }); loadedObserver.setChanged(); loadedObserver.notifyObservers( "Parsing complete " + loaded.size() + " of " + (loaded.size() + pending.size())); if (loaded.isEmpty()) { filterChange.notifyObservers(false); notify(FManager.FAILURE); return; } try { fpc.generateFilter(); fpc.compileFilter(); fpc.updateFilter(); /** invokes previously set callback */ filterChange.setChanged(); filterChange.notifyObservers(true); } catch (Exception ex) { Logger.getLogger(FManager.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); filterChange.notifyObservers(false); notify(FManager.FAILURE); } notify(FManager.COMPLETE); } catch (Exception ex) { Logger.getLogger(FManager.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); } finally { done(); } }