Source Code Cross Referenced for WritableCache.java in  » Inversion-of-Control » carbon » org » sape » carbon » services » cache » total » 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 » Inversion of Control » carbon » org.sape.carbon.services.cache.total 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Sapient Public License
003:         * Version 1.0 (the "License"); you may not use this file except in compliance
004:         * with the License. You may obtain a copy of the License at
005:         * http://carbon.sf.net/License.html.
006:         *
007:         * Software distributed under the License is distributed on an "AS IS" basis,
008:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009:         * the specific language governing rights and limitations under the License.
010:         *
011:         * The Original Code is The Carbon Component Framework.
012:         *
013:         * The Initial Developer of the Original Code is Sapient Corporation
014:         *
015:         * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
016:         */
017:
018:        package org.sape.carbon.services.cache.total;
019:
020:        import java.util.Collections;
021:        import java.util.HashMap;
022:        import java.util.Map;
023:
024:        import org.sape.carbon.core.component.Component;
025:        import org.sape.carbon.core.component.ComponentConfiguration;
026:        import org.sape.carbon.core.component.lifecycle.Configurable;
027:        import org.sape.carbon.core.component.lifecycle.Initializable;
028:        import org.sape.carbon.services.cache.CacheLoadException;
029:
030:        import org.apache.commons.logging.Log;
031:        import org.apache.commons.logging.LogFactory;
032:
033:        /**
034:         * <p>The Total Cache implementation of the Cache interface is intended for
035:         * access to data which expires periodically as a whole or which can be changed
036:         * on the fly by clients.</p>
037:         *
038:         * <p>
039:         * This implementation uses a synchronized map to store all data.  This means
040:         * that all gets and puts are synchronized to ensure consistent results
041:         * </p>
042:         *
043:         * Copyright 2002 Sapient
044:         * @since carbon 1.0
045:         * @author Douglas Voet, March 2002
046:         * @version $Revision: 1.15 $($Author: ghinkl $ / $Date: 2003/09/30 02:43:48 $)
047:         */
048:        public class WritableCache extends AbstractTotalCache implements 
049:                Configurable, Initializable {
050:
051:            /** The handle to Apache-commons logger */
052:            private Log log = LogFactory.getLog(this .getClass());
053:
054:            /** Map of the cached values. */
055:            private Map activeMap = null;
056:
057:            /** Holds the dataloader for this cache. */
058:            private TotalCacheDataLoader dataLoader = null;
059:
060:            /**
061:             * Refresh the contents of the cache.  First, initialize a holding cache.
062:             * Then load the holding cache with new data from the data loader.  Finally,
063:             * activate the holding cache.
064:             *
065:             * @throws CacheLoadException when its data loader has failed to load data
066:             */
067:            public void refreshAll() throws CacheLoadException {
068:
069:                if (log.isTraceEnabled()) {
070:                    log.trace("Refreshing Cache");
071:                }
072:
073:                synchronized (this .activeMap) {
074:                    this .activeMap.clear();
075:                    this .activeMap.putAll(this .dataLoader.loadAllData());
076:                }
077:            }
078:
079:            /**
080:             * @see Configurable#configure(ComponentConfiguration)
081:             */
082:            public void configure(ComponentConfiguration configuration) {
083:
084:                this .dataLoader = ((TotalCacheConfiguration) configuration)
085:                        .getDataLoader();
086:            }
087:
088:            /**
089:             * @see Initializable#initialize(org.sape.carbon.core.component.Component)
090:             */
091:            public void initialize(Component this Component) throws Exception {
092:
093:                Map holdingMap;
094:                // Checking for instance of appropriate dataloader. This will
095:                // enable backward compatibility.
096:                if (this .dataLoader instanceof  ConfigurableMapTypeCacheDataLoader) {
097:                    holdingMap = ((ConfigurableMapTypeCacheDataLoader) this .dataLoader)
098:                            .getMapInstance();
099:                } else {
100:                    holdingMap = new HashMap();
101:                }
102:                this .activeMap = Collections.synchronizedMap(holdingMap);
103:            }
104:
105:            /**
106:             * @see AbstractTotalCache#getCacheMap()
107:             */
108:            protected Map getCacheMap() {
109:                return this.activeMap;
110:            }
111:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.