1. POM파일
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
2. Class 파일 (해당 클래스에 구현된 모든 함수에서 User를 리턴하는 함수에 패스워드를 null로 해주는 것 구현)
@Aspect
public class UserAspect {
@Around (value = "execution (public 패키지.User 패키지.UserDaoImpl.*(..))")
public User removeUserPasswordMethod (final ProceedingJoinPoint joinPoint) {
try {
final User user = (User) joinPoint.proceed();
if (user != null) {
user.setPassword(null);
}//end if
return user;
} catch (Throwable e) {
e.printStackTrace();
}//end try/catch
return null;
}//end removeUserPasswordMethod Method
3. 설정파일 설정
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<aop:aspectj-autoproxy/>
<bean id="userAspect" class="com.wisekids.wkdbserver.aop.UserAspect"/>
'Development > Web & Server' 카테고리의 다른 글
[Hibernate] 원하는 값만 가져오기~! (0) | 2014.01.17 |
---|---|
[Hibernate] update 와 merge 차이점 (0) | 2014.01.17 |
[Hibernate] DB 특정 값 암호화하여 사용하기~! (Jasypt) (0) | 2014.01.10 |
[Hibernate] Hibernate4 와 EHCache 연동하기~!! (0) | 2014.01.07 |
[Hibernate] Date 검색 (0) | 2014.01.06 |