Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » How to access 'this'
How to access 'this' [message #45111] Mon, 20 December 2004 19:22 Go to next message
Eclipse User
Originally posted by: sekar.gopinathan.fhlbny.com

Hi
I am trying to create an aspect for auditing within our application.
Usually our application has a service object and the service object passes
itself to the auditing service object. So in effect our service object
code would look like

serviceA{
....
execute(...){
//Do the task
auditService.execute(this)
}

Now I want to put the 'auditService.execute(this) into an aspect.
Inside my aspect can I write something like?
public aspect DoAudit {

pointcut doAudit():execution(* AbstractBusinessService.execute);

after():doAudit(){
auditStep.execute(thisJoinPoint.getThis());
}
}

When I was reading the API spec, I read that for perfomance reasons
getThis should not be used. Is my understanding correct? Or is there
any other way to do the same task. I am not sure if I missed something
from the manual. I appreciate if someone can point me in the right
direction.

Thanks
Re: How to access 'this' [message #45145 is a reply to message #45111] Mon, 20 December 2004 22:50 Go to previous messageGo to next message
Eclipse User
Originally posted by: newsserver_mails.bodden.de

On Mon, 20 Dec 2004 19:22:51 +0000 (UTC), Sekar Gopinathan wrote:
> public aspect DoAudit {
>
> pointcut doAudit():execution(* AbstractBusinessService.execute);
>
> after():doAudit(){
> auditStep.execute(thisJoinPoint.getThis());
> }
> }
>
> When I was reading the API spec, I read that for perfomance reasons
> getThis should not be used. Is my understanding correct? Or is there
> any other way to do the same task. I am not sure if I missed something
> from the manual. I appreciate if someone can point me in the right
> direction.
Indeed. correct it to:

public aspect DoAudit {

pointcut doAudit(serviceA s):
execution(* AbstractBusinessService.execute(serviceA)) && this(s);

after(serviceA sa):doAudit(sa){
auditStep.execute(sa);
}
}

Then in the pointcut, "this" is bound to the formal s. In the piece of
advice, "sa" is bound to that very instance.

Eric

--
Eric Bodden, ICQ: 12656220, http://www.bodden.de, PGP: BB465582
Active Desktop Wallpaper Changer: That's what it is...
http://bodden.de/projects/wpchanger/
Re: How to access 'this' [message #45176 is a reply to message #45145] Tue, 21 December 2004 00:28 Go to previous message
Eclipse User
Originally posted by: sekar.gopinathan.fhlbny.com

Eric,
It worked.

AOP requries one to think very differently. I am getting there.

Thanks you.

Eric Bodden wrote:

> On Mon, 20 Dec 2004 19:22:51 +0000 (UTC), Sekar Gopinathan wrote:
>> public aspect DoAudit {
>>
>> pointcut doAudit():execution(* AbstractBusinessService.execute);
>>
>> after():doAudit(){
>> auditStep.execute(thisJoinPoint.getThis());
>> }
>> }
>>
>> When I was reading the API spec, I read that for perfomance reasons
>> getThis should not be used. Is my understanding correct? Or is there
>> any other way to do the same task. I am not sure if I missed something
>> from the manual. I appreciate if someone can point me in the right
>> direction.
> Indeed. correct it to:

> public aspect DoAudit {

> pointcut doAudit(serviceA s):
> execution(* AbstractBusinessService.execute(serviceA)) && this(s);

> after(serviceA sa):doAudit(sa){
> auditStep.execute(sa);
> }
> }

> Then in the pointcut, "this" is bound to the formal s. In the piece of
> advice, "sa" is bound to that very instance.

> Eric
Re: How to access 'this' [message #585360 is a reply to message #45111] Mon, 20 December 2004 22:50 Go to previous message
Eric Bodden is currently offline Eric Bodden
Messages: 32
Registered: July 2009
Member
On Mon, 20 Dec 2004 19:22:51 +0000 (UTC), Sekar Gopinathan wrote:
> public aspect DoAudit {
>
> pointcut doAudit():execution(* AbstractBusinessService.execute);
>
> after():doAudit(){
> auditStep.execute(thisJoinPoint.getThis());
> }
> }
>
> When I was reading the API spec, I read that for perfomance reasons
> getThis should not be used. Is my understanding correct? Or is there
> any other way to do the same task. I am not sure if I missed something
> from the manual. I appreciate if someone can point me in the right
> direction.
Indeed. correct it to:

public aspect DoAudit {

pointcut doAudit(serviceA s):
execution(* AbstractBusinessService.execute(serviceA)) && this(s);

after(serviceA sa):doAudit(sa){
auditStep.execute(sa);
}
}

Then in the pointcut, "this" is bound to the formal s. In the piece of
advice, "sa" is bound to that very instance.

Eric

--
Eric Bodden, ICQ: 12656220, http://www.bodden.de, PGP: BB465582
Active Desktop Wallpaper Changer: That's what it is...
http://bodden.de/projects/wpchanger/
Re: How to access 'this' [message #585378 is a reply to message #45145] Tue, 21 December 2004 00:28 Go to previous message
Eclipse User
Originally posted by: sekar.gopinathan.fhlbny.com

Eric,
It worked.

AOP requries one to think very differently. I am getting there.

Thanks you.

Eric Bodden wrote:

> On Mon, 20 Dec 2004 19:22:51 +0000 (UTC), Sekar Gopinathan wrote:
>> public aspect DoAudit {
>>
>> pointcut doAudit():execution(* AbstractBusinessService.execute);
>>
>> after():doAudit(){
>> auditStep.execute(thisJoinPoint.getThis());
>> }
>> }
>>
>> When I was reading the API spec, I read that for perfomance reasons
>> getThis should not be used. Is my understanding correct? Or is there
>> any other way to do the same task. I am not sure if I missed something
>> from the manual. I appreciate if someone can point me in the right
>> direction.
> Indeed. correct it to:

> public aspect DoAudit {

> pointcut doAudit(serviceA s):
> execution(* AbstractBusinessService.execute(serviceA)) && this(s);

> after(serviceA sa):doAudit(sa){
> auditStep.execute(sa);
> }
> }

> Then in the pointcut, "this" is bound to the formal s. In the piece of
> advice, "sa" is bound to that very instance.

> Eric
Previous Topic:How to access 'this'
Next Topic:aspect in J2ee
Goto Forum:
  


Current Time: Tue Sep 16 13:34:06 GMT 2014

Powered by FUDForum. Page generated in 0.02470 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software