Source Code Cross Referenced for ServletCache.java in  » Cache » OSCache » com » opensymphony » oscache » web » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Cache » OSCache » com.opensymphony.oscache.web 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2003 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.oscache.web;
006:
007:        import com.opensymphony.oscache.base.Cache;
008:        import com.opensymphony.oscache.base.CacheEntry;
009:
010:        import org.apache.commons.logging.Log;
011:        import org.apache.commons.logging.LogFactory;
012:
013:        import java.io.Serializable;
014:
015:        import javax.servlet.http.HttpSessionBindingEvent;
016:        import javax.servlet.http.HttpSessionBindingListener;
017:
018:        /**
019:         * A simple extension of Cache that implements a session binding listener,
020:         * and deletes it's entries when unbound
021:         *
022:         * @author        <a href="mailto:mike@atlassian.com">Mike Cannon-Brookes</a>
023:         * @author        <a href="mailto:tgochenour@peregrine.com">Todd Gochenour</a>
024:         * @author <a href="mailto:fbeauregard@pyxis-tech.com">Francois Beauregard</a>
025:         * @version        $Revision: 339 $
026:         */
027:        public final class ServletCache extends Cache implements 
028:                HttpSessionBindingListener, Serializable {
029:            private static transient final Log log = LogFactory
030:                    .getLog(ServletCache.class);
031:
032:            /**
033:             * The admin for this cache
034:             */
035:            private ServletCacheAdministrator admin;
036:
037:            /**
038:             * The scope of that cache.
039:             */
040:            private int scope;
041:
042:            /**
043:             * Create a new ServletCache
044:             *
045:             * @param admin The ServletCacheAdministrator to administer this ServletCache.
046:             * @param scope The scope of all entries in this hashmap
047:             */
048:            public ServletCache(ServletCacheAdministrator admin, int scope) {
049:                super (admin.isMemoryCaching(), admin.isUnlimitedDiskCache(),
050:                        admin.isOverflowPersistence());
051:                setScope(scope);
052:                this .admin = admin;
053:            }
054:
055:            /**
056:             * Create a new Cache
057:             *
058:             * @param admin The CacheAdministrator to administer this Cache.
059:             * @param algorithmClass The class that implement an algorithm
060:             * @param limit The maximum cache size in number of entries
061:             * @param scope The cache scope
062:             */
063:            public ServletCache(ServletCacheAdministrator admin,
064:                    String algorithmClass, int limit, int scope) {
065:                super (admin.isMemoryCaching(), admin.isUnlimitedDiskCache(),
066:                        admin.isOverflowPersistence(), admin.isBlocking(),
067:                        algorithmClass, limit);
068:                setScope(scope);
069:                this .admin = admin;
070:            }
071:
072:            /**
073:             * Get the cache scope
074:             *
075:             * @return The cache scope
076:             */
077:            public int getScope() {
078:                return scope;
079:            }
080:
081:            private void setScope(int scope) {
082:                this .scope = scope;
083:            }
084:
085:            /**
086:             * When this Cache is bound to the session, do nothing.
087:             *
088:             * @param event The SessionBindingEvent.
089:             */
090:            public void valueBound(HttpSessionBindingEvent event) {
091:            }
092:
093:            /**
094:             * When the users's session ends, all listeners are finalized and the
095:             * session cache directory is deleted from disk.
096:             *
097:             * @param event The event that triggered this unbinding.
098:             */
099:            public void valueUnbound(HttpSessionBindingEvent event) {
100:                if (log.isInfoEnabled()) {
101:                    // CACHE-229: don't access the session's id, because this can throw an IllegalStateException
102:                    log.info("[Cache] Unbound from session "
103:                            + event.getSession() + " using name "
104:                            + event.getName());
105:                }
106:
107:                admin.finalizeListeners(this );
108:                clear();
109:            }
110:
111:            /**
112:             * Indicates whether or not the cache entry is stale. This overrides the
113:             * {@link Cache#isStale(CacheEntry, int, String)} method to take into account any
114:             * flushing that may have been applied to the scope that this cache belongs to.
115:             *
116:             * @param cacheEntry     The cache entry to test the freshness of.
117:             * @param refreshPeriod  The maximum allowable age of the entry, in seconds.
118:             * @param cronExpiry     A cron expression that defines fixed expiry dates and/or
119:             * times for this cache entry.
120:             *
121:             * @return <code>true</code> if the entry is stale, <code>false</code> otherwise.
122:             */
123:            protected boolean isStale(CacheEntry cacheEntry, int refreshPeriod,
124:                    String cronExpiry) {
125:                return super.isStale(cacheEntry, refreshPeriod, cronExpiry)
126:                        || admin.isScopeFlushed(cacheEntry, scope);
127:            }
128:        }
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.