日期:2014-05-17 浏览次数:20682 次
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.hxy.mlp.common; import java.io.FileInputStream; import java.io.InputStream; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; /** * * @author Arondight */ public class StartServlet extends HttpServlet { @Override public void init() throws ServletException { try { String path = this.getServletContext().getRealPath("/WEB-INF/config.properties"); InputStream in = new FileInputStream(path); Config.prop.load(in); } catch (Exception ex) { throw new ServletException(ex.getMessage()); } } }
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.hxy.mlp.common; import com.hxy.mlp.idao.*; import com.hxy.mlp.iservice.*; /** * * @author Arondight */ public class MyFactory { private static Object getObject(String name) { try { String className = Config.prop.getProperty(name); Object obj = Class.forName(className).newInstance(); return obj; } catch (Exception ex) { ex.printStackTrace(); return null; } } public static IMlpUserDao createMlpUserDao() { return (IMlpUserDao) getObject("mlpUserDao"); } public static IMlpHomeDao createMlpHomeDao() { return (IMlpHomeDao) getObject("mlpHomeDao"); } public static IMlpCategoryDao createMlpCategoryDao() { return (IMlpCategoryDao) getObject("mlpCategoryDao"); } public static IMlpArticleDao createMlpArticleDao() { return (IMlpArticleDao) getObject("mlpArticleDao"); } public static IMlpReviewDao createMlpReviewDao() { return (IMlpReviewDao) getObject("mlpReviewDao"); } public static IMlpPictureDao createMlpPictureDao() { return (IMlpPictureDao) getObject("mlpPictureDao"); } public static IMlpMsgDao createMlpMsgDao() { return (IMlpMsgDao) getObject("mlpMsgDao"); } public static IMlpUserService createMlpUserService() { return (IMlpUserService) getObject("mlpUserService"); } public static IMlpHomeService createMlpHomeService() { return (IMlpHomeService) getObject("mlpHomeService"); } public static IMlp