@@ -50,8 +50,7 @@ public void run(){
5050 // If all deliberation steps are finished, then check whether
5151 // the agent is done, so it can be killed.
5252 if (this .agent .isDone ()){
53- agent .getShutdownPlans ().forEach ( plan -> { try { agent .executePlan (plan ); } catch (PlanExecutionError ex ) { /*TODO?*/ } } );
54- this .platform .killAgent (this .agent .getAID ());
53+ initiateShutdown (this .agent );
5554 } else {
5655 if (!this .agent .checkSleeping ()){ // If the agents goes to sleep then it will be woken upon any external input (message, external trigger)
5756 reschedule ();
@@ -62,13 +61,28 @@ public void run(){
6261 // killed and removed from the platform. All proxy's are
6362 // notified of the agent's death. The rest of the multi-
6463 // agent system will continue execution by default.
65- this .platform .killAgent (this .agent .getAID ());
66- }
64+ Platform .getLogger ().log (getClass (), exception );
65+ this .platform .killAgent (this .agent .getAID ());
66+ }
6767 } else {
68- agent .getShutdownPlans ().forEach ( plan -> { try { agent .executePlan (plan ); } catch (PlanExecutionError ex ) { /*TODO?*/ } } );
69- this .platform .killAgent (this .agent .getAID ());
68+ initiateShutdown (agent );
7069 }
71- }
70+ }
71+
72+ /** Perform shutdown plans, and kill agent **/
73+ private void initiateShutdown (Agent agent ) {
74+ agent .getShutdownPlans ().forEach (
75+ plan -> {
76+ try {
77+ agent .executePlan (plan );
78+ } catch (PlanExecutionError ex ) {
79+ Platform .getLogger ().log (plan .getClass (), ex );
80+ /*TODO?*/
81+ }
82+ }
83+ );
84+ this .platform .killAgent (agent .getAID ());
85+ }
7286
7387 /** Returns the id of the agent to which this runnable belongs. */
7488 public final AgentID getAgentID (){ return this .agent .getAID (); }
0 commit comments