Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Is this possible with Aspect/J?

#: Cees De Groot changed the world a bit at a time by saying (astral date: 7/7/2006 12:34 PM) :#
Hi,

I have a SOAP interface where one method, login(), generates a cookie
which all other methods have to send as the first parameter. So all
the other methods look like:

       public AttributeArrayResult getExtendedTransactionStatus(String key,
long transactionId) {
               Account account = AuthenticationHelper.getInstance
().getAccountByKey (key);
               if (account == null) {
                       logFailedLogin();
                       return new AttributeArrayResult("invalid key");
               }

              // ... do actual work
       }

Clearly, the authentication check is an aspect that screams to be
refactored away. However, the various methods have different
signatures with different numbers of arguments, and I haven't been
able to find how to write around advice that handles this. Is this
possible at all?

(in Smalltalk, I'd just do

self authenticatedWith: key do: [
    // ... do actual work
]

but using the whole anonymous inner class mess in Java just to pass a
bit of code actually makes it less readable)

If the position of the key argument is stable (known) than I guess this is all you need (it looks like it is the only parameter you need for authentication).

./alex
--
.w( the_mindstorm )p.



Back to the top