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.mapper.api.ClassPropertyManager;
21: import org.objectweb.speedo.mim.api.HomeItf;
22: import org.objectweb.util.monolog.api.BasicLevel;
23: import org.objectweb.util.monolog.api.Logger;
24:
25: import java.util.Properties;
26:
27: /**
28: *
29: *
30: * @author S.Chassande-Barrioz
31: */
32: public class CPMTransactionLockingLevel implements
33: ClassPropertyManager, SpeedoProperties {
34:
35: public String getName() {
36: return TRANSACTION_LOCKING_LEVEL;
37: }
38:
39: public void applyDefault(HomeItf home, Properties props, Logger l) {
40: }
41:
42: public void applyDefault(HomeItf gcHome, HomeItf refHome,
43: Properties props, Logger l) {
44: }
45:
46: public void applyProperty(String name, String value, HomeItf home,
47: Properties props, Logger logger) {
48: applyProp(home, value, logger);
49: }
50:
51: public void applyProperty(String name, String value,
52: HomeItf gcHome, HomeItf refHome, Properties props,
53: Logger logger) {
54: applyProp(gcHome, value, logger);
55: }
56:
57: private void applyProp(HomeItf home, String value, Logger logger) {
58: //Locking level= instance | field
59: if (logger.isLoggable(BasicLevel.INFO)) {
60: logger.log(BasicLevel.INFO, "Use the locking level '"
61: + value + "' for the class '" + home.getPath());
62: }
63: if (TRANSACTION_LOCKING_LEVEL_FIELD.equalsIgnoreCase(value)) {
64: home.setFieldLockingLevel(true);
65: } else if (TRANSACTION_LOCKING_LEVEL_INSTANCE
66: .equalsIgnoreCase(value)) {
67: home.setFieldLockingLevel(false);
68: } else {
69: logger.log(BasicLevel.WARN, "Locking level '" + value
70: + "' specified for the class '" + home.getPath()
71: + "' is not managed.");
72: }
73: }
74: }
|