[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [ajdt-dev] Need help with an advice
|
Hello Matthew,
thanks for the tip. actually i figured out that a withincode pointcut will help better, since i'll intercept
call to one method done within the scope of another method, which is exactly what i wanted..
Since i m here, i'd need to ask you one general question about aspectJ.
By reading some docs about it, i found out that one interesting use of aspectJ will be
for 'evolution of existing systems', which it means afaik that you can just change or add
behaviour to existing code without touching it..
does it ring any bells?
does it make sense to use aspectJ for evolving a system EVEN THOUGH you have
access to existing code?
thanks and regards
marco
thanx again and
On 3/15/06, Matthew Webster <matthew_webster@xxxxxxxxxx
> wrote:
Marco,
I think you need around call advice:
public aspect MyAspect {
pointcut
myMethod() :
execution
(* myMethod(..));
pointcut retrieveCollection()
:
call (*
com.Bean2.getItems(..))
&&
within(MyBeanX);
Object around() : retrieveCollection()
{
System.err.println("There
you go.. intercepted as we were expecting..");
hello all,
i have to modify an existing code to respect some new business rules..
Although i have access to the existing code, i prefer to implement this
functionality wiht an aspect (i hate
those if..else etc that just clutter my code..)
i have following situation though (this is just an excerpt, i need to do
similar functionality
further later in same method
public class MyBeanX {
....
private void myMethod(String args) {
Collection items = bean2.getItems(..)
}
.....
}
what i need to do is to replace that Collection items = bean2.getItems()
with a different call that does something else (but
still return a collection)
i have thought to crete somethinglike this...
public aspect MyAspect {
pointcut myMethod() :
execution (* com.BeanXmy.myMethod(..));
pointcut retrieveCollection() :
execution (* com.Bean2.getItems(..))
&& within(MyAspect);
void around() : retrieveCollection() {
System.err.println("There you go.. intercepted
as we were expecting..");
}
looking from cross-references in aspectJ,looks like something is
wrong since the around() advice does not intercept any methods...
can anyone tell me where my aspect code is wrong?
thanks and regards
marco
_______________________________________________
ajdt-dev mailing list
ajdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ajdt-dev