Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Again Simple Question

You can indeed use after returning advice.  Here's a generic form that
will allow you to capture return value and arguments:

after() returning(Object returnValue) : somePC() {
  Object[] args = thisJoinPoint.getArgs();
  process(args,returnValue);
}

returnValue will be null for a method with a void return type.
Primitive return types will be autoboxed.

Regards, Adrian.

On 03/03/06, Trasca Virgil <virgil_trasca@xxxxxxxxx> wrote:
>
>      Hi Adrian,
>
>         Thanks for your quick answer on my previous
> question. It worked.
>
>         I have another question. I hava a big Java API
> and I want to "catch" all method calls serialize
> method params&values at input, serialize method
> params&values at output and also serialize the
> returninc object&value of the method call. The params
> & returning value can be any type from void, int,
> double to String and also complex Class Types from my
> API.
>
>     What I had written
>
> pointcut whenMethodIsCalled(StatefullParentBean bean):
> this(bean) && execution (* *.* (..)) &&
> !within(TestAPI);
>
> pointcut topLevelCalls(StatefullParentBean
> bean):whenMethodIsCalled(bean) &&
> !cflowbelow(whenMethodIsCalled(StatefullParentBean));
>
> I have an
> before(StatefullParentBean bean): topLevelCalls(bean)
> and also
> after(StatefullParentBean bean) : topLevelCalls(bean)
>
> in which I serialize input & output params.
>
> But I want to serialize also the return value. For
> this can I use after returning in place of after?
> In after returning can I still get the values of the
> parameters which the methods have? Or I need both
> after & after returning 1 for parameters and the other
> for return value?
>     AspectJ5 knows if I put Object for the returning
> value to handle with all types of returning types no
> metter if they are void, int, double, String or a
> complex type from my API.
>
> Thanks in advance,
> Virgil
>
>
>
> --- aspectj-users-request@xxxxxxxxxxx wrote:
>
> > Send aspectj-users mailing list submissions to
> >       aspectj-users@xxxxxxxxxxx
> >
> > To subscribe or unsubscribe via the World Wide Web,
> > visit
> >
> >
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > or, via email, send a message with subject or body
> > 'help' to
> >       aspectj-users-request@xxxxxxxxxxx
> >
> > You can reach the person managing the list at
> >       aspectj-users-owner@xxxxxxxxxxx
> >
> > When replying, please edit your Subject line so it
> > is more specific
> > than "Re: Contents of aspectj-users digest..."
> >
> >
> > Today's Topics:
> >
> >    1. Re: Need to enumerate all methods for selected
> > advices of an
> >       aspect (Andy Clement)
> >    2. Re: Need to enumerate all methods for selected
> > advices       of an
> >       aspect (Wes Isberg)
> >    3. Re: [NEWSDELIVER] Getting VerifyError with
> > around        advice on
> >       static method (Matthew Webster)
> >
> >
> >
> ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Fri, 3 Mar 2006 08:12:19 +0000
> > From: "Andy Clement" <andrew.clement@xxxxxxxxx>
> > Subject: Re: [aspectj-users] Need to enumerate all
> > methods for
> >       selected        advices of an aspect
> > To: aspectj-users@xxxxxxxxxxx
> > Message-ID:
> > <689d61aa0603030012v16d0025ah@xxxxxxxxxxxxxx>
> > Content-Type: text/plain; charset="iso-8859-1"
> >
> > The new reflection support in AspectJ5 will allow
> > you to query
> > what the advice declarations are, but *not* where
> > they are
> > affecting (that may follow when we get some time...)
> >
> > It is possible to use your own message handler which
> > will
> > then get callbacks for 'weave info' messages.  To
> > see the kind
> > of information you would get, turn on weave info
> > messages
> > in the AJDT options panel or pass -showWeaveInfo to
> > the
> > compiler.  If it looks like what you want, write an
> > implementation
> > of IMessageHolder and pass the class name with
> > -messageHolder to the compiler ... I think that will
> > work, although
> > I've not tried it !!
> >
> > Andy.
> >
> >
> > On 03/03/06, András Imre <andras.imre@xxxxxxxxx>
> > wrote:
> > >
> > > Hi,
> > >
> > > I have an aspect, which checks access permissions
> > before
> > > allowing execution of certain methods for the
> > current user.
> > > This is done with around advice.
> > >
> > > Now I'd like generate a file, in which each
> > affected method
> > > is listed for this aspect. In this way I'd have an
> > automated
> > > way to get an always up-to-date template which
> > could be
> > > used for creating an access permission
> > configuration file.
> > >
> > > I see this info e.g. on the Cross References tab
> > in Eclipse,
> > > and as AspectJ markers, but cant export from
> > either, and
> > > would not be automatic.
> > > Is there a way to generate this automatically,
> > preferably in
> > > similar format and structure to the
> > thisJoinPoint.toString()
> > > variations?
> > >
> > > I tried messing with reflection, but could not
> > access
> > > aspects this way... Can aspects be investigated
> > runtime?
> > >
> > >
> > > Thanks,
> > >   András
> > > _______________________________________________
> > > aspectj-users mailing list
> > > aspectj-users@xxxxxxxxxxx
> > >
> >
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > >
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL:
> >
> http://eclipse.org/pipermail/aspectj-users/attachments/20060303/729a0f84/attachment.html
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Fri, 3 Mar 2006 00:43:38 -0800
> > From: "Wes Isberg" <wes@xxxxxxxxxxxxxx>
> > Subject: Re: [aspectj-users] Need to enumerate all
> > methods for
> >       selected advices        of an aspect
> > To: aspectj-users@xxxxxxxxxxx
> > Message-ID:
> > <20060303004338.1250926427.wes@xxxxxxxxxxxxxx>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Another option is to post-process declare warning
> > messages.  Given
> >
> >   aspect A {
> >       declare warning: Permissions.access() :
> > "Access";
> >   }
> >
> > ajc will emit messages of the form
> > ------------
> > C:\src\C.java:44 [warning] Access
> > class C { void m(){} }
> > ^^^^^^^^^^^^^^^^^^^^^
> >         method-execution(void M.m())
> >         see also: C:\src\A.java:22::0
> > ------------
> >
> > Capture the messages from the command-line or by
> > installing a
> > message handler (using iajc/Ant or the very new
> > undocumented
> > ajc flag -messageHolder) and munge them to produce a
> > config file.
> >
> > Not pretty!
> >
> > Wes
> >
> > ------------Original Message------------
> > From: "Andy Clement" <andrew.clement@xxxxxxxxx>
> > To: aspectj-users@xxxxxxxxxxx
> > Date: Fri, Mar-3-2006 0:11 AM
> > Subject: Re: [aspectj-users] Need to enumerate all
> > methods for selected advices of an aspect
> > The new reflection support in AspectJ5 will allow
> > you to query
> > what the advice declarations are, but *not* where
> > they are
> > affecting (that may follow when we get some time...)
> >
> > It is possible to use your own message handler which
> > will
> > then get callbacks for 'weave info' messages.  To
> > see the kind
> > of information you would get, turn on weave info
> > messages
> > in the AJDT options panel or pass -showWeaveInfo to
> > the
> > compiler.  If it looks like what you want, write an
> > implementation
> > of IMessageHolder and pass the class name with
> > -messageHolder to the compiler ... I think that will
> > work, although
> > I've not tried it !!
> >
> > Andy.
> >
> >
> >
> > On 03/03/06, András Imre <andras.imre@xxxxxxxxx>
> > wrote:
> > Hi,
> >
> > I have an aspect, which checks access permissions
> > before
> > allowing execution of certain methods for the
> > current user.
> > This is done with around advice.
> >
> >
> === message truncated ===
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


--
-- Adrian
adrian.colyer@xxxxxxxxx


Back to the top