[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] generics & LTW?
|
Hi Larry,
> But I could generate an aop.xml file - that'd work. Except that it
doesn't appear that I can specify an aspect in aop.xml
> that extends,
say, "Isolator<some class name>".
This seems quite powerful.... so I just raised
https://bugs.eclipse.org/bugs/show_bug.cgi?id=266220 and implemented it.
My aop.xml now looks like this:
<aspectj>
<aspects>
<concrete-aspect name="IsolatorForCode" extends="Isolator<Code>"/>
</aspects>
</aspectj>
Will be in a dev build shortly. It actually gives some nice static crosscutting control from the XML form. Contrived example incoming:
abstract aspect Serializer<Z> {
declare parents: Z implements java.io.Serializable;
}
<aspectj>
<aspects>
<concrete-aspect name="MakeFooSerializable" extends="Serializer<Foo>"/>
</aspects>
</aspectj>
On your other point, there are ways to programmatically construct the aspect definitions (effectively replacing the Aj code that reads the XML to build them) but it is not easy (not as easy as it should be).
cheers,
Andy.
2009/2/20 Larry Edelstein
<ribs@xxxxxxx>
I've got an aspect that I'd like to weave, at load time, with one or more arbitrary classes (but ones loaded by the system classloader).
Two problems. An example of the kind of generic aspect I'd like to use, Isolator<T>, is below.
I want to weave it around one or more classes I specify at launch time. I'd really like to write some kind of launcher class that takes class names as parameters and does the weaving. But I could generate an aop.xml file - that'd work. Except that it doesn't appear that I can specify an aspect in aop.xml that extends, say, "Isolator<some class name>".
Alternatively, I could not use generics, and make the below aspect a bit more general, and have its concrete subaspects specify all the pointcuts necessary - one for the "within", and one for the internal calls.
Can anybody give me help on these?
Larry Edelstein
Senior Member of Technical Staff
public abstract aspect Isolator<T> {
pointcut dependencyCall() :
call()
&& within(T)
&& !internalCall()
&& !platformCall();
pointcut call() :
call(* *.*(..))
|| call(*.new(..));
pointcut internalCall() :
call(* T.*(..))
|| call(T.new(..));
pointcut platformCall() :
call(* java..*.*(..))
|| call(java..*.new(..));
Object around() : dependencyCall () {
// Does something here
}
}
public aspect ServiceIsolator extends Isolator<Service> {}
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users