Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
AOP 설정 시 '@target' Pointcut Designator 써보신분 계신가요?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
심상호  
View profile   Translate to Translated (View Original)
 More options Mar 9 2011, 11:16 pm
From: 심상호 <cutebear0...@gmail.com>
Date: Wed, 9 Mar 2011 20:16:47 -0800 (PST)
Local: Wed, Mar 9 2011 11:16 pm
Subject: AOP 설정 시 '@target' Pointcut Designator 써보신분 계신가요?
제가 구현하고자 하는 기능이 특정 Annotation이 붙어있는 interface의 method 호출 시 Log를 남기는 기능입
니다.

그래서 LogTarget Annotation을 만들고, Pointcut을 "@target(LogTarget)"으로 지정했더니
Application Context에 있는 모든 Bean을 대상으로 Proxy를 생성하려고 하는 현상이 발생했습니다.

@Documented
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface LogTarget {

}

이상해서 간단한 Test를 생성해서 돌려보니 역시나 이상한 값이 나옵니다.

String expression = "@target(LogTarget)";
Class<?> targetClass = ApplicationContext.class;

AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
pointcut.setExpression(expression);

System.out.println(AopUtils.canApply(pointcut, targetClass));

여러분이 다 아시는 ApplicationContext interface에는 LogTarget 이라는 Annotation이 붙어있
지 않은데도 AopUtils.canApply method는 true 를 return하고 있습니다.

Debugging 하면서 소스코드를 따라가다보니 AspectJ 에 문제가 있는 듯 하기도 한데, 혹시 이 문제 관련해서 뭔가 아
시는 분 계신가요?

사용하고 있는 버전은

Springframework : 3.0.5.RELEASE
AspectJ : 1.6.10

입니다.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
황지환  
View profile   Translate to Translated (View Original)
 More options Mar 10 2011, 1:06 am
From: 황지환 <hjhb...@naver.com>
Date: Wed, 9 Mar 2011 22:06:17 -0800 (PST)
Local: Thurs, Mar 10 2011 1:06 am
Subject: Re: AOP 설정 시 '@target' Pointcut Designator 써보신분 계신가요?
흥미롭네요.
@within 으로 테스트 해보셨나요?
덕분에, target, within 이 의미가 좀 다른걸 알았네요.
나이스한 답변은 못드리겠네요;;;

앞전에 토스 읽기 모임에서 표시인터페이스 얘기를 했었는데,
역시 AOP 와 Annotation 함께 사용하면 막강하겠네요.

On 3월10일, 오후1시16분, 심상호 <cutebear0...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
심상호  
View profile   Translate to Translated (View Original)
 More options Mar 10 2011, 1:46 am
From: 심상호 <shs...@crossent.com>
Date: Thu, 10 Mar 2011 15:46:25 +0900
Local: Thurs, Mar 10 2011 1:46 am
Subject: Re: [KSUG] Re: AOP 설정 시 '@target' Pointcut Designator 써보신분 계신가요?

@within 으로도 테스트해봤습니다.

일단 interface에 있는 annotation을 사용하여 AOP를 적용하는 것은 불가능하다하는건 알아냈습니다.

@within의 경우 annotation이 직접 선언된 Class에서 직접 구현한 method만을 선택하고, @target(제대로
동작하는 경우)의 경우 annotation이 직접 선언된 Class가 구현한 method를 선택합니다. @annotation은
annotation이 직접 붙어있는 method만을 선택합니다.

즉, @within, @target, @annotation 모두, 구현체(Class)에만 적용되어서 제가 하고자 했던 기능은
불가능합니다.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
심상호  
View profile   Translate to Translated (View Original)
 More options Mar 10 2011, 2:55 am
From: 심상호 <shs...@crossent.com>
Date: Thu, 10 Mar 2011 16:55:07 +0900
Local: Thurs, Mar 10 2011 2:55 am
Subject: Re: [KSUG] Re: AOP 설정 시 '@target' Pointcut Designator 써보신분 계신가요?

자문자답은 아니고...

좀 더 테스트를 해보니 "execution"과 "@target" 을 같이 사용하는 경우, execution에 의해서 한정된 Bean들에
대해서 Proxy를 생성하고, 동작은 원하는 방식대로 동작합니다. 즉, "@target" designator는 Proxy 대상을
선택할때는 적용되지 않고 실제 Method 호출 시 동작하는 것으로 판단됩니다.

Spring Forum의 http://forum.springsource.org/showthread.php?t=28525 를 보면,
"@within"과 "@target"의 차이점은 Join-point를 선택하는 시점의 차이라고 되어 있고 Spring에서는 차이가 없다고
되어 있습니다.

위 글을 봐서는 "@target" 으로 지정된 Bean에 대해서 advice 수행 여부를 Runtime에 결정하겠다는 의도로 해당
Bean을 Proxy로 만드는 듯 한데요. 굳이 그럴 필요가 있나 하는 생각이 듭니다.

그리고 한가지 드는 생각은 "@target" designator를 단독으로 사용하거나, 같이 사용하는 designator의 지정 범위가
넓을 경우 불필요한 Proxy가 많이 생기겠구나...하는 점이네요.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »