Package org.objectweb.speedo.metadata

Source Code of org.objectweb.speedo.metadata.SpeedoDefaults

/**
* 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.metadata;

import org.objectweb.speedo.api.SpeedoException;
import org.objectweb.speedo.api.SpeedoRuntimeException;
import org.objectweb.speedo.lib.Personality;
import org.objectweb.speedo.metadata.ejb.EJBDefaults;
import org.objectweb.speedo.metadata.jdo.JDODefaults;

/**
* Is an helper class for loading default value of speedo meta objects.
*
* @author S.Chassande-Barrioz
*/
public abstract class SpeedoDefaults {
 
    /**
     * is the unique instance helping the initialization of speedo meta objects
     */
    private static SpeedoDefaults defaults;
 
    /**
     * This abstract method should initiaze a speedo meta Object.
     * @param se the speedo meta object to initialize.
     */
  public abstract void assignDefaults(Object se) throws SpeedoRuntimeException;
 
  /**
     * Initializes the defaults field with regards to the current personality
     * @param p the current personality
   */
    public static void init(Personality p) throws SpeedoException {
        String className = p.getPersonalityClassName(
                "org.objectweb.speedo.metadata", "Defaults");
    try {
      defaults = (SpeedoDefaults) Class.forName(className).newInstance();
    } catch (InstantiationException e) {
      throw new SpeedoException(
          "Cannot create object for Speedo defaults with class: "
                    + className, e);
    } catch (IllegalAccessException e) {
      throw new SpeedoException(
          "Cannot create object for Speedo defaults with class: "
                    + className, e);
    } catch (ClassNotFoundException e) {
      throw new SpeedoException(
          "Cannot create object for Speedo defaults with class: "
                    + className, e);
    }
  }
 
    /**
     * Set the default value for a Speedo Meta Object.
     * @param se the meta object to initiaze with default value of the current
     * personality.
     */
  public static void setDefaults(Object se) throws SpeedoRuntimeException {
    defaults.assignDefaults(se);
  }
}
TOP

Related Classes of org.objectweb.speedo.metadata.SpeedoDefaults

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.