Ilybra: aspects battlefield

On aspects in Ilybra project…

Great people like Ron Bodkin talk about the pragmatic way of doing software. So why don’t me, when I have this experience and I’m just hot to tell the world to look at the other side of this matrix..

Ilybra is a battlefield when it comes to aspects. Ther first aspect was tracing of course, the rest you see below, and today I got an idea on another one to my collection. Some people will even call my aspects “enterprise”! As you wish :) I don’t know the meaning of that word. I just develop an application for my library ladies.. ;)

Like it was said in the Ilybra: introduction, Ilybra utilizes some custom made aspects. They are:

  • authorization and authentification
  • optimization of access to some sorted data collection
  • tracing execution of Struts actions
  • dirty problem with null parameters
  • reseting Struts’ forms
  • measure the action invocation time
  • …and will be more, when need arises
  • Oh my, and I’ve just forgotten about the most important one: persistence – see how invisible it is my way :)

Many! lines of code has just disappeared from my classes. This is the core value of aspects. My code is cleaner.I will demonstrate you my Struts’ action code with: tracing, authorization, persistence, returning empty String instead of null, resetting forms and measuring time of invocation of action – ufff, a lot :) :

My full, original code (without any cheating or removal lines of code for the sake of the presentation of the example) of user story: Prolong copy on reader’s account: enter new date, accept choice, view confirmation.
Note: of course, there exists one, additional, global ilybra-aop.xml AOP configuration file for defining pointcuts.

Interested in library.prolongCopy(..) or library.getCopyById(..)??

..Authorization and authentification are common in applications. And so it is with Ilybra. It is 2 years now, I started to work on the application, but only from the last week the system must authorize a reader to access his account.

What is important here I’ve managed to add this concern – orthogonal concern – after the application was finished. I’ve done it with one simple aspect listening on all Struts actions, which checks if there is a User object in a session. Implementation is trivial. And aspect oriented way turned out to work. (This implementation could also be done using “servlet’s filters”, as they also crosscut expected behaviour in this particular example).

Code of the aspect on the plate:

I hope those examplets will clear your mind for a moment :)