1
|
/**
|
2
|
* Copyright (C) 2015 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.common.monitor;
|
10
|
|
11
|
import java.io.Serializable;
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
|
15
|
|
16
|
/**
|
17
|
* @author cmathew
|
18
|
* @date 14 Oct 2015
|
19
|
*
|
20
|
*/
|
21
|
public class RemotingProgressMonitor extends RestServiceProgressMonitor implements IRemotingProgressMonitor {
|
22
|
private static final long serialVersionUID = -3173248814638886884L;
|
23
|
|
24
|
private Serializable result;
|
25
|
private List<String> reports = new ArrayList<String>();
|
26
|
private transient RemotingProgressMonitorThread monitorThread;
|
27
|
|
28
|
|
29
|
public RemotingProgressMonitor(RemotingProgressMonitorThread monitorThread) {
|
30
|
if(monitorThread == null) {
|
31
|
throw new IllegalStateException("Monitor Thread is null");
|
32
|
}
|
33
|
this.monitorThread = monitorThread;
|
34
|
}
|
35
|
|
36
|
public RemotingProgressMonitor() {
|
37
|
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* {@inheritDoc}
|
42
|
*/
|
43
|
@Override
|
44
|
public Object getResult() {
|
45
|
return result;
|
46
|
}
|
47
|
|
48
|
|
49
|
/**
|
50
|
* {@inheritDoc}
|
51
|
*/
|
52
|
@Override
|
53
|
public void setResult(Serializable result) {
|
54
|
this.result = result;
|
55
|
}
|
56
|
|
57
|
|
58
|
/**
|
59
|
* {@inheritDoc}
|
60
|
*/
|
61
|
@Override
|
62
|
public List<String> getReports() {
|
63
|
return reports;
|
64
|
}
|
65
|
|
66
|
|
67
|
/**
|
68
|
* {@inheritDoc}
|
69
|
*/
|
70
|
@Override
|
71
|
public void addReport(String report) {
|
72
|
reports.add(report);
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* {@inheritDoc}
|
77
|
*/
|
78
|
@Override
|
79
|
public void interrupt() {
|
80
|
if(monitorThread.isAlive()) {
|
81
|
monitorThread.interrupt();
|
82
|
}
|
83
|
}
|
84
|
|
85
|
|
86
|
/**
|
87
|
* {@inheritDoc}
|
88
|
*/
|
89
|
@Override
|
90
|
public RemotingProgressMonitorThread getThread() {
|
91
|
return monitorThread;
|
92
|
}
|
93
|
|
94
|
/**
|
95
|
* {@inheritDoc}
|
96
|
*/
|
97
|
@Override
|
98
|
public boolean isMonitorThreadRunning() {
|
99
|
RemotingProgressMonitorThread monitorThread = RemotingProgressMonitorThread.getMonitorThread(this);
|
100
|
return monitorThread != null;
|
101
|
}
|
102
|
}
|