Source Code Cross Referenced for IncludeCacheManagerSession.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » transformation » helpers » 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
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.cocoon.transformation.helpers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.transformation.helpers;
018:
019:        import java.io.IOException;
020:        import java.util.HashMap;
021:        import java.util.Iterator;
022:        import java.util.Map;
023:
024:        import org.apache.avalon.framework.parameters.Parameters;
025:        import org.apache.excalibur.source.Source;
026:        import org.apache.excalibur.source.SourceResolver;
027:        import org.apache.excalibur.source.SourceValidity;
028:        import org.apache.excalibur.source.impl.validity.ExpiresValidity;
029:
030:        /**
031:         * This object encapsulates a "caching session". A caching session has the
032:         * duration of one single request.
033:         * This object is used by the {@link IncludeCacheManager} and holds all required
034:         * configuration for performing the caching of this request.
035:         * 
036:         * The session can be configured during construction with the following parameters:
037:         * - purge (boolean/false) : Turn on/off purging the cache
038:         * - preemptive (boolean/false) : Turn on/off preemptive caching
039:         * - parallel (boolean/false) : Turn on/off parallel processing
040:         * - expires (long/0) : The lifetime of the cached content
041:         * 
042:         *  @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
043:         *  @version CVS $Id: IncludeCacheManagerSession.java 433543 2006-08-22 06:22:54Z crossley $
044:         *  @since   2.1
045:         */
046:        public final class IncludeCacheManagerSession {
047:
048:            /** The expires information */
049:            private long expires;
050:
051:            /** Should we purge the cache */
052:            private boolean purge;
053:
054:            /** Should we load preemptive */
055:            private boolean preemptive;
056:
057:            /** Should we process everything in parallel */
058:            private boolean parallel;
059:
060:            /** The used {@link IncludeCacheStorageProxy} */
061:            private IncludeCacheStorageProxy storage;
062:
063:            /** The list of all threads */
064:            private Map threadList;
065:
066:            /** Cache the expires validity object */
067:            private SourceValidity validity;
068:
069:            /** Cache the source objects */
070:            private Map sourceList = new HashMap(10);
071:
072:            /**
073:             * Constructor
074:             * @param configuration The parameters configuring this session
075:             * @param proxy         The proxy used to cache the data
076:             */
077:            IncludeCacheManagerSession(Parameters configuration,
078:                    IncludeCacheStorageProxy proxy) {
079:                this .expires = configuration.getParameterAsLong("expires", 0);
080:                this .purge = configuration
081:                        .getParameterAsBoolean("purge", false);
082:                this .preemptive = configuration.getParameterAsBoolean(
083:                        "preemptive", false);
084:                this .parallel = configuration.getParameterAsBoolean("parallel",
085:                        false);
086:                this .storage = proxy;
087:            }
088:
089:            /**
090:             * Get the used storage proxy
091:             */
092:            IncludeCacheStorageProxy getCacheStorageProxy() {
093:                return this .storage;
094:            }
095:
096:            /**
097:             * Get the expiration information
098:             */
099:            public long getExpires() {
100:                return this .expires;
101:            }
102:
103:            public SourceValidity getExpiresValidity() {
104:                if (this .expires > 0 && this .validity == null) {
105:                    this .validity = new ExpiresValidity(this .expires * 1000); // milliseconds
106:                }
107:                return this .validity;
108:            }
109:
110:            /**
111:             * Is the cache purged?
112:             */
113:            public boolean isPurging() {
114:                return this .purge;
115:            }
116:
117:            /**
118:             * Do we use preemptive caching?
119:             */
120:            public boolean isPreemptive() {
121:                return this .preemptive;
122:            }
123:
124:            /**
125:             * Do we process the includes in parallel?
126:             */
127:            public boolean isParallel() {
128:                return this .parallel;
129:            }
130:
131:            /**
132:             * Add another object to the thread list
133:             * @param uri    The absolute URI
134:             * @param object The thread
135:             */
136:            void add(String uri, Object object) {
137:                if (null == this .threadList) {
138:                    this .threadList = new HashMap(10);
139:                }
140:                this .threadList.put(uri, object);
141:            }
142:
143:            /**
144:             * Get the thread object.
145:             * @param uri     The URI
146:             * @return Object The thread.
147:             */
148:            Object get(String uri) {
149:                if (null != this .threadList) {
150:                    return this .threadList.get(uri);
151:                }
152:                return null;
153:            }
154:
155:            /**
156:             * Turn off/on preemptive caching
157:             */
158:            void setPreemptive(boolean value) {
159:                this .preemptive = value;
160:            }
161:
162:            /**
163:             * Lookup a source object and cache it
164:             * @param uri     Absolute URI
165:             * @return Source The source obejct
166:             */
167:            public Source resolveURI(String uri, SourceResolver resolver)
168:                    throws IOException {
169:                Source source = (Source) this .sourceList.get(uri);
170:                if (null == source) {
171:                    source = resolver.resolveURI(uri);
172:                    this .sourceList.put(source.getURI(), source);
173:                }
174:                return source;
175:            }
176:
177:            /**
178:             * Cleanup
179:             * @param resolver The source resolver to release cached sources
180:             */
181:            void cleanup(SourceResolver resolver) {
182:                Iterator iter = this .sourceList.values().iterator();
183:                while (iter.hasNext()) {
184:                    final Source source = (Source) iter.next();
185:                    resolver.release(source);
186:                }
187:            }
188:
189:            /**
190:             * Print a representation of this object
191:             */
192:            public String toString() {
193:                return "CacheManagerSession(" + this .hashCode() + ") -"
194:                        + " expires: " + this .expires + " parallel: "
195:                        + this .parallel + " preemptive: " + this .preemptive
196:                        + " purge: " + this.purge;
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.