日期:2014-05-17 浏览次数:20699 次
public class LogAdvice implements MethodBeforeAdvice {
@Override
public void before(Method method, Object[] args, Object target)
throws Throwable {
// TODO Auto-generated method stub
String targetClassName = target.getClass().getName();
String targetMethodName = method.getName();
String logInfoText="前置通知:" + targetClassName + "类的"+targetMethodName+"方法执行";
System.out.println(logInfoText);
}
}
public interface UserDAO {
public boolean login(String username, String password);
public void addUser(String username, String password);
public void delUser(int id);
}
public class UserDAOImpl implements UserDAO {
@Override
public boolean login(String username, String password) {
// TODO Auto-generated method stub
if (username.equals("admin") && password.equals("123")) {
return true;
}
return false;
}
@Override
public void addUser(String username, String password) {
// TODO Auto-generated method stub
System.out.println(username + "用户添加成功!");
}
@Override
public void delUser(int id) {
// TODO Auto-generated method stub
System.out.println("编号为" + id + "的用户被删除!");
}
}
public interface UserBiz {
public boolean login(String username, String password);
public void addUser(String username, String password);
public void delUser(int id);
}
public class UserBizImpl implements UserBiz {
UserDAO userDAO;
public void setUserDAO(UserDAO userDAO) {
this.userDAO = userDAO;
}
@Override
public boolean login(String username, String password) {