-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDefaultKnimeExecutionService.java
More file actions
47 lines (39 loc) · 1.36 KB
/
DefaultKnimeExecutionService.java
File metadata and controls
47 lines (39 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package org.knime.scijava.commands;
import java.lang.ref.WeakReference;
import org.knime.core.node.ExecutionContext;
import org.scijava.Priority;
import org.scijava.plugin.Plugin;
import org.scijava.service.AbstractService;
/**
* Default implementation of KnimeExecutionService. Holds a KNIME Node
* {@link ExecutionContext} in a {@link WeakReference}, which ensures that the
* {@link ExecutionContext} can be garbage collected when execution of a Node
* terminates.
*
* @author Jonathan Hale (University of Konstanz)
* @see ExecutionContext
*/
@Plugin(type = KNIMEExecutionService.class, priority = DefaultKnimeExecutionService.PRIORITY)
public class DefaultKnimeExecutionService extends AbstractService
implements KNIMEExecutionService {
/**
* Priority of this {@link Plugin}
*/
public static final double PRIORITY = Priority.NORMAL_PRIORITY;
private WeakReference<ExecutionContext> m_exec = new WeakReference<>(null);
/**
* Set the {@link ExecutionContext}. Note that this service holds the
* {@link ExecutionContext} in a {@link WeakReference}, which means that the
* reference needs to be kept valid outside the service.
*
* @param context
*/
@Override
public void setExecutionContext(final ExecutionContext context) {
m_exec = new WeakReference<>(context);
}
@Override
public ExecutionContext getExecutionContext() {
return m_exec.get();
}
}