[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Basic Question on Aspects
|
Anytime you're frustrated with a "crosscutting concern" there's an application of AspectJ lurking
somewhere.
For example, I've used AspectJ to do the following:
+ register GUI components in a GUI testing framework
+ place methods on the "Swing thread" (by using around advice and invokeAndWait())
+ add listeners to a new Window, whenever one is created
And, in addition, there are patterns waiting to be discovered quite apart from the usual
crosscutting concerns. Below is a recipe which I first saw in ''AspectJ in Action'' by R. Laddad
(apologies if someone else actually thought of it first). It does address a crosscutting concern
when you think about it, but IMHO it takes on a life of its own. If this doesn't make you go
"Wow...", then I give up. :)
-Peter Kalmus
public interface Nameable {
public void setName(String name);
public String getName();
static aspect DefaultImplementation {
private String Nameable._name;
public void Nameable.setName(String name) {
_name = name;
}
public String Nameable.getName() {
return _name;
}
}
}
An implementation of Nameable:
public class MyClass implements Nameable {}
A test of MyClass:
public class Test {
public static void main(String[] argv) {
MyClass mc = new MyClass();
mc.setName("Bill");
System.out.println(mc.getName());
}
}
--- Sreekanth Vadagiri <SVadagir@xxxxxxxxxxxxxxxx> wrote:
>
>
>
>
> Hi Guys,
> I apologize if this group is not appropriate for this question. Please let
> me know if there is a appropriate group i could post this on.
>
> I like the whole concept of aspect but the problem is that it is restricted
> to a very limited set of problems. The examples that i see all the time is
> logging, transactions, exceptions handling, session management etc.
> i am yet to find a different problem to which aspects can be applied. Is
> there an example of application of aspects in problems different from the
> above?
>
> TIA
> Sreekanth
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/