Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Removing functionality with AspectJ?

Thanks very much.
 
Actually, my description of my problem was a bit on the rubbish side. What I should have said is that CallForOfferServer  overrides the action() method in jade.core.behaviours.Behaviour, and that I do want to advise "when method action() is called from within
CallForOfferServer"
 
So sorry about that. Anyway, it seems that this works:
 

pointcut callAction( ) : call(* jade.core.behaviours.Behaviour.action ())

&&

target(apoptotic.bookTrading.BookSellerAgent$CallForOfferServer);

Thanks very much for your help

Rob

 

 

 


 

 



On 06/11/2007, Bora Erbas <bora.erbas@xxxxxxxxx> wrote:
I assume when you say "when it is called from the class
CallForOfferServer", you mean
"when object A uses an object of type CallForOfferServer to call
action() method", right?
I mean you don't mean "when method action() is called from within
CallForOfferServer"?

Anyway, if my assumption is correct then what I would do is:
pointcut callAction() : call(* jade.core.behaviours.Behaviour.action ());

And in the advice use thisJoinPoint.getTarget().getClass() or
instanceof to check against CallForOfferServer.
I am not sure if it would work but anyway give it a try..



On Nov 6, 2007 10:35 AM, Rob Austin <austirob@xxxxxxxxxxxxxx> wrote:
> Thanks very much Fintan, I'm close to getting it working, but no cigar.
>
> I think this is because the method I am targetting is inherited.
>
> I have a class called CallForOfferServer which inherits the method  action()
> from a class called Behaviour as follows:
>
> Behaviour
> ^
> SimpleBehaviour
> ^
> LifeCycle
> ^
> CallForOfferServer
>
> I am trying to advise the action() method only when it is called from the
> class CallForOfferServer, but just can't nail it.
>
> Any help would be great. This is my failing code:
>
>
> pointcut callAction() : call(* jade.core.behaviours.Behaviour.action ()) &&
> target(apoptotic.bookTrading.BookSellerAgent.CallForOfferServer );
>
>
>
>
>
>
>
> void around( ): callAction()
>
> {
>
>
>
>  \\ do something
>
> }
> Really appreciate your help
>
> Thanks
>
> Rob
>
>
>
>
>
> On 05/11/2007, Fintan Conway <Fintan.Conway@xxxxxx> wrote:
> >
> >
> > Hi Rob,
> >
> > Instead of a "before" advice, use an "around" advice.  With an around
> advice you need to call the method proceed() to run the original method.
> Thus in your advice if the security test allows the method to proceed you
> call the proceed() keyword, otherwise skip.
> >
> > Regards,
> >
> > Fintan
> >
> >
> >
> > -----Original Message-----
> > From: aspectj-users-bounces@xxxxxxxxxxx
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Rob Austin
> > Sent: 05 November 2007 11:44
> > To: aspectj-users@xxxxxxxxxxx
> > Subject: [aspectj-users] Removing functionality with AspectJ?
> >
> >
> > Hi there,
> >
> > I'm completely new to AspectJ and was wondering if there is anyway to
> cause a method to be "skipped" with AspectJ.
> >
> > Apologies if the question sounds silly, but I am using AspectJ to monitor
> what is going on in an object for security purposes.
> >
> > If certain conditions have been met, a rule engine implemented in a before
> advice determines that the code in that method should be skipped. Naturally,
> for this to be in anyway feasible, the method in question would need not to
> return anything, something like
> >
> > publicvoid action()
> >
> > I guess I need something like a  decorator pattern that removes
> functionality rather than adds it. The only way I can currently think do to
> this is to use my aspect to change the value of a boolean variable in the
> target method which causes the code to exit without doing anything.
> >
> > Really appreciate your help
> >
> > Thanks
> >
> > Rob
> >
> >
> >
> >  * ** *** ** * ** *** ** * ** *** ** *
> > This email and any files transmitted with it are confidential and
> > intended solely for the use of the individual or entity to whom they
> > are addressed.
> > Any views or opinions presented are solely those of the author, and do not
> necessarily
> > represent those of ESB.
> > If you have received this email in error please notify the sender.
> >
> > Although ESB scans e-mail and attachments for viruses, it does not
> guarantee
> > that either are virus-free and accepts no liability for any damage
> sustained
> > as a result of viruses.
> >
> > Company Registration Information: http://www.esb.ie/companies
> > * ** *** ** * ** *** ** * ** *** ** *
> >
> >
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top