1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.daemon.impl;
18
19
20 import org.apache.jetspeed.daemon.Daemon;
21 import org.apache.jetspeed.daemon.DaemonConfig;
22 import org.apache.jetspeed.daemon.DaemonEntry;
23 import org.apache.jetspeed.daemon.impl.util.diskcachedaemon.URLRefresher;
24 import org.apache.jetspeed.cache.disk.DiskCacheEntry;
25 import org.apache.jetspeed.cache.disk.JetspeedDiskCache;
26 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
27 import org.apache.jetspeed.services.logging.JetspeedLogger;
28 import org.apache.jetspeed.services.threadpool.ThreadPool;
29
30
31 import org.apache.turbine.util.RunData;
32
33 /***
34 A daemon that takes all instances of the DiskCacheDaemon and makes sure
35 that any content entries get updated on a regular basis.
36
37
38 @author <A HREF="mailto:burton@apache.org">Kevin A. Burton</A>
39 @version $Id: DiskCacheDaemon.java,v 1.23 2004/02/23 02:48:05 jford Exp $
40 */
41 public class DiskCacheDaemon implements Daemon {
42
43
44 private int status = Daemon.STATUS_NOT_PROCESSED;
45 private int result = Daemon.RESULT_UNKNOWN;
46 private DaemonConfig config = null;
47 private DaemonEntry entry = null;
48 private RunData rundata = null;
49
50 /***
51 * Static initialization of the logger for this class
52 */
53 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(DiskCacheDaemon.class.getName());
54
55 /***
56 Go over all the documents on the system and if refresh them if necessary.
57 */
58 public void run() {
59
60 logger.info("parsing out document store");
61 this.setResult( Daemon.RESULT_PROCESSING );
62
63 DiskCacheEntry urls[] = JetspeedDiskCache.getInstance().getEntries();
64
65 for (int i = 0; i < urls.length; ++i) {
66
67 String url = urls[i].getSourceURL();
68
69
70
71 if(!urls[i].isLocal()) {
72 ThreadPool.process( new URLRefresher( url ) );
73 }
74
75 }
76 this.setResult( Daemon.RESULT_SUCCESS );
77 }
78
79 /***
80 Init this Daemon from the DaemonFactory
81 @see Daemon#init
82 */
83 public void init(DaemonConfig config, DaemonEntry entry) {
84 this.config = config;
85 this.entry = entry;
86 }
87
88 /***
89 */
90 public DaemonConfig getDaemonConfig() {
91 return this.config;
92 }
93
94 /***
95 */
96 public DaemonEntry getDaemonEntry() {
97 return this.entry;
98 }
99
100 /***
101 Return the status for this Daemon
102
103 @see Daemon#STATUS_NOT_PROCESSED
104 @see Daemon#STATUS_PROCESSED
105 @see Daemon#STATUS_PROCESSING
106 */
107 public int getStatus() {
108 return this.status;
109 }
110
111 /***
112 Set the status for this Daemon
113
114 @see #STATUS_NOT_PROCESSED
115 @see #STATUS_PROCESSED
116 @see #STATUS_PROCESSING
117 */
118 public void setStatus(int status) {
119 this.status = status;
120 }
121
122 /***
123 @see Daemon#getResult()
124 */
125 public int getResult() {
126 return this.result;
127 }
128
129 /***
130 @see Daemon#setResult(int result)
131 */
132 public void setResult( int result ) {
133 this.result = result;
134 }
135
136 /***
137 @see Daemon#getMessage()
138 */
139 public String getMessage() {
140 return null;
141 }
142
143 }