19 package org.sleuthkit.autopsy.datamodel.utils;
21 import com.google.common.util.concurrent.ThreadFactoryBuilder;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.lang.ref.WeakReference;
25 import java.util.concurrent.ExecutorService;
26 import java.util.concurrent.Executors;
27 import java.util.concurrent.Future;
28 import java.util.logging.Level;
29 import org.openide.nodes.AbstractNode;
53 private static final ExecutorService
executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE,
new ThreadFactoryBuilder().setNameFormat(
"node-background-task-%d").build());
68 return executor.submit(task);
92 this.weakNodeRef =
new WeakReference<>(node);
93 this.weakListenerRef =
new WeakReference<>(listener);
124 T node = this.weakNodeRef.get();
125 PropertyChangeListener listener = this.weakListenerRef.get();
126 if (node == null || listener == null) {
130 if (Thread.currentThread().isInterrupted()) {
136 if (Thread.currentThread().isInterrupted()) {
140 if (changeEvent != null) {
141 listener.propertyChange(changeEvent);
144 }
catch (Exception ex) {
145 LOGGER.log(Level.WARNING,
"Error executing property sheet values computation background task", ex);
final WeakReference< PropertyChangeListener > weakListenerRef
AbstractNodePropertySheetTask(T node, PropertyChangeListener listener)
abstract PropertyChangeEvent computePropertyValue(T node)
static final ExecutorService executor
synchronized static Logger getLogger(String name)
static final Logger LOGGER
final WeakReference< T > weakNodeRef
static final Integer THREAD_POOL_SIZE
static Future<?> submitTask(AbstractNodePropertySheetTask<?> task)