01: /**
02: * Copyright (C) 2001-2005 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.mapper.lib;
18:
19: import org.objectweb.jorm.api.PClassMapping;
20: import org.objectweb.speedo.api.SpeedoProperties;
21: import org.objectweb.speedo.lib.BooleanHelper;
22: import org.objectweb.speedo.mapper.api.ClassPropertyManager;
23: import org.objectweb.speedo.mim.api.HomeItf;
24: import org.objectweb.util.monolog.api.BasicLevel;
25: import org.objectweb.util.monolog.api.Logger;
26:
27: import java.util.Properties;
28: import java.util.StringTokenizer;
29:
30: public class CPMUserCachePolicy implements ClassPropertyManager,
31: SpeedoProperties {
32:
33: public String getName() {
34: return USER_CACHE_CLASS_POLICY;
35: }
36:
37: public void applyDefault(HomeItf home, Properties props, Logger l) {
38: }
39:
40: public void applyDefault(HomeItf gcHome, HomeItf refHome,
41: Properties props, Logger l) {
42: }
43:
44: public void applyProperty(String name, String value, HomeItf home,
45: Properties props, Logger logger) {
46: StringTokenizer st = new StringTokenizer(value, " ,;:/\t",
47: false);
48: while (st.hasMoreTokens()) {
49: String cacheName = st.nextToken();
50: home.activeUserCache(cacheName);
51: if (logger.isLoggable(BasicLevel.INFO)) {
52: logger.log(BasicLevel.INFO,
53: "Activating the user cache '" + cacheName
54: + "' for the class '" + home.getPath());
55: }
56: //activate cache for all subclasses
57: PClassMapping[] subPcms = null;
58: try {
59: subPcms = home.getSubPCMs();
60: } catch (Exception e) {
61: logger.log(BasicLevel.WARN, "cannot apply property '"
62: + name + "' to the sub classes of '"
63: + home.getPath() + "': ", e);
64: }
65: if (subPcms != null) {
66: for (int i = 0; i < subPcms.length; i++) {
67: ((HomeItf) subPcms[i]).activeUserCache(cacheName);
68: }
69: }
70: }
71: }
72:
73: public void applyProperty(String name, String value,
74: HomeItf gcHome, HomeItf refHome, Properties props,
75: Logger logger) {
76: }
77: }
|