Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Any useful examples

Ok, how about this one:

In an EJB environment, I have various fairly orthogonal things to do when
writing an EJB. Let's say I have a stateless session bean with a method on a
remote interface. The things to consider are:

a) programmatic security (assume security requirements are too complex for
declaritive security only)
b) validation of parameters
c) the business logic of the method

Without aspects, these concerns would all be in the implementation of the
method on the SLSB. Now with aspects, I can write an aspect for security,
using an "excecution()" aspect selecting the method. In the aspect, I have
access to the bean's context, eg the javax.ejb.SessionContext, and the
method parameters, so I can implement any programmatic security
restrictions. Similarly, I can have another aspect for parameter validation.
The aspects throw security or validation exceptions.

Finally, the actual method on the session bean is called, which now contains
only the real business logic. Future changes in validation and/or security
policy don't touch the business logic code.

So I have dealt with the orthogonal concerns a)-c) separately, and since I
have used "exceution()" pointcut, I haven't touched client code. 

I can post the details of how I have this working, following helpful advice
from this list, if anyone is interested.

Regs,
Nick.



-----Original Message-----
From: Kenworthy, Edward (EDS) [mailto:Edward.Kenworthy@xxxxxxxxxxx]
Sent: Friday, 8 August 2003 5:55 PM
To: 'aspectj-users@xxxxxxxxxxx'
Subject: [aspectj-users] Any useful examples


Been following Aspects for a year/18 months but never really dived in,
principally because I still don't see the point ;-)

Sure they're useful for adding logging (but that's only one thing), I can
see that, but many of the other examples (eg strapping on a UI) would be
better solved using other techniques (eg patterns, MVC etc). Anyone have, or
can point me at, an example of a non-trivial application of aspects that
either couldn't be solved another way, or is much, much easier solved using
aspects ? The example doesn't need to be complex, but what it's doing should
be non-trivial (if you see what I mean).

On a related note, anyone know if there's a plugin for IDEA ? Scanned their
boards and a couple of developers are using AspectJ with IDEA, but no
mention of how (by hand using Ant or using a plug-in or something else ?)

Thanks in advance.

Edward

PS

I've downloaded the examples and faq, and (maybe I'm not seeing the wood for
the trees) but I couldn't see such an example there.


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


Back to the top