zoukankan      html  css  js  c++  java
  • 工厂模式小例子 getDaoImp

    /**新建一个工厂类,创建dao层对象(单例模式)

    */

    public class DaoFactory{

      private static DaoFactory daoFactory;//私有化自身

      private DaoFactory(){};//私有化构造方法

      static{

      if(daoFactory==null){

        synchronized(DaoFactory.class){

          If(daoFactory==null){

            daoFactory =new DaoFactory();

          }

        }

    //工厂模式

    public static ConDao getDaoImpl(String daoImpl){

      CanDao caodao = null;

      if (daoImpl.equals("DetailDaoImpl")) {
      caodao = new DetailDaoImpl();
      } else if (daoImpl.equals("NewsCotegoryDaoImpl")) {
      caodao = new NewsCotegoryDaoImpl();
      } else if (daoImpl.equals("NewDaoImp")) {
      caodao = new NewDaoImp();
      }

      return caodao;

      }

    }

  • 相关阅读:
    git merge
    google platform
    http tutorial
    DS,AA tree
    Java,Hashtable
    java,Object
    Pumping lemma for regular languages
    Pumping lemma
    Context-free grammar
    Formal language
  • 原文地址:https://www.cnblogs.com/javaxiaodoufu/p/7357962.html
Copyright © 2011-2022 走看看