//공통모듈임을 나타내주어야함! 순서는 상관없음! aspect는 콤포논트의 확장된 버전이면
//상관없는데, 얘는 확장한 버전이 아니라 두개를 같이 써줘야함
@Aspect
@Component
public class LogAspect {
}
@Before(value="execution(* com.gorakgarak..*(java.lang.String))")
public void beforeLogging(JoinPoint joinPoint){
System.out.println(joinPoint.getSignature().getName() + "메소드 호출 전 :" +
joinPoint.getArgs()[0]);
}
둘다 해줘야함
xml 설정은?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.2.xsd">
<context:component-scan base-package="com.gorakgarak.sample2.annotation"></context:component-scan>
<aop:aspectj-autoproxy/>
</beans>
'웹 & 프레임워크' 카테고리의 다른 글
자바스크립트로 md5구현 (0) | 2014.07.09 |
---|---|
Spring AOP 이용법, 매개변수 하나 (0) | 2014.06.27 |
Spring AOP란 무엇이고 용어를 알아보자 (0) | 2014.06.27 |
Spring AOP, LogAspect이용법 (0) | 2014.06.27 |
Spring @component 이용법 (0) | 2014.06.27 |