ex7_24.txt
来自「j2ee core design patterns」· 文本 代码 · 共 48 行
TXT
48 行
Example 7.24 Implementing Lazy Loading strategy
...
public Collection getSkillSetsData() {
throws SkillSetException {
checkSkillSetLoad();
return skillSets;
}
private void checkSkillSetLoad()
throws SkillSetException {
try {
// Lazy Load strategy...Load on demand
if (skillSets == null)
skillSets =
getSkillSetDAO().findAllSkills(resourceId);
} catch (Exception exception) {
// No skills, throw an exception
throw new SkillSetException(...);
}
}
...
public void ejbLoad() {
try {
// load the resource info from
ResourceDAO resourceDAO = new ResourceDAO();
setResourceData(
resourceDAO.findResource(employeeId));
// If the lazy loaded objects are already
// loaded, they need to be reloaded.
// If there are not loaded, do not load them
// here...lazy load will load them later.
if (skillSets != null) {
reloadSkillSets();
}
if (blockOutTimes != null) {
reloadBlockOutTimes();
}
...
throw new EJBException("Reason:"+...);
}
}
...
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?