Package org.objectweb.speedo.mapper.lib

Source Code of org.objectweb.speedo.mapper.lib.CPMPrefetchOnGenClass

/**
* Copyright (C) 2001-2005 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
package org.objectweb.speedo.mapper.lib;

import org.objectweb.jorm.api.PClassMapping;
import org.objectweb.jorm.mapper.rdb.genclass.RdbGenClassProp;
import org.objectweb.jorm.mapper.rdb.lib.RdbPrefetchablePCM;
import org.objectweb.speedo.api.SpeedoProperties;
import org.objectweb.speedo.genclass.AbstractGenClassHome;
import org.objectweb.speedo.lib.BooleanHelper;
import org.objectweb.speedo.mapper.api.ClassPropertyManager;
import org.objectweb.speedo.mim.api.HomeItf;
import org.objectweb.util.monolog.api.Logger;

import java.util.Properties;


public class CPMPrefetchOnGenClass
  implements ClassPropertyManager, SpeedoProperties {

  public String getName() {
    return PREFETCH_ON_GENCLASS;
  }

  public void applyDefault(HomeItf home, Properties props, Logger l) {
        String str = props.getProperty(PREFETCH_ON_GENCLASS);
        if (str != null) {
            home.setPrefetchOnGenClass(BooleanHelper.parse(str, true));
        }
  }
  public void applyDefault(HomeItf gcHome, HomeItf refHome, Properties props, Logger l) {
    if (gcHome instanceof AbstractGenClassHome) {
      PClassMapping gcm = ((AbstractGenClassHome) gcHome).getRealPClassMapping();
      if (gcm instanceof RdbGenClassProp) {
        if (refHome instanceof RdbPrefetchablePCM) {
          ((RdbGenClassProp) gcm).setPrefetchElementPCM(
              (RdbPrefetchablePCM) refHome);
        }
      }
    }
  }
  public void applyProperty(String name, String value,
      HomeItf home, Properties props, Logger logger) {
    home.setPrefetchOnGenClass(BooleanHelper.parse(value, true));
  }
  public void applyProperty(String name, String value,
      HomeItf gcHome, HomeItf refHome, Properties props, Logger logger) {
    applyDefault(gcHome, refHome, null, null);
  }
}
TOP

Related Classes of org.objectweb.speedo.mapper.lib.CPMPrefetchOnGenClass

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.