KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > identitymaps > NoIdentityMap


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.identitymaps;
23
24 import java.util.*;
25
26 /**
27  * <p><b>Purpose</b>: Provide the capability to not cache objects at all.
28  * <p><b>Responsibilities</b>:<ul>
29  * <li> Do nothing when an object is cached
30  * </ul>
31  * @since TOPLink/Java 1.0
32  */

33 public class NoIdentityMap extends IdentityMap {
34     public NoIdentityMap(int size) {
35         super(size);
36     }
37
38     /**
39      * locking for no identity.
40      */

41     public CacheKey acquire(Vector primaryKey) {
42         CacheKey cacheKey = new CacheKey(primaryKey);
43         cacheKey.acquire();
44         return cacheKey;
45     }
46
47     /**
48      * INTERNAL:
49      * Used to print all the Locks in every identity map in this session.
50      * The output of this method will go to log passed in as a parameter.
51      */

52     public void collectLocks(HashMap threadList) {
53     }
54
55     /**
56      * Allow for the cache to be iterated on.
57      */

58     public Enumeration elements() {
59         return new Vector(1).elements();
60     }
61
62     /**
63      * Return the object cached in the identity map
64      * Return null as no object is cached in the no IM.
65      */

66     public Object JavaDoc get(Vector primaryKey) {
67         return null;
68     }
69
70     /**
71      * Return null since no objects are actually cached.
72      */

73     protected CacheKey getCacheKey(CacheKey searchKey) {
74         return null;
75     }
76
77     /**
78      * @return 0 (zero)
79      */

80     public int getSize() {
81         return 0;
82     }
83
84     /**
85      * Return the number of actual objects of type myClass in the IdentityMap.
86      * Recurse = true will include subclasses of myClass in the count.
87      */

88     public int getSize(Class JavaDoc myClass, boolean recurse) {
89         return 0;
90     }
91
92     /**
93      * Get the write lock value from the cache key associated to the primarykey
94      */

95     public Object JavaDoc getWriteLockValue(Vector primaryKey) {
96         return null;
97     }
98
99     /**
100      * Allow for the cache keys to be iterated on.
101      */

102     public Enumeration keys() {
103         return new Vector(1).elements();
104     }
105
106     /**
107      * DO NOTHING.
108      */

109     public CacheKey put(Vector aVector, Object JavaDoc object, Object JavaDoc writeLockValue, long readTime) {
110         return null;
111     }
112
113     /**
114      * DO NOTHING
115      */

116     public void put(CacheKey key) {
117         return;
118     }
119
120     /**
121      * Do Nothing.
122      * Return null, since no objects are cached.
123      */

124     public Object JavaDoc remove(Vector primaryKey) {
125         return null;
126     }
127
128     /**
129      * Do Nothing
130      * Return null, since no objects are cached.
131      */

132     public Object JavaDoc remove(CacheKey searchKey) {
133         return null;
134     }
135
136     public void setWriteLockValue(Vector primaryKey, Object JavaDoc writeLockValue) {
137     }
138 }
139
Popular Tags