Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] passing an extra parameter to existing method s

Title: Message
Mark,
 
I was also looking into something where pattern-based method introduction would be usefull. I was trying to code an aspect that would enhance the methods of Collection to make every Collection synchronized. Could be usefull if you suddently find your components running in multiple threads and you don't want to change all your Collections to Vector or Hashtable because the same components are being used in another application that is not multi-threaded.
 
Rudi.
-----Original Message-----
From: Volkmann, Mark [mailto:Mark.Volkmann@xxxxxxxxxxxxx]
Sent: donderdag 10 juli 2003 15:46
To: 'aspectj-users@xxxxxxxxxxx'
Subject: RE: [aspectj-users] passing an extra parameter to existing method s

I think what I want is a pattern-based form of method introduction ... unless there is another approach that would provide this same thing.
-----Original Message-----
From: Volkmann, Mark
Sent: Wednesday, July 09, 2003 2:11 PM
To: 'aspectj-users@xxxxxxxxxxx'
Subject: [aspectj-users] passing an extra parameter to existing methods

Is there a way I could do the following with AspectJ?

I want to add methods to several classes that wrap existing methods and add an additional parameter.
Then I want to use around advice to make calls to the original methods go to the new methods and add the new parameter.

For example, the deposit method in my Account class looks like this.

public void deposit(double amount) {
    balance += amount;
}

I want to add the following.

public void deposit(Context context, double amount) {
    deposit(amount);
    // Do something with the context parameter here.
}

Then all calls to the original deposit method should go to the new one.

I know how to do this for individual methods, but I'm looking for a way to do this to many methods in the Account class without having to write the code for each of them in my aspect.



***********************************************************************************
WARNING: All e-mail sent to and from this address will be received or
otherwise recorded by the A.G. Edwards corporate e-mail system and is
subject to archival, monitoring or review by, and/or disclosure to,
someone other than the recipient.
************************************************************************************

This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.



This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.



Back to the top