KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > core > tasks > BlacklistUpdateTask


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * 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 and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 /*
19  * Created on Mar 10, 2004
20  */

21 package org.apache.roller.ui.core.tasks;
22
23 import java.util.TimerTask JavaDoc;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.roller.RollerException;
27 import org.apache.roller.model.Roller;
28 import org.apache.roller.model.RollerFactory;
29 import org.apache.roller.model.ScheduledTask;
30 import org.apache.roller.util.Blacklist;
31
32 /**
33  * Update MT Blacklist if needed.
34  *
35  * @author Allen Gilliland
36  */

37 public class BlacklistUpdateTask extends TimerTask JavaDoc implements ScheduledTask {
38     
39     private static Log mLogger = LogFactory.getLog(BlacklistUpdateTask.class);
40     
41     
42     /**
43      * Task init.
44      */

45     public void init(Roller roller, String JavaDoc realPath) throws RollerException {
46         mLogger.debug("initing");
47     }
48     
49     
50     /**
51      * Excecute the task.
52      */

53     public void run() {
54         
55         mLogger.info("task started");
56
57         Blacklist.checkForUpdate();
58         
59         mLogger.info("task completed");
60     }
61     
62     
63     /**
64      * Main method so that this task may be run from outside the webapp.
65      */

66     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
67         try {
68             // NOTE: if this task is run externally from the Roller webapp then
69
// all it will really be doing is downloading the MT blacklist file
70
BlacklistUpdateTask task = new BlacklistUpdateTask();
71             task.init(null, null);
72             task.run();
73             System.exit(0);
74         } catch (RollerException ex) {
75             ex.printStackTrace();
76             System.exit(-1);
77         }
78     }
79     
80 }
81
Popular Tags