⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyfactory.java

📁 噶额外噶外骨骼感广泛高热感 就 啊啊
💻 JAVA
字号:
/*
 * @author                        : Neelesh
 * @Version                       : 1.0
 *
 * Development Environment        : Oracle9i JDeveloper
 * Name of the Application        : KeyFactory.java
 * Creation/Modification History  :
 *
 * Neelesh    23-Feb-2003      Created
 *
 */
package oracle.otnsamples.util;

/**
 * This class provides a static method to obtain a unique id based on a
 * predefined strategy. To change the strategy, the user must write a class
 * which implements the interface KeyGenerator, and change the value of the
 * final variable 'keyGeneratorClass' in this class.
 *
 * @author Neelesh
 * @version 1.0
 */
public class KeyFactory {

  // Name of the key generation strategy implementation
  private static final String keyGeneratorClass =
    "oracle.otnsamples.util.GUIDGenerator";

  // A single instance of KeyGenerator
  private static KeyGenerator keyGenerator = null;

  // Initialize the key generator instance in the static block
  static {

    try {
      keyGenerator =
        (KeyGenerator) Class.forName(keyGeneratorClass).newInstance();
    } catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  /**
   * This method returns a globally unique id. The way in which the id is
   * generated depends on the strategy used. This method internally calls the
   * getKey() method of KeyGenerator interface
   *
   * @return <b>String</b> unique id
   */
  public static String getKey() {

    return keyGenerator.getKey();
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -