Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] pointers to struts and auditing

Hi Conrad,

You are right, this is a good use for the cflow pointcut designator. E.g.,

    public pointcut actionMethodExec(HttpServletRequest request) :
       execution(public ActionForward *(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse)) && args(*, *, request, *);

    pointcut businessOperation(request) :    cflow(strutsAction(request)) && businessMethod(); // businessMethod() is your existing pointcut

    before(HttpServletRequest request) : businessOperation(request) {
         HttpSession session = request.getSession();
         …

See for example http://www.eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html for more about cflow  This is related to the wormhole pattern which is described in AspectJ in Action…

Ron


From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Conrad CRAMPTON PSE 52704
Sent: Sunday, October 22, 2006 8:47 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] pointers to struts and auditing

 

Hi,

I want to provide an aspect that audits certain method calls in a struts based application. Can anyone give me some good practice on how to do this?

Currently I have an aspect which I have successfully set up to pick out my business methods that I am concerned with but at the business layer, there is no visibility of the httpsession variables that hold my user details. I want to use these user details to add to the auditing messages but don't know how to 'pass' them into the business method.

 

Do I just make the struts action that calls the business method in question the pointcut instead of the business method itself and therefore get a handle on the HttpServletRequest (and therefore the session and its attributes) or should I have some sort of cflow pointcut of my action and business method. I don't really 'get' cflow pointcuts just yet but sort of feel that this is an option.

 

Any suggestions would be most welcome here for someone very new to AOP - even though what I have done so far leads me to believe I will be using aspects much more in the future.

 

TIA

Conrad


Back to the top