KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > usercache > lib > CompositeUserCache


1 /**
2  * Copyright (C) 2001-2005 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  *
19  *
20  * Authors: S.Chassande-Barrioz.
21  * Created on 13 mai 2005
22  *
23  */

24 package org.objectweb.speedo.usercache.lib;
25
26 import org.objectweb.speedo.usercache.api.UserCache;
27
28 /**
29  *
30  *
31  * @author S.Chassande-Barrioz
32  */

33 public class CompositeUserCache implements UserCache {
34
35     UserCache[] inner;
36     
37     /**
38      *
39      */

40     public CompositeUserCache(UserCache[] inner) {
41         super();
42         this.inner = inner;
43         // TODO Auto-generated constructor stub
44
}
45
46     public Object JavaDoc bind(Object JavaDoc key, Object JavaDoc oid) {
47         throw new UnsupportedOperationException JavaDoc("No bind possible on composite user cache");
48     }
49     public int getId() {
50         throw new UnsupportedOperationException JavaDoc("No bind possible on composite user cache");
51     }
52     public String JavaDoc[] getIndexFieldNames() {
53         return inner[0].getIndexFieldNames();
54     }
55     public String JavaDoc getName() {
56         throw new UnsupportedOperationException JavaDoc("No bind possible on composite user cache");
57     }
58     public boolean isActive() {
59         for (int i = 0; i < inner.length; i++) {
60             if (inner[i].isActive()) {
61                 return true;
62             }
63         }
64         return false;
65     }
66     public Object JavaDoc lookup(Object JavaDoc key) {
67         for (int i = 0; i < inner.length; i++) {
68             Object JavaDoc res = inner[i].lookup(key);
69             if (res != null) {
70                 return res;
71             }
72         }
73         return null;
74     }
75     public Object JavaDoc unbindFromKey(Object JavaDoc key) {
76         for (int i = 0; i < inner.length; i++) {
77             Object JavaDoc res = inner[i].unbindFromKey(key);
78             if (res != null) {
79                 return res;
80             }
81         }
82         return null;
83     }
84     public Object JavaDoc unbindFromOID(Object JavaDoc oid) {
85         for (int i = 0; i < inner.length; i++) {
86             Object JavaDoc res = inner[i].unbindFromOID(oid);
87             if (res != null) {
88                 return res;
89             }
90         }
91         return null;
92     }
93 }
94
Popular Tags