디자인패턴 AOP가 필요한 이유

황제낙엽 2008.10.08 17:16 조회 수 : 187 추천:85

sitelink1  
sitelink2  
sitelink3  
extra_vars4  
extra_vars5  
extra_vars6  
·미리보기 | 소스복사·
 
  1. public User findUser(String userId) throws UserNotFoundException {   
  2.  if(log.isDebugEnabled()) {   
  3.   log.debug("findUser() 시작");   
  4.   log.debug("User ID : " + userId);   
  5.  }   
  6.     
  7.  User user = null;   
  8.     
  9.  StopWatch clock = new StopWatch("Profiling ...");   
  10.  try {   
  11.   clock.start("findUser()");   
  12.   user = userDAO.findUser(userId);   
  13.  } finally {   
  14.   clock.stop();   
  15.  }   
  16.     
  17.  if(clock.getTotalTimeMillis() > 500) {   
  18.   if(log.isWarnEnabled()) {   
  19.    log.warn("Execution Source : UserDAO.findUser()");   
  20.    log.warn("Execution Time : " + clock.prettyPrint());   
  21.   }   
  22.  }   
  23.     
  24.  if(log.isDebugEnabled()) {   
  25.   log.debug("findUser() 종료");   
  26.  }   
  27.     
  28.  return user;   
  29.  

 


회색 박스안의 코드는 실제 비즈니스 로직이 아니다.
이 코드를 따로 분리해서 관리할 수 있다면...