KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > usercache > api > UserCache


1 /**
2  * Copyright (C) 2001-2004 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * 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  */

18 package org.objectweb.speedo.usercache.api;
19
20 /**
21  * Defines an user cache of persistent objects. The user cache maintains
22  * bindings between an object identifier and the user key. This cache can be
23  * implemented such as a coherent double map (oid=>key and key=>oid).
24  * The user cache entry can be removed (unbound) from the user key or from the
25  * object identifier. Indeed when an object is removed from the real cache, the
26  * persistent object is no more availlable, its user key too.
27  *
28  * @author S.Chassande-Barrioz
29  */

30 public interface UserCache {
31
32     /**
33      * Look for an identifier of persistent instance from an user key
34      * @param key is the user key of the searched persistent instance (not null)
35      * @return the identifier of the persistent instance corresponding to the
36      * user key. If not found, a null value is returned.
37      */

38     Object JavaDoc lookup(Object JavaDoc key);
39
40     /**
41      * Adds an entry into user cache. If an entry already exists with the same
42      * identifier or the same key, it has been replaced.
43      *
44      * @param key is the user key the user of the persistent instance (not null)
45      * @param oid is the identifier of the persistent instance (not null)
46      *
47      * @return the previous associated identifier of a persistent instance
48      * associated to the specified user key. The null value is returned if no
49      * entry was previously bound.
50      */

51     Object JavaDoc bind(Object JavaDoc key, Object JavaDoc oid);
52         
53     /**
54      * Forces the eviction of an entry from an user key
55      * @param key is the user key of a persistent instance (not null)
56      * @return the object identifier if found, otherwise null
57      */

58     Object JavaDoc unbindFromKey(Object JavaDoc key);
59
60     /**
61      * Forces the eviction of an entry from an object identifier
62      * @param oid is the identifier of a persistent instance (not null)
63      * @return the user key if found, otherwise null
64      */

65     Object JavaDoc unbindFromOID(Object JavaDoc oid);
66     
67     String JavaDoc getName();
68     
69     int getId();
70     
71     boolean isActive();
72     
73     String JavaDoc[] getIndexFieldNames();
74     
75 }
76
Popular Tags