在此,我们用定义了一个接口:config.java /* * Created on 2005-8-29 * * the supper class for parse the xml files * * TODO To change the template for this generated file go to * Window - PReferences - Java - Code Style - Code Templates */ package zy.pro.wd.xml;
/** * @author zhangyi * * TODO To change the template for this generated type comment go to Window - * Preferences - Java - Code Style - Code Templates */ public abstract class Config { /** * the supper class for parse the xml files */ protected Element root;
(三) 定义解析我们自定义配置文件(XML文件)的 抽象类,此处我们定义了DataSourceConfig.java,文件内容如下: /* * Created on 2005-8-29 * *reading the JDBC datasource properties from xml files * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package zy.pro.wd.xml;
/** * @author zhangyi * * TODO To change the template for this generated type comment go to Window - * Preferences - Java - Code Style - Code Templates */ public abstract class DataSourceConfig extends Config { private static final String DATABASE_USER = "DatabaseUser";
private static final String DATABASE_PASSWord = "DatabasePassword";
private static final String SERVER_NAME = "ServerName";
private static final String DATABASE_NAME = "DatabaseName";
private static final String SERVER_PORT = "ServerPort";
(1) 定义解析MS SQL 数据源的实现类MSSQLConfig.java.内容如下: /* * Created on 2005-8-31 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package zy.pro.wd.xml;
/** * @author zhangyi * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class MSSQLConfig extends DataSourceConfig {
private static final String MAX_CONNECTIONS = "MaxConnections";
(2) 定义实现解析oracle数据源的实现类OracleConfig.java,内容如下: /* * Created on 2005-8-29 * *parse the xml file of the oracle configure * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ pa