日期:2014-05-20 浏览次数:20783 次
public class RoleService extends BaseService {
private IRoleDao roleDao;
public ServiceReturns<List<Role>> findAll() throws Exception {
String ss ;
try {
List<Role> allRoleList = roleDao.findAll(Role.class);
if (allRoleList.size() <= 0) {
this.setSuccess(false);
this.setMessageCode(MessageConstant.FIND_ALLROLE_FAILURE);
return this;
}
this.setDataObject(allRoleList);
this.setForwardUrl(ForwardUrlConstant.FIND_ALLROLE_SUCCESS);
return this;
} catch (Exception exception) {
this.saveLog(exception, new LogDetails(
ModuleConstant.MODULE_ROLE_MANAGEMENT,
ModuleConstant.METHOD_COMMON_FIND_ALL, getClassName()),
MessageConstant.FIND_ALLROLE_FAILURE);
this.setSuccess(false);
}
return this;
}
这个类中好几个return this 各代表什么意思啊?
public class BaseService<T> extends ServiceReturns<T>{
private LogDetails logDetails = new LogDetails();
protected LogDao logDao;
public void saveLog(LogDetails log){
logDao.save(log);
}
public LogDao getLogDao() {
return logDao;
}
.....
public class ServiceReturns<T> {
private boolean success ;
private String messageCode;
private T dataObject;
private String forwardUrl="";
public String getMessageCode() {
return messageCode;
}
public void setMessageCode(String messageCode) {
this.messageCode = messageCode;
}
public ServiceReturns() {
}
public ServiceReturns(boolean _success) {
this.success = _success;
}
.....
RoleService其实继承了serviceReturn ,但是RoleService 中的方法返回的又是serviceReturn ,RoleService 中的方法return this指的是什么,RoleService 中的saveLog方法里面的this.setSuccess(false)应该值的是ServiceReturn类中的变量,而对这个方法而言没有返回值啊?
我去完全晕了!!!!