Source Code Cross Referenced for DbQueryManagerCache.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » database » 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 » Web Framework » rife 1.6.1 » com.uwyn.rife.database 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: DbQueryManagerCache.java 3737 2007-05-08 01:48:00Z gbevin $
007:         */
008:        package com.uwyn.rife.database;
009:
010:        import com.uwyn.rife.database.Datasource;
011:        import com.uwyn.rife.database.DbQueryManager;
012:        import java.util.HashMap;
013:        import java.util.Map;
014:
015:        /**
016:         * This class is a simple cache for {@link DbQueryManager} objects. {@link
017:         * DbQueryManager} objects are cached by their related {@link Datasource} and
018:         * an identifier.
019:         * 
020:         * @author JR Boyens (jboyens[remove] at uwyn dot com)
021:         * @author Geert Bevin (gbevin[remove] at uwyn dot com)
022:         * @version $Revision: 3737 $
023:         * @since 1.0
024:         */
025:        public class DbQueryManagerCache {
026:            private final Map<Datasource, HashMap<String, DbQueryManager>> mCache = new HashMap<Datasource, HashMap<String, DbQueryManager>>();
027:
028:            /**
029:             * Default constructor
030:             * 
031:             * @since 1.0
032:             */
033:            public DbQueryManagerCache() {
034:            }
035:
036:            /**
037:             * Retrieve a cached {@link DbQueryManager}
038:             * 
039:             * @param datasource the {@link Datasource} associated with the
040:             * desired {@link DbQueryManager}
041:             * @param identifier the identifier associate with the desired {@link
042:             * DbQueryManager}
043:             * @return the cached {@link DbQueryManager}
044:             * @since 1.0
045:             */
046:            public DbQueryManager get(Datasource datasource, String identifier) {
047:                if (null == datasource)
048:                    throw new IllegalArgumentException(
049:                            "datasource can't be null.");
050:                if (null == identifier)
051:                    throw new IllegalArgumentException(
052:                            "identifier can't be null.");
053:
054:                HashMap<String, DbQueryManager> dbquery_managers = null;
055:                synchronized (mCache) {
056:                    dbquery_managers = mCache.get(datasource);
057:                    if (null == dbquery_managers) {
058:                        return null;
059:                    }
060:                }
061:
062:                synchronized (dbquery_managers) {
063:                    return dbquery_managers.get(identifier);
064:                }
065:            }
066:
067:            /**
068:             * Place a {@link DbQueryManager} in the cache
069:             * 
070:             * @param datasource the {@link Datasource} associated with the {@link
071:             * DbQueryManager} to put in the cache
072:             * @param identifier the identifier associated with the {@link
073:             * DbQueryManager} to put in the cache
074:             * @param dbQueryManager the {@link DbQueryManager} to put in the
075:             * cache
076:             * @since 1.0
077:             */
078:            public void put(Datasource datasource, String identifier,
079:                    DbQueryManager dbQueryManager) {
080:                if (null == datasource)
081:                    throw new IllegalArgumentException(
082:                            "datasource can't be null.");
083:                if (null == identifier)
084:                    throw new IllegalArgumentException(
085:                            "identifier can't be null.");
086:                if (null == dbQueryManager)
087:                    throw new IllegalArgumentException(
088:                            "dbQueryManager can't be null.");
089:
090:                HashMap<String, DbQueryManager> dbquery_managers = null;
091:
092:                synchronized (mCache) {
093:                    dbquery_managers = mCache.get(datasource);
094:
095:                    if (null == dbquery_managers) {
096:                        dbquery_managers = new HashMap<String, DbQueryManager>();
097:                        mCache.put(datasource, dbquery_managers);
098:                    }
099:                }
100:
101:                synchronized (dbquery_managers) {
102:                    dbquery_managers.put(identifier, dbQueryManager);
103:                }
104:
105:                assert mCache.containsKey(datasource);
106:                assert mCache.get(datasource).containsKey(identifier);
107:                assert mCache.get(datasource).get(identifier) == dbQueryManager;
108:            }
109:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.