Source Code Cross Referenced for AbstractMetaCache.java in  » Database-ORM » db-ojb » org » apache » ojb » broker » cache » 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 » Database ORM » db ojb » org.apache.ojb.broker.cache 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.ojb.broker.cache;
002:
003:        /* Copyright 2003-2005 The Apache Software Foundation
004:         *
005:         * Licensed under the Apache License, Version 2.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * 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:
018:        import org.apache.ojb.broker.Identity;
019:
020:        /**
021:         * An abstract 'meta' implementation of the {@link ObjectCache}
022:         * interace.
023:         * <br/>
024:         * Implement the abstract {@link #getCache} method in sub-classes.
025:         * All base Object/Identity validation is done by this class.
026:         *
027:         * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
028:         * @version $Id: AbstractMetaCache.java,v 1.5.2.2 2005/12/21 22:24:15 tomdz Exp $
029:         */
030:        public abstract class AbstractMetaCache implements  ObjectCache {
031:            public static final int METHOD_CACHE = 1;
032:            public static final int METHOD_LOOKUP = 2;
033:            public static final int METHOD_REMOVE = 3;
034:
035:            /**
036:             * This method handle all calls against the {@link ObjectCache} interface.
037:             * Note: The parameter <code>obj</code> can be <code>null</code> - e.g. when
038:             * lookup or remove method was called.
039:             *
040:             * @param oid Identity of the target object.
041:             * @param obj The target object itself or <code>null</code> if not available.
042:             * @param callingMethod Specifies the type of method call against the {@link ObjectCache}
043:             * interface. {@link #METHOD_CACHE}, {@link #METHOD_LOOKUP}, {@link #METHOD_REMOVE}.
044:             * @return The {@link ObjectCache} implementation.
045:             */
046:            public abstract ObjectCache getCache(Identity oid, Object obj,
047:                    int callingMethod);
048:
049:            /**
050:             * Caches the given object using the given Identity as key
051:             *
052:             * @param oid  The Identity key
053:             * @param obj  The object o cache
054:             */
055:            public void cache(Identity oid, Object obj) {
056:                if (oid != null && obj != null) {
057:                    ObjectCache cache = getCache(oid, obj, METHOD_CACHE);
058:                    if (cache != null) {
059:                        cache.cache(oid, obj);
060:                    }
061:                }
062:            }
063:
064:            /**
065:             * We delegate this method to the standard cache method.
066:             * <br/>
067:             * ++ Override if needed ++
068:             */
069:            public boolean cacheIfNew(Identity oid, Object obj) {
070:                cache(oid, obj);
071:                return true;
072:            }
073:
074:            /**
075:             * Looks up the object from the cache
076:             *
077:             * @param oid  The Identity to look up the object for
078:             * @return     The object if found, otherwise null
079:             */
080:            public Object lookup(Identity oid) {
081:                Object ret = null;
082:                if (oid != null) {
083:                    ObjectCache cache = getCache(oid, null, METHOD_LOOKUP);
084:                    if (cache != null) {
085:                        ret = cache.lookup(oid);
086:                    }
087:                }
088:                return ret;
089:            }
090:
091:            /**
092:             * Removes the given object from the cache
093:             *
094:             * @param oid  oid of the object to remove
095:             */
096:            public void remove(Identity oid) {
097:                if (oid == null)
098:                    return;
099:
100:                ObjectCache cache = getCache(oid, null, METHOD_REMOVE);
101:                if (cache != null) {
102:                    cache.remove(oid);
103:                }
104:            }
105:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.