在此,我們用定義了一個接口: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";
?。?) 定義解析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";
?。?) 定義實現解析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