only advise an object when its used in certain application scenarios

View: New views
2 Messages — Rating Filter:   Alert me  

only advise an object when its used in certain application scenarios

by Robert Taylor-19 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Greetings,
 
I need to advise the same object only in certain scenarios of an application.
 
For example,
I have a model object, say Person.
 
I use Hibernate to persist and retrieve Person objects.
 
I do not want to advise certain getter/setter methods on Person, when it
is in control of Hibernate framework.
 
However, I do want to advise those getter/setter methods on Person when it
is used in the UI tier. Essentially when the UI components retrieve information from
Person or the UI components populate Person with information.
 
I'm not sure how to define my point cuts for this situation (if it can be done).
 
/robert
 
 
 

_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Re: only advise an object when its used in certain application scenarios

by Andrew Eisenberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Robert,

You would need to use a cflow pointcut.  See
http://www.eclipse.org/aspectj/doc/released/progguide/quick.html#quick-pointcuts

You would want to do something like this:

pointcut uiTier() : within(com.foo.bar.ui..*);

pointcut personStuff() : within(Person);

before() : cflow(uiTier()) && personStuff() {  ... }

On Sun, Sep 20, 2009 at 7:09 PM, Robert Taylor <rtaylor@...> wrote:

> Greetings,
>
> I need to advise the same object only in certain scenarios of an
> application.
>
> For example,
> I have a model object, say Person.
>
> I use Hibernate to persist and retrieve Person objects.
>
> I do not want to advise certain getter/setter methods on Person, when it
> is in control of Hibernate framework.
>
> However, I do want to advise those getter/setter methods on Person when it
> is used in the UI tier. Essentially when the UI components retrieve
> information from
> Person or the UI components populate Person with information.
>
> I'm not sure how to define my point cuts for this situation (if it can be
> done).
>
> /robert
>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@...
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users