1/*2 * Copyright 2000-2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.daemon.impl;
1819//jetspeed stuff20import org.apache.jetspeed.daemon.Daemon;
21import org.apache.jetspeed.daemon.DaemonConfig;
22import org.apache.jetspeed.daemon.DaemonEntry;
23import org.apache.jetspeed.daemon.impl.util.diskcachedaemon.URLRefresher;
24import org.apache.jetspeed.cache.disk.DiskCacheEntry;
25import org.apache.jetspeed.cache.disk.JetspeedDiskCache;
26import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
27import org.apache.jetspeed.services.logging.JetspeedLogger;
28import org.apache.jetspeed.services.threadpool.ThreadPool;
2930//turbine stuff31import org.apache.turbine.util.RunData;
3233/***34A daemon that takes all instances of the DiskCacheDaemon and makes sure35that any content entries get updated on a regular basis.363738@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*/41publicclassDiskCacheDaemon implements Daemon {
424344privateint status = Daemon.STATUS_NOT_PROCESSED;
45privateint result = Daemon.RESULT_UNKNOWN;
46privateDaemonConfig config = null;
47privateDaemonEntry entry = null;
48private RunData rundata = null;
4950/***51 * Static initialization of the logger for this class52 */53privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(DiskCacheDaemon.class.getName());
5455/***56 Go over all the documents on the system and if refresh them if necessary.57 */58publicvoid run() {
5960 logger.info("parsing out document store");
61this.setResult( Daemon.RESULT_PROCESSING );
6263DiskCacheEntry urls[] = JetspeedDiskCache.getInstance().getEntries();
6465for (int i = 0; i < urls.length; ++i) {
6667 String url = urls[i].getSourceURL();
6869//SGP Note: Currently local URL have cache entries,70//but we must not fetch them71if(!urls[i].isLocal()) {
72 ThreadPool.process( new URLRefresher( url ) );
73 }
7475 }
76this.setResult( Daemon.RESULT_SUCCESS );
77 }
7879/***80 Init this Daemon from the DaemonFactory81 @see Daemon#init82 */83publicvoid init(DaemonConfig config, DaemonEntry entry) {
84this.config = config;
85this.entry = entry;
86 }
8788/***89 */90publicDaemonConfig getDaemonConfig() {
91returnthis.config;
92 }
9394/***95 */96publicDaemonEntry getDaemonEntry() {
97returnthis.entry;
98 }
99100/***101 Return the status for this Daemon102103 @see Daemon#STATUS_NOT_PROCESSED104 @see Daemon#STATUS_PROCESSED105 @see Daemon#STATUS_PROCESSING106 */107publicint getStatus() {
108returnthis.status;
109 }
110111/***112 Set the status for this Daemon113114 @see #STATUS_NOT_PROCESSED115 @see #STATUS_PROCESSED116 @see #STATUS_PROCESSING117 */118publicvoid setStatus(int status) {
119this.status = status;
120 }
121122/***123 @see Daemon#getResult()124 */125publicint getResult() {
126returnthis.result;
127 }
128129/***130 @see Daemon#setResult(int result)131 */132publicvoid setResult( int result ) {
133this.result = result;
134 }
135136/***137 @see Daemon#getMessage()138 */139public String getMessage() {
140returnnull;
141 }
142143 }