001: /**********************************************************************
002: Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015: Contributors:
016: ...
017: **********************************************************************/package org.jpox.jdo;
018:
019: import java.util.Collection;
020:
021: import javax.jdo.datastore.DataStoreCache;
022:
023: import org.jpox.cache.Level2Cache;
024:
025: /**
026: * Implementation of the JDO DataStoreCache.
027: * Provides a wrapper and hands off calls to the underlying JPOX Level2 cache
028: *
029: * @version $Revision: 1.1 $
030: */
031: public class JDODataStoreCache implements DataStoreCache {
032: /** Underlying Level 2 cache. */
033: Level2Cache cache = null;
034:
035: /**
036: * Constructor.
037: * @param cache Level 2 Cache
038: */
039: public JDODataStoreCache(Level2Cache cache) {
040: this .cache = cache;
041: }
042:
043: /**
044: * Accessor for the underlying Level 2 cache.
045: * @return Underlying L2 cache.
046: */
047: public Level2Cache getLevel2Cache() {
048: return cache;
049: }
050:
051: /**
052: * Evict the parameter instance from the second-level cache.
053: * @param oid the object id of the instance to evict.
054: */
055: public void evict(Object oid) {
056: cache.evict(oid);
057: }
058:
059: /**
060: * Evict the parameter instances from the second-level cache.
061: * All instances in the PersistenceManager's cache are evicted
062: * from the second-level cache.
063: */
064: public void evictAll() {
065: cache.evictAll();
066: }
067:
068: /**
069: * Evict the parameter instances from the second-level cache.
070: * @param oids the object ids of the instance to evict.
071: */
072: public void evictAll(Object[] oids) {
073: cache.evictAll(oids);
074: }
075:
076: /**
077: * Evict the parameter instances from the second-level cache.
078: * @param oids the object ids of the instance to evict.
079: */
080: public void evictAll(Collection oids) {
081: cache.evictAll(oids);
082: }
083:
084: /**
085: * Evict the parameter instances from the second-level cache.
086: * @param pcClass the class of instances to evict
087: * @param subclasses if true, evict instances of subclasses also
088: */
089: public void evictAll(Class pcClass, boolean subclasses) {
090: cache.evictAll(pcClass, subclasses);
091: }
092:
093: /**
094: * Evict the parameter instances from the second-level cache.
095: * @param pcClass the class of instances to evict
096: * @param subclasses if true, evict instances of subclasses also
097: */
098: public void evictAll(boolean subclasses, Class pcClass) {
099: cache.evictAll(pcClass, subclasses);
100: }
101:
102: /**
103: * Pin the parameter instance in the second-level cache.
104: * @param oid the object id of the instance to pin.
105: */
106: public void pin(Object oid) {
107: cache.pin(oid);
108: }
109:
110: /**
111: * Pin the parameter instances in the second-level cache.
112: * @param oids the object ids of the instances to pin.
113: */
114: public void pinAll(Collection oids) {
115: cache.pinAll(oids);
116: }
117:
118: /**
119: * Pin the parameter instances in the second-level cache.
120: * @param oids the object ids of the instances to pin.
121: */
122: public void pinAll(Object[] oids) {
123: cache.pinAll(oids);
124: }
125:
126: /**
127: * Pin instances in the second-level cache.
128: * @param pcClass the class of instances to pin
129: * @param subclasses if true, pin instances of subclasses also
130: */
131: public void pinAll(Class pcClass, boolean subclasses) {
132: cache.pinAll(pcClass, subclasses);
133: }
134:
135: /**
136: * Pin instances in the second-level cache.
137: * @param subclasses if true, pin instances of subclasses also
138: * @param pcClass the class of instances to pin
139: */
140: public void pinAll(boolean subclasses, Class pcClass) {
141: cache.pinAll(pcClass, subclasses);
142: }
143:
144: /**
145: * Unpin the parameter instance from the second-level cache.
146: * @param oid the object id of the instance to unpin.
147: */
148: public void unpin(Object oid) {
149: cache.unpin(oid);
150: }
151:
152: /**
153: * Unpin the parameter instances from the second-level cache.
154: * @param oids the object ids of the instance to evict.
155: */
156: public void unpinAll(Collection oids) {
157: cache.unpinAll(oids);
158: }
159:
160: /**
161: * Unpin the parameter instance from the second-level cache.
162: * @param oids the object id of the instance to evict.
163: */
164: public void unpinAll(Object[] oids) {
165: cache.unpinAll(oids);
166: }
167:
168: /**
169: * Unpin instances from the second-level cache.
170: * @param pcClass the class of instances to unpin
171: * @param subclasses if true, unpin instances of subclasses also
172: */
173: public void unpinAll(Class pcClass, boolean subclasses) {
174: cache.unpinAll(pcClass, subclasses);
175: }
176:
177: /**
178: * Unpin instances from the second-level cache.
179: * @param subclasses if true, unpin instances of subclasses also
180: * @param pcClass the class of instances to unpin
181: */
182: public void unpinAll(boolean subclasses, Class pcClass) {
183: cache.unpinAll(pcClass, subclasses);
184: }
185: }
|