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: RE: [aspectj-users] passing an extra parameter to existing method s

The reason I need to pass an extra parameter is that I'm passing it to a stateless session bean running in a different VM.  My idea was to

1) Use AspectJ to add additional methods to my session beans.

   The additional methods would take the same parameters as the exising ones and add a new parameter to carry additional data.  They would invoke the original method that they wrap and then do something with the additional data.

2) Use AspectJ to change calls to the session bean methods in client classes to pass the new parameter in addition to the existing parameters.

Step 2 seems easy.  Step 1 however seems impossible with the current implementation of AspectJ.

What I'd love is for someone to tell me that step 1 is not impossible or suggest an alternate approach that doesn't involve making the session beans stateful.

> -----Original Message-----
> From: Wes Isberg [mailto:wes@xxxxxxxxxxxxxx]
> Sent: Thursday, July 10, 2003 12:34 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] passing an extra parameter to existing
> method s
>
>
> AspectJ won't do that, but it's an interesting enough
> subcase of proxying that you might want to submit it as
> a compiler RFE in the bug database so it can be discussed
> with other 1.2 language design issues.
>
> But I'm less convinced that you want to add the methods
> as you describe, particularly since they don't seem to
> need to be visible to any clients other than the aspect.
> Might you do the same with advice in the aspect?
>
> -----
> aspect A {
>
>      pointcut someCalls(Context context) : {bind context}
>         && execution({methods});
>
>      Object around(Context context) : someCalls(context) {
>         Object result = proceed();
>         // do something with context
>      }
> }
>
> -----
>
> If you need to do things with the invoked instance, then
> surface that as well:
>
>      Object around(Context context, MyClass targ) :
>             someCalls(context) && target(targ) {
>         Object result = proceed();
>         // do something with context and targ
>      }
>
> If the "do something with ..." code differs by type
> or method, then it seems like you're back to specific
> method delegate, which could be in the aspect or declared
> in the target class.
>
> Wes
>
> Volkmann, Mark wrote:
>
> > 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.
> >
> **************************************************************
> **************
> > ********
> >
> >
> >
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
>



***********************************************************************************
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.
************************************************************************************

Back to the top