0

i am working with JADE in Eclipse. i tried to capture the action method for each executed behaviour using an aspect. it works so well, i even got the instance of the executed behaviour. however this instance doesn't allow me to get the Agent which added this behaviour. because in http://jade.tilab.com/doc/api/jade/core/behaviours/Behaviour.html Behaviour allows us to know which Agent added this behaviour. the following pic shows my error

enter image description here

thanks.

Mike Causer
  • 8,196
  • 2
  • 43
  • 63
steevn
  • 242
  • 2
  • 8
  • 2
    No, the pic does *not* show the error, just the place in the code where it seems to occur. Would you mind updating the question by actually quoting the exact error message? Probably it already explains what the compiler complains about. – kriegaex Apr 07 '15 at 20:37

1 Answers1

0

Thanks for not updating the question, not posting the actual error message and even hiding your class's imports from your readers' view. :-7

Anyway: The code you posted should work, for me it does in Eclipse without any red underlinings. Here are two variants for your pointcut and advice, on like yours with an ugly cast and usage of getThis() and one more elegant by direct and type-safe parameter binding:

package de.scrum_master.aspect;

import jade.core.behaviours.Behaviour;

public aspect ActionAspect {
    before() :
        execution(* Behaviour.action(..))
    {
        System.out.println(thisJoinPoint);
        Behaviour behaviour = (Behaviour) thisJoinPoint.getThis();
        behaviour.getAgent();
    }

    before(Behaviour behaviour) :
        execution(* Behaviour.action(..)) && this(behaviour)
    {
        System.out.println(thisJoinPoint);
        behaviour.getAgent();
    }
}
kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • but still, even with your code, i am getting red underlinings what is your jade version please ?! i have an assumption that the version is the source of my problem – steevn Apr 12 '15 at 18:07
  • *You* are asking *me* for details and you are too lazy to provide any?! Come on! After you, Sir. I am waiting. – kriegaex Apr 12 '15 at 19:25
  • yes i was right i found the problem , the jade v4.3.3 is offering getAgent() in the Behaviour calss thanks so much sir but now i am facing another problem i will edit the question – steevn Apr 13 '15 at 13:30
  • So you opened a question here because you tried to call a non-existent method. Okay, no further comments on that. I kindly suggest to accept my answer and not to edit the question (you have not done so in 4 hours now anyway) because the follow-up problem would probably unrelated. – kriegaex Apr 13 '15 at 18:15