KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > cofax > cms > CofaxToolsClearCache


1 /*
2  * CofaxToolsClearCache is part of the Cofax content management system library.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Please see http://www.cofax.org for contact information and other related informaion.
19  *
20  * $Header: /cvsroot/cofax/cofax/src/org/cofax/cms/CofaxToolsClearCache.java,v 1.3.2.1 2006/12/11 16:28:24 fxrobin Exp $
21  */

22
23 package org.cofax.cms;
24
25 import java.io.*;
26 import java.net.*;
27
28 /**
29  * CofaxToolsClearCache: Makes http calls to Cofax Servlet Server to clear
30  * article cache or template cache. Expects the complete URl - compilation of
31  * that information is done within other classes. CofaxToolsClearCache is
32  * implemented as a thread so users will not have to wait upon completion of
33  * cache clearing if multiple servers or VAS exist.
34  *
35  * @author Charles Harvey
36  *
37  */

38
39 public class CofaxToolsClearCache extends Thread JavaDoc {
40
41     String JavaDoc URLToGet;
42
43     /**
44      * Makes http calls to Cofax Servlet Server to clear article cache or
45      * template cache. Expects the complete URl - compilation of that
46      * information is done within other classes. CofaxToolsClearCache is
47      * implemented as a thread so users will not have to wait upon completion of
48      * cache clearing if multiple servers or VAS exist.
49      *
50      */

51     CofaxToolsClearCache(String JavaDoc URLToGet) {
52         this.URLToGet = URLToGet;
53     }
54
55     public void run() {
56         URL url = null;
57         HttpURLConnection connection = null;
58         int responseCode = 0;
59         try {
60             CofaxToolsUtil.log("CofaxToolsClearCache run clearing Cache: " + URLToGet);
61             url = new URL(URLToGet);
62             connection = (HttpURLConnection) url.openConnection();
63             responseCode = connection.getResponseCode();
64         } catch (MalformedURLException ex) {
65             CofaxToolsUtil.log("CofaxToolsClearCache run ERROR: Malformed URL: " + URLToGet);
66         } catch (IOException ex) {
67             CofaxToolsUtil.log("CofaxToolsClearCache run ERROR: IO Exception: " + URLToGet);
68         }
69         if (responseCode != 200) {
70             CofaxToolsUtil.log("CofaxToolsClearCache run ERROR: " + responseCode + " " + URLToGet);
71         }
72     }
73
74 }
75
Popular Tags