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.speedo.api.SpeedoProperties;
20: import org.objectweb.speedo.lib.BooleanHelper;
21: import org.objectweb.speedo.mapper.api.ClassPropertyManager;
22: import org.objectweb.speedo.mim.api.HomeItf;
23: import org.objectweb.util.monolog.api.BasicLevel;
24: import org.objectweb.util.monolog.api.Logger;
25:
26: import java.util.Properties;
27:
28: public class CPMShareablePolicy implements ClassPropertyManager,
29: SpeedoProperties {
30:
31: public String getName() {
32: return SHAREABLE;
33: }
34:
35: public void applyDefault(HomeItf home, Properties props, Logger l) {
36: String str = props.getProperty(SHAREABLE);
37: if (str != null) {
38: home.setPrefetchOnQuery(BooleanHelper.parse(str, true));
39: }
40: }
41:
42: public void applyDefault(HomeItf gcHome, HomeItf refHome,
43: Properties props, Logger l) {
44: String str = props.getProperty(SHAREABLE);
45: if (str != null) {
46: gcHome.setPrefetchOnQuery(BooleanHelper.parse(str, true));
47: }
48: }
49:
50: public void applyProperty(String name, String value, HomeItf home,
51: Properties props, Logger logger) {
52: if (logger != null && logger.isLoggable(BasicLevel.INFO)) {
53: logger.log(BasicLevel.INFO, "Use the shareable mode '"
54: + value + "' for the class '" + home.getPath());
55: }
56: home.setShareable(BooleanHelper.parse(props.getProperty(
57: SHAREABLE, value), true));
58: }
59:
60: public void applyProperty(String name, String value,
61: HomeItf gcHome, HomeItf refHome, Properties props,
62: Logger logger) {
63: if (logger != null && logger.isLoggable(BasicLevel.INFO)) {
64: logger.log(BasicLevel.INFO, "Use the shareable mode '"
65: + value + "' for the secondary class '"
66: + gcHome.getPath());
67: }
68: gcHome.setShareable(BooleanHelper.parse(props.getProperty(
69: SHAREABLE, value), true));
70: }
71:
72: }
|