servicelocator.java

来自「这是一本描述JDBC数据库的书籍」· Java 代码 · 共 39 行

JAVA
39
字号
/* * ServiceLocator.java * * Created on June 11, 2005, 11:21 AM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */package ch02.locator;import ch02.manager.EmployeeDAO;import java.io.*;import java.util.*;/** * * @author kevin */public class ServiceLocator {    public static final String EMPLOYEE_SERVICE="employee_dao_service";    private static String employeeService = null;    /** Creates a new instance of ServiceLocator */    private ServiceLocator() {        InputStream is = getClass().getResourceAsStream("services.properties");        try{            Properties props = new Properties();            props.load(is);            employeeService = props.getProperty(EMPLOYEE_SERVICE);        }catch(Exception e){            e.printStackTrace();        }    }        public static EmployeeDAO getEmployeeDAO()throws Exception{        new ServiceLocator();        return (EmployeeDAO)Class.forName(employeeService).newInstance();    }}

⌨️ 快捷键说明

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