Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Passing in parameters from runtime code

Title: RE: [aspectj-users] Passing in parameters from runtime code

The user will be in the HttpSession, it is part of the requirements set forth by the ServletFilters that handle security.  At the same time I should try to support non-web based clients so being specific the HttpSession is prob. not a good idea.

Thanks for the tip!

--
Sloan


-----Original Message-----
From: Ramnivas Laddad [mailto:ramnivas@xxxxxxxxxxxxxxx]
Sent: Friday, September 03, 2004 2:18 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Passing in parameters from runtime code


You may want to store away the Subject object in a ThreadLocal or
HttpSession (depending upon if user is authenticated in the same request
or the same session as the execution of SQL statements of your interest)
object by advising the join points that obtain the authenticated user.
Then you can access the object inside advice to SQL statement execution.
Something like:

aspect LogSQLWithSubject {
    ThreadLocal currentSubjectHolder = new ThreadLocal();

    after returning(Subject subject)
        : call(method_that_returns_authenticated_subject) {
       currentSubjectHolder.set(subject);
    }

    before(String sqlString)
        : call(sql_statement_execution_method)
          && args(sqlString, ...) {
       Subject currentSubject = (Subject)currentSubjectHolder.get();
       ... log sqlString and currentSubject ...
    }
}

-Ramnivas

===
Ramnivas Laddad,
Author, AspectJ in Action
http://ramnivas.com

Seaman, Sloan wrote:

> How do I get a variable from the running code into some Aspect?
>
> What I mean to say is that I have an web app that for each user logged
> in, there is a javax.security.auth.Subject object for.  I'm using
> AspectJ to record all SQL statements that end up getting executed but
> how do I tie them to the Subject?
>
> I.E. How do I get the .aj code to have an instance of the Subject
> object?  I can't put it in a static place in memory because since it
> is a web app, I have to worry about threading issues.
>
> Anyone know how I can pull this off?
>
> Thanks!
>
> --
> Sloan
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top