001: /**
002: * Copyright (C) 2001-2005 France Telecom R&D
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: *
019: *
020: * Authors: S.Chassande-Barrioz.
021: * Created on 13 mai 2005
022: *
023: */package org.objectweb.speedo.usercache.lib;
024:
025: import org.objectweb.speedo.usercache.api.UserCache;
026:
027: /**
028: *
029: *
030: * @author S.Chassande-Barrioz
031: */
032: public class CompositeUserCache implements UserCache {
033:
034: UserCache[] inner;
035:
036: /**
037: *
038: */
039: public CompositeUserCache(UserCache[] inner) {
040: super ();
041: this .inner = inner;
042: // TODO Auto-generated constructor stub
043: }
044:
045: public Object bind(Object key, Object oid) {
046: throw new UnsupportedOperationException(
047: "No bind possible on composite user cache");
048: }
049:
050: public int getId() {
051: throw new UnsupportedOperationException(
052: "No bind possible on composite user cache");
053: }
054:
055: public String[] getIndexFieldNames() {
056: return inner[0].getIndexFieldNames();
057: }
058:
059: public String getName() {
060: throw new UnsupportedOperationException(
061: "No bind possible on composite user cache");
062: }
063:
064: public boolean isActive() {
065: for (int i = 0; i < inner.length; i++) {
066: if (inner[i].isActive()) {
067: return true;
068: }
069: }
070: return false;
071: }
072:
073: public Object lookup(Object key) {
074: for (int i = 0; i < inner.length; i++) {
075: Object res = inner[i].lookup(key);
076: if (res != null) {
077: return res;
078: }
079: }
080: return null;
081: }
082:
083: public Object unbindFromKey(Object key) {
084: for (int i = 0; i < inner.length; i++) {
085: Object res = inner[i].unbindFromKey(key);
086: if (res != null) {
087: return res;
088: }
089: }
090: return null;
091: }
092:
093: public Object unbindFromOID(Object oid) {
094: for (int i = 0; i < inner.length; i++) {
095: Object res = inner[i].unbindFromOID(oid);
096: if (res != null) {
097: return res;
098: }
099: }
100: return null;
101: }
102: }
|