1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.plugin;
17
18 import java.util.Collections;
19 import java.util.HashSet;
20 import java.util.Iterator;
21 import java.util.Set;
22
23
24
25
26
27
28 public class Reloader implements Runnable {
29
30 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(Reloader.class);
31
32 private final Set<Reloadable> reloadables = Collections.synchronizedSet(new HashSet<Reloadable>());
33
34 public void run() {
35 try {
36 LOG.debug("Checking if any reloading is necessary...");
37 synchronized (reloadables) {
38 for (Iterator iterator = reloadables.iterator(); iterator.hasNext();) {
39 Reloadable reloadable = (Reloadable) iterator.next();
40 LOG.debug("Checking reloadable: " + reloadable);
41 if (reloadable.isReloadable() && reloadable.isReloadNeeded()) {
42
43
44
45 LOG.info("Reloading: " + reloadable);
46 reloadable.reload();
47
48 }
49 }
50 }
51 } catch (Throwable t) {
52 LOG.error("Failed to reload plugin.", t);
53 }
54 }
55
56 public void addReloadable(Reloadable reloadable) {
57 reloadables.add(reloadable);
58 }
59
60 public void removeReloadable(Reloadable reloadable) {
61 reloadables.remove(reloadable);
62 }
63
64 public Set<Reloadable> getReloadables() {
65 return reloadables;
66 }
67
68 }