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.jorm.mapper.rdb.genclass.RdbGenClassProp;
21: import org.objectweb.jorm.mapper.rdb.lib.RdbPrefetchablePCM;
22: import org.objectweb.speedo.api.SpeedoProperties;
23: import org.objectweb.speedo.genclass.AbstractGenClassHome;
24: import org.objectweb.speedo.lib.BooleanHelper;
25: import org.objectweb.speedo.mapper.api.ClassPropertyManager;
26: import org.objectweb.speedo.mim.api.HomeItf;
27: import org.objectweb.util.monolog.api.Logger;
28:
29: import java.util.Properties;
30:
31: public class CPMPrefetchOnGenClass implements ClassPropertyManager,
32: SpeedoProperties {
33:
34: public String getName() {
35: return PREFETCH_ON_GENCLASS;
36: }
37:
38: public void applyDefault(HomeItf home, Properties props, Logger l) {
39: String str = props.getProperty(PREFETCH_ON_GENCLASS);
40: if (str != null) {
41: home.setPrefetchOnGenClass(BooleanHelper.parse(str, true));
42: }
43: }
44:
45: public void applyDefault(HomeItf gcHome, HomeItf refHome,
46: Properties props, Logger l) {
47: if (gcHome instanceof AbstractGenClassHome) {
48: PClassMapping gcm = ((AbstractGenClassHome) gcHome)
49: .getRealPClassMapping();
50: if (gcm instanceof RdbGenClassProp) {
51: if (refHome instanceof RdbPrefetchablePCM) {
52: ((RdbGenClassProp) gcm)
53: .setPrefetchElementPCM((RdbPrefetchablePCM) refHome);
54: }
55: }
56: }
57: }
58:
59: public void applyProperty(String name, String value, HomeItf home,
60: Properties props, Logger logger) {
61: home.setPrefetchOnGenClass(BooleanHelper.parse(value, true));
62: }
63:
64: public void applyProperty(String name, String value,
65: HomeItf gcHome, HomeItf refHome, Properties props,
66: Logger logger) {
67: applyDefault(gcHome, refHome, null, null);
68: }
69: }
|