01: /**
02: * Copyright (C) 2001-2004 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package org.objectweb.speedo.usercache.api;
18:
19: /**
20: * Defines an user cache of persistent objects. The user cache maintains
21: * bindings between an object identifier and the user key. This cache can be
22: * implemented such as a coherent double map (oid=>key and key=>oid).
23: * The user cache entry can be removed (unbound) from the user key or from the
24: * object identifier. Indeed when an object is removed from the real cache, the
25: * persistent object is no more availlable, its user key too.
26: *
27: * @author S.Chassande-Barrioz
28: */
29: public interface UserCache {
30:
31: /**
32: * Look for an identifier of persistent instance from an user key
33: * @param key is the user key of the searched persistent instance (not null)
34: * @return the identifier of the persistent instance corresponding to the
35: * user key. If not found, a null value is returned.
36: */
37: Object lookup(Object key);
38:
39: /**
40: * Adds an entry into user cache. If an entry already exists with the same
41: * identifier or the same key, it has been replaced.
42: *
43: * @param key is the user key the user of the persistent instance (not null)
44: * @param oid is the identifier of the persistent instance (not null)
45: *
46: * @return the previous associated identifier of a persistent instance
47: * associated to the specified user key. The null value is returned if no
48: * entry was previously bound.
49: */
50: Object bind(Object key, Object oid);
51:
52: /**
53: * Forces the eviction of an entry from an user key
54: * @param key is the user key of a persistent instance (not null)
55: * @return the object identifier if found, otherwise null
56: */
57: Object unbindFromKey(Object key);
58:
59: /**
60: * Forces the eviction of an entry from an object identifier
61: * @param oid is the identifier of a persistent instance (not null)
62: * @return the user key if found, otherwise null
63: */
64: Object unbindFromOID(Object oid);
65:
66: String getName();
67:
68: int getId();
69:
70: boolean isActive();
71:
72: String[] getIndexFieldNames();
73:
74: }
|