📄 resourcedaofactory.java
字号:
package com.eline.wap.resource.dao;
import com.eline.wap.common.util.AppKeys;
import com.eline.wap.common.util.AppSettings;
import com.eline.wap.resource.exceptions.ResourceDAOSysException;
public class ResourceDAOFactory {
static public CategoryDAO getCategoryDAO() throws ResourceDAOSysException {
CategoryDAO categoryDao = null;
try {
String provider = AppSettings.getInstance().getProperty(AppKeys.DS_TYPE);
if (provider == null || provider.equals("") || provider.equalsIgnoreCase("SQLServer"))
categoryDao = new MSSqlCategoryDAO();
else if (provider.equalsIgnoreCase("Oracle"))
throw new ResourceDAOSysException("unsupported datasource type.");
/*InitialContext ic = new InitialContext();
String className = (String) ic.lookup(JNDINames.CATEGORY_DAO_CLASS);
categoryDao = (CategoryDAO) Class.forName(className).newInstance();*/
} catch (ResourceDAOSysException e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: ResourceDAOSysException while getting DAO type : \n" + e.getMessage());
} catch (Exception e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: Exception while getting DAO type : \n" + e.getMessage());
}
return categoryDao;
}
static public BookDAO getBookDAO() throws ResourceDAOSysException {
BookDAO bookDao = null;
try {
String provider = AppSettings.getInstance().getProperty(AppKeys.DS_TYPE);
if (provider == null || provider.equals("") || provider.equalsIgnoreCase("SQLServer"))
bookDao = new MSSqlBookDAO();
else if (provider.equalsIgnoreCase("Oracle"))
throw new ResourceDAOSysException("unsupported datasource type.");
} catch (ResourceDAOSysException e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: ResourceDAOSysException while getting DAO type : \n" + e.getMessage());
} catch (Exception e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: Exception while getting DAO type : \n" + e.getMessage());
}
return bookDao;
}
static public PictureDAO getPictureDAO() throws ResourceDAOSysException {
PictureDAO pictureDao = null;
try {
String provider = AppSettings.getInstance().getProperty(AppKeys.DS_TYPE);
if (provider == null || provider.equals("") || provider.equalsIgnoreCase("SQLServer"))
pictureDao = new MSSqlPictureDAO();
else if (provider.equalsIgnoreCase("Oracle"))
throw new ResourceDAOSysException("unsupported datasource type.");
} catch (ResourceDAOSysException e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: ResourceDAOSysException while getting DAO type : \n" + e.getMessage());
} catch (Exception e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: Exception while getting DAO type : \n" + e.getMessage());
}
return pictureDao;
}
static public NewsDAO getNewsDAO() throws ResourceDAOSysException {
NewsDAO NewsDao = null;
try {
String provider = AppSettings.getInstance().getProperty(AppKeys.DS_TYPE);
if (provider == null || provider.equals("") || provider.equalsIgnoreCase("SQLServer"))
NewsDao = new MSSqlNewsDAO();
else if (provider.equalsIgnoreCase("Oracle"))
throw new ResourceDAOSysException("unsupported datasource type.");
} catch (ResourceDAOSysException e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: ResourceDAOSysException while getting DAO type : \n" + e.getMessage());
} catch (Exception e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: Exception while getting DAO type : \n" + e.getMessage());
}
return NewsDao;
}
static public RingDAO getRingDAO() throws ResourceDAOSysException {
RingDAO RingDao = null;
try {
String provider = AppSettings.getInstance().getProperty(AppKeys.DS_TYPE);
if (provider == null || provider.equals("") || provider.equalsIgnoreCase("SQLServer"))
RingDao = new MSSqlRingDAO();
else if (provider.equalsIgnoreCase("Oracle"))
throw new ResourceDAOSysException("unsupported datasource type.");
} catch (ResourceDAOSysException e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: ResourceDAOSysException while getting DAO type : \n" + e.getMessage());
} catch (Exception e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: Exception while getting DAO type : \n" + e.getMessage());
}
return RingDao;
}
static public KJavaDAO getKJavaDAO() throws ResourceDAOSysException {
KJavaDAO kjavaDao = null;
try {
String provider = AppSettings.getInstance().getProperty(AppKeys.DS_TYPE);
if (provider == null || provider.equals("") || provider.equalsIgnoreCase("SQLServer"))
kjavaDao = new MSSqlKJavaDAO();
else if (provider.equalsIgnoreCase("Oracle"))
throw new ResourceDAOSysException("unsupported datasource type.");
} catch (ResourceDAOSysException e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: ResourceDAOSysException while getting DAO type : \n" + e.getMessage());
} catch (Exception e) {
throw new ResourceDAOSysException("ResourceDAOFactory.getDAO: Exception while getting DAO type : \n" + e.getMessage());
}
return kjavaDao;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -