KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > frontoffice > smartCache > SmartCacheManager


1 /*
2  * ĻON content management system.
3  * Copyright (C) 2002 Guillaume Bort(gbort@msn.com). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  * Copyright 2000-2002 (C) Intalio Inc. All Rights Reserved.
7  *
8  * ĻON is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * ĻON core framework, ĻON content server, ĻON backoffice, ĻON frontoffice
14  * and ĻON admin application are parts of ĻON and are distributed under
15  * same terms of licence.
16  *
17  *
18  * ĻON includes software developed by the Apache Software Foundation (http://www.apache.org/)
19  * and software developed by the Exolab Project (http://www.exolab.org).
20  *
21  * ĻON is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  */

26
27 package org.nextime.ion.frontoffice.smartCache;
28
29 import java.util.Vector JavaDoc;
30
31 import javax.servlet.ServletConfig JavaDoc;
32 import javax.servlet.ServletContext JavaDoc;
33 import javax.servlet.ServletException JavaDoc;
34 import javax.servlet.http.HttpServlet JavaDoc;
35 import javax.servlet.jsp.JspFactory JavaDoc;
36 import javax.servlet.jsp.JspWriter JavaDoc;
37 import javax.servlet.jsp.PageContext JavaDoc;
38
39 import org.apache.taglibs.cache.CacheUtil;
40 import org.nextime.ion.framework.business.Publication;
41 import org.nextime.ion.framework.business.Section;
42 import org.nextime.ion.framework.business.impl.PublicationImpl;
43 import org.nextime.ion.framework.business.impl.SectionImpl;
44 import org.nextime.ion.framework.event.WcmEvent;
45 import org.nextime.ion.framework.event.WcmListener;
46 import org.nextime.ion.framework.mapping.Mapping;
47
48 public class SmartCacheManager extends HttpServlet JavaDoc implements WcmListener {
49
50     static {
51         PublicationImpl.addListener(new SmartCacheManager());
52         SectionImpl.addListener(new SmartCacheManager());
53     }
54     
55     private static ServletContext JavaDoc context;
56
57     /**
58      * @see org.nextime.ion.framework.event.WcmListener#objectCreated(WcmEvent)
59      */

60     public void objectCreated(WcmEvent event) {
61         cleanCache();
62     }
63
64     /**
65      * @see org.nextime.ion.framework.event.WcmListener#objectDeleted(WcmEvent)
66      */

67     public void objectDeleted(WcmEvent event) {
68         cleanCache();
69     }
70
71     /**
72      * @see org.nextime.ion.framework.event.WcmListener#objectModified(WcmEvent)
73      */

74     public void objectModified(WcmEvent event) {
75         cleanCache();
76     }
77
78     protected void cleanCache() {
79 // try {
80
// Vector sections = Section.listAll();
81
// for (int i = 0; i < sections.size(); i++) {
82
// String id = ((Section) sections.get(i)).getId();
83
// context.removeAttribute("org.apache.taglibs.cache.session.caches.section_"+id);
84
// }
85
// } catch (Exception e) {
86
// e.printStackTrace();
87
// }
88
context.setAttribute("ion_lastUpdate", System.currentTimeMillis()+"");
89     }
90
91     /**
92      * @see javax.servlet.Servlet#init(ServletConfig)
93      */

94     public void init(ServletConfig JavaDoc arg0) throws ServletException JavaDoc {
95         context = arg0.getServletContext();
96     }
97
98 }
99
Popular Tags