bdi4jade

Plan body refactoring

4/7/2014 1:47:07 PM

Changes

bdi-jade/lib/log4j-api-2.0-rc1.jar 0(+0 -0)

bdi-jade/lib/log4j-core-2.0-rc1.jar 0(+0 -0)

bdi-jade/src/bdi4jade/plan/PlanInstance.java 342(+0 -342)

Details

diff --git a/bdi-jade/.classpath b/bdi-jade/.classpath
index cfaaa3e..f6d474c 100644
--- a/bdi-jade/.classpath
+++ b/bdi-jade/.classpath
@@ -5,7 +5,6 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
 	<classpathentry kind="lib" path="lib/jade-4.3.2.jar"/>
 	<classpathentry kind="lib" path="lib/commons-logging-1.1.3.jar"/>
-	<classpathentry kind="lib" path="lib/log4j-api-2.0-rc1.jar"/>
-	<classpathentry kind="lib" path="lib/log4j-core-2.0-rc1.jar"/>
+	<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/bdi-jade/lib/log4j-1.2.17.jar b/bdi-jade/lib/log4j-1.2.17.jar
new file mode 100644
index 0000000..068867e
Binary files /dev/null and b/bdi-jade/lib/log4j-1.2.17.jar differ
diff --git a/bdi-jade/src/bdi4jade/core/Intention.java b/bdi-jade/src/bdi4jade/core/Intention.java
index 78dd463..2346610 100644
--- a/bdi-jade/src/bdi4jade/core/Intention.java
+++ b/bdi-jade/src/bdi4jade/core/Intention.java
@@ -37,8 +37,8 @@ import bdi4jade.exception.PlanInstantiationException;
 import bdi4jade.goal.Goal;
 import bdi4jade.goal.GoalStatus;
 import bdi4jade.plan.Plan;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
+import bdi4jade.plan.Plan.EndState;
+import bdi4jade.plan.PlanBodyInterface;
 
 /**
  * This class represents the intention abstraction from the BDI model. It
@@ -54,7 +54,7 @@ import bdi4jade.plan.PlanInstance.EndState;
  */
 public class Intention {
 
-	private PlanInstance currentPlan;
+	private PlanBodyInterface currentPlan;
 	private final Set<Plan> executedPlans;
 	private final Goal goal;
 	private final List<GoalListener> goalListeners;
@@ -129,7 +129,8 @@ public class Intention {
 			Plan selectedPlan = myAgent.getPlanSelectionStrategy().selectPlan(
 					goal, options);
 			try {
-				this.currentPlan = new PlanInstance(selectedPlan, this);
+				this.currentPlan = selectedPlan.createPlanBody();
+				currentPlan.init(selectedPlan, this);
 			} catch (PlanInstantiationException e) {
 				log.error("Plan " + selectedPlan.getId()
 						+ " could not be instantiated.");
@@ -142,7 +143,7 @@ public class Intention {
 		if (options.isEmpty()) {
 			this.unachievable = true;
 		} else {
-			this.currentPlan.startPlan();
+			this.currentPlan.start();
 		}
 	}
 
@@ -158,7 +159,7 @@ public class Intention {
 			break;
 		case TRYING_TO_ACHIEVE:
 			this.waiting = true;
-			this.currentPlan.stopPlan();
+			this.currentPlan.stop();
 			this.currentPlan = null;
 			break;
 		case PLAN_FAILED:
@@ -284,7 +285,7 @@ public class Intention {
 			break;
 		case TRYING_TO_ACHIEVE:
 			this.noLongerDesired = true;
-			this.currentPlan.stopPlan();
+			this.currentPlan.stop();
 			this.currentPlan = null;
 			break;
 		case PLAN_FAILED:
diff --git a/bdi-jade/src/bdi4jade/exception/PlanInstantiationException.java b/bdi-jade/src/bdi4jade/exception/PlanInstantiationException.java
index b7342c4..b798e24 100644
--- a/bdi-jade/src/bdi4jade/exception/PlanInstantiationException.java
+++ b/bdi-jade/src/bdi4jade/exception/PlanInstantiationException.java
@@ -22,11 +22,11 @@
 
 package bdi4jade.exception;
 
-import bdi4jade.plan.PlanBody;
+import bdi4jade.plan.PlanBodyInterface;
 
 /**
  * This method represents an exception that occurred during the instantiation
- * process of a {@link PlanBody}.
+ * process of a {@link PlanBodyInterface}.
  * 
  * @author ingrid
  */
diff --git a/bdi-jade/src/bdi4jade/plan/DisposablePlanBody.java b/bdi-jade/src/bdi4jade/plan/DisposablePlanBody.java
index b3e8754..070d2a3 100644
--- a/bdi-jade/src/bdi4jade/plan/DisposablePlanBody.java
+++ b/bdi-jade/src/bdi4jade/plan/DisposablePlanBody.java
@@ -25,7 +25,7 @@ package bdi4jade.plan;
 import bdi4jade.core.Intention;
 
 /**
- * This interface indicates that a {@link PlanBody} should be finalized in case
+ * This interface indicates that a {@link PlanBodyInterface} should be finalized in case
  * of being terminated.
  * 
  * @author ingrid *
diff --git a/bdi-jade/src/bdi4jade/plan/OutputPlanBody.java b/bdi-jade/src/bdi4jade/plan/OutputPlanBody.java
index f626ce7..afc9a3c 100644
--- a/bdi-jade/src/bdi4jade/plan/OutputPlanBody.java
+++ b/bdi-jade/src/bdi4jade/plan/OutputPlanBody.java
@@ -25,7 +25,7 @@ package bdi4jade.plan;
 import bdi4jade.goal.Goal;
 
 /**
- * This interface defines that a {@link PlanBody} provides output for a goal
+ * This interface defines that a {@link PlanBodyInterface} provides output for a goal
  * that is being achieved. These outputs that are properties of the goal may be
  * set during the plan body execution, but this interface defines a method for
  * excplicit performing this taks of setting outpust.
diff --git a/bdi-jade/src/bdi4jade/plan/Plan.java b/bdi-jade/src/bdi4jade/plan/Plan.java
index b57cea1..811310f 100644
--- a/bdi-jade/src/bdi4jade/plan/Plan.java
+++ b/bdi-jade/src/bdi4jade/plan/Plan.java
@@ -36,6 +36,8 @@ import bdi4jade.core.PlanLibrary;
 import bdi4jade.exception.PlanInstantiationException;
 import bdi4jade.goal.Goal;
 import bdi4jade.message.MessageGoal;
+import bdi4jade.softgoal.PlanContribution;
+import bdi4jade.softgoal.PlanGoalDependency;
 import bdi4jade.softgoal.Softgoal;
 import bdi4jade.util.MetadataElementImpl;
 
@@ -53,6 +55,15 @@ public abstract class Plan extends MetadataElementImpl {
 
 	}
 
+	/**
+	 * This enumuration represents the possible end states of a plan execution.
+	 * 
+	 * @author ingrid
+	 */
+	public enum EndState {
+		FAILED, SUCCESSFUL;
+	}
+
 	private final Set<Class<? extends Goal>> goals;
 	protected final String id;
 	private final Set<MessageTemplate> messageTemplates;
@@ -194,14 +205,14 @@ public abstract class Plan extends MetadataElementImpl {
 	}
 
 	/**
-	 * Instantiate the plan body of this plan. It must be an instance of
-	 * {@link Behaviour} and also implements the {@link PlanBody} interface.
+	 * Instantiate the plan body of this plan. It must implement the
+	 * {@link PlanBodyInterface} interface.
 	 * 
 	 * @return the instantiated plan body.
 	 * @throws PlanInstantiationException
 	 *             if an error occurred during the instantiation process.
 	 */
-	public abstract Behaviour createPlanBody()
+	public abstract PlanBodyInterface createPlanBody()
 			throws PlanInstantiationException;
 
 	/**
diff --git a/bdi-jade/src/bdi4jade/plan/PlanBody.java b/bdi-jade/src/bdi4jade/plan/PlanBody.java
index cec7790..ae4ba5a 100644
--- a/bdi-jade/src/bdi4jade/plan/PlanBody.java
+++ b/bdi-jade/src/bdi4jade/plan/PlanBody.java
@@ -23,31 +23,330 @@
 package bdi4jade.plan;
 
 import jade.core.behaviours.Behaviour;
-import bdi4jade.plan.PlanInstance.EndState;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import bdi4jade.core.BeliefBase;
+import bdi4jade.core.Intention;
+import bdi4jade.event.GoalEvent;
+import bdi4jade.event.GoalFinishedEvent;
+import bdi4jade.exception.PlanInstantiationException;
+import bdi4jade.goal.Goal;
+import bdi4jade.plan.Plan.EndState;
 
 /**
- * This interface defines a PlanBody. Plans are executed as behaviors (
- * {@link Behaviour}), but executed in the BDI context, these behaviors should
- * also implement this interface.
+ * This class represents a plan that has been instantiated to be executed.
  * 
  * @author ingrid
  */
-public interface PlanBody {
+public abstract class PlanBody extends Behaviour implements PlanBodyInterface {
+
+	private static final long serialVersionUID = -6488256636028800227L;
+
+	private EndState endState;
+	private final List<GoalFinishedEvent> goalEventQueue;
+	private Intention intention;
+	private Plan plan;
+	private final List<Goal> subgoals;
+
+	/**
+	 * Creates a new plan body instance.
+	 */
+	public PlanBody() {
+		this.plan = null;
+		this.intention = null;
+		this.endState = null;
+		this.subgoals = new ArrayList<Goal>();
+		this.goalEventQueue = new LinkedList<GoalFinishedEvent>();
+	}
+
+	/**
+	 * Dispatches a goal to be achieved.
+	 * 
+	 * @param goal
+	 *            the goal to be dispatched.
+	 */
+	public void dispatchGoal(Goal goal) {
+		this.intention.getMyAgent().addGoal(goal);
+	}
+
+	/**
+	 * Dispatches a goal to be achieved, using the capability (or its children
+	 * capabilities) associated with the plan.
+	 * 
+	 * @param goal
+	 *            the goal to be dispatched.
+	 */
+	public void dispatchProtectedGoal(Goal goal) {
+		this.intention.getMyAgent().addGoal(
+				this.plan.getPlanLibrary().getCapability(), goal);
+	}
+
+	/**
+	 * Dispatches a subgoal to be achieved, using the capability (or its
+	 * children capabilities) associated with the plan.
+	 * 
+	 * @param subgoal
+	 *            the subgoal to be dispatched.
+	 */
+	public void dispatchProtectedSubgoal(Goal subgoal) {
+		this.intention.getMyAgent().addGoal(
+				this.plan.getPlanLibrary().getCapability(), subgoal);
+		synchronized (subgoals) {
+			this.subgoals.add(subgoal);
+		}
+	}
 
 	/**
-	 * Returns the end state of the execution of this plan.
+	 * Dispatches a subgoal to be achieved, using the capability (or its
+	 * children capabilities) associated with the plan, and registers itself as
+	 * a listener to receive a notification of the end of execution of the goal.
 	 * 
-	 * @return the end state of this plan, or null if it has not finished yet.
+	 * @param subgoal
+	 *            the subgoal to be dispatched.
 	 */
-	public EndState getEndState();
+	public void dispatchProtectedSubgoalAndListen(Goal subgoal) {
+		this.intention.getMyAgent().addGoal(
+				this.plan.getPlanLibrary().getCapability(), subgoal, this);
+		synchronized (subgoals) {
+			this.subgoals.add(subgoal);
+		}
+	}
 
 	/**
-	 * Initializes the PlanBody. It is invoked just after its instantiation.
+	 * Dispatches a subgoal to be achieved.
 	 * 
-	 * @param planInstance
-	 *            the plan instance that contains contextual information for
-	 *            this plan body.
+	 * @param subgoal
+	 *            the subgoal to be dispatched.
+	 */
+	public void dispatchSubgoal(Goal subgoal) {
+		this.intention.getMyAgent().addGoal(subgoal);
+		synchronized (subgoals) {
+			this.subgoals.add(subgoal);
+		}
+	}
+
+	/**
+	 * Dispatches a subgoal to be achieved and registers itself as a listener to
+	 * receive a notification of the end of execution of the goal.
+	 * 
+	 * @param subgoal
+	 *            the subgoal to be dispatched.
+	 */
+	public void dispatchSubgoalAndListen(Goal subgoal) {
+		this.intention.getMyAgent().addGoal(subgoal, this);
+		synchronized (subgoals) {
+			this.subgoals.add(subgoal);
+		}
+	}
+
+	@Override
+	public final boolean done() {
+		synchronized (plan) {
+			return getEndState() != null;
+		}
+	}
+
+	/**
+	 * Drops all current subgoals dispatched by this plan.
+	 */
+	private void dropSubgoals() {
+		synchronized (subgoals) {
+			Iterator<Goal> it = subgoals.iterator();
+			while (it.hasNext()) {
+				Goal subgoal = it.next();
+				this.intention.getMyAgent().setNoLongerDesired(subgoal);
+				it.remove();
+			}
+		}
+	}
+
+	/**
+	 * Returns the belief base of the capability.
+	 * 
+	 * @return the belief base containing the beliefs.
+	 */
+	public BeliefBase getBeliefBase() {
+		return this.plan.getPlanLibrary().getCapability().getBeliefBase();
+	}
+
+	/**
+	 * Returns the end state of plan. A null value means that the plan is still
+	 * in execution. If the plan body has come to an end state, it invokes the
+	 * method to set the output parameters of the goal, in case the plan body
+	 * implements the {@link OutputPlanBody} interface (this is invoked only
+	 * once). If the plan body has come to an end state, it sets all of its
+	 * subgoals as no longer desired, in case they are still trying to be
+	 * achieved.
+	 * 
+	 * @return the end state of the plan.
+	 */
+	public EndState getEndState() {
+		synchronized (plan) {
+			return endState;
+		}
+	}
+
+	/**
+	 * Returns the goal to be achieved by this plan instance.
+	 * 
+	 * @return the goal.
+	 */
+	public Goal getGoal() {
+		return this.intention.getGoal();
+	}
+
+	/**
+	 * Returns a goal event from the queue. If the queue is empty, the behavior
+	 * associated with this plan instance is blocked.
+	 * 
+	 * @return the goal event or null if the queue is empty.
+	 */
+	public GoalFinishedEvent getGoalEvent() {
+		return getGoalEvent(true, -1);
+	}
+
+	/**
+	 * Returns a goal event from the queue. If the queue is empty, the behavior
+	 * associated with this plan instance is going to be blocked if the
+	 * parameter passed to this method is true.
+	 * 
+	 * @param block
+	 *            true if the behavior must be blocked if the queue is empty.
+	 * @return the goal event or null if the queue is empty.
+	 */
+	public GoalFinishedEvent getGoalEvent(boolean block) {
+		return getGoalEvent(block, -1);
+	}
+
+	/**
+	 * Returns a goal event from the queue. If the block parameter is true, the
+	 * behavior associated with this plan instance is going to be blocked if the
+	 * queue is empty according to the specified milliseconds. specified
+	 * milliseconds. If the time is lower then zero, the behavior is going to be
+	 * blocked until an event happens ({@link Behaviour#block()}).
+	 * 
+	 * @param block
+	 *            true if the behavior must be blocked if the queue is empty.
+	 * @param ms
+	 *            the maximum amount of time that the behavior must be blocked.
+	 * @return the goal event or null if the queue is empty.
+	 */
+	private GoalFinishedEvent getGoalEvent(boolean block, long ms) {
+		synchronized (goalEventQueue) {
+			if (!this.goalEventQueue.isEmpty()) {
+				return this.goalEventQueue.remove(0);
+			} else {
+				if (block) {
+					if (ms < 0) {
+						block();
+					} else {
+						block(ms);
+					}
+				}
+				return null;
+			}
+		}
+	}
+
+	/**
+	 * Returns a goal event from the queue. If the queue is empty, the behavior
+	 * associated with this plan instance is going to be blocked for the
+	 * specified milliseconds.
+	 * 
+	 * @param ms
+	 *            the maximum amount of time that the behavior must be blocked.
+	 * @return the goal event or null if the queue is empty.
+	 */
+	public GoalFinishedEvent getGoalEvent(long ms) {
+		return getGoalEvent(true, ms);
+	}
+
+	/**
+	 * Returns the {@link Plan} that is associated with this plan instance.
+	 * 
+	 * @return the plan.
+	 */
+	public Plan getPlan() {
+		return plan;
+	}
+
+	/**
+	 * @see bdi4jade.event.GoalListener#goalPerformed(bdi4jade.event.GoalEvent)
+	 */
+	@Override
+	public synchronized void goalPerformed(GoalEvent event) {
+		if (event instanceof GoalFinishedEvent) {
+			synchronized (goalEventQueue) {
+				this.goalEventQueue.add((GoalFinishedEvent) event);
+				restart();
+			}
+			synchronized (subgoals) {
+				this.subgoals.remove(event.getGoal());
+			}
+		}
+	}
+
+	/**
+	 * Initializes this plan body. It associates this plan body with a plan
+	 * definition ({@link Plan}) and an {@link Intention}. If this plan body has
+	 * already been initialized, this method throws a
+	 * {@link PlanInstantiationException}.
+	 * 
+	 * @param plan
+	 *            the plan associated this this plan body.
+	 * @param intention
+	 *            the intention that this plan instance have to achieve.
+	 * @throws PlanBodyInstantiationException
+	 *             if this plan body has already been initialized.
+	 */
+	public void init(Plan plan, Intention intention)
+			throws PlanInstantiationException {
+		if (this.plan != null || this.intention != null) {
+			throw new PlanInstantiationException(
+					"This plan body has already been initialized.");
+		}
+		this.plan = plan;
+		this.intention = intention;
+	}
+
+	/**
+	 * @param endState
+	 *            the endState to set
+	 */
+	protected void setEndState(EndState endState) {
+		synchronized (plan) {
+			this.endState = endState;
+			if (this.endState != null) {
+				if (this instanceof OutputPlanBody) {
+					((OutputPlanBody) this).setGoalOutput(getGoal());
+				}
+				dropSubgoals();
+			}
+		}
+	}
+
+	/**
+	 * Starts the plan body, a {@link Behaviour}, associated with this plan.
+	 */
+	public void start() {
+		this.intention.getMyAgent().addBehaviour(this);
+	}
+
+	/**
+	 * Stops the plan body, a {@link Behaviour}, associated with this plan. If
+	 * the body implements the {@link DisposablePlanBody}, it invokes the method
+	 * to about the plan body, so it can perform finalizations.
 	 */
-	public void init(PlanInstance planInstance);
+	public void stop() {
+		dropSubgoals();
+		this.intention.getMyAgent().removeBehaviour(this);
+		if (this instanceof DisposablePlanBody) {
+			((DisposablePlanBody) this).onAbort();
+		}
+	}
 
 }
diff --git a/bdi-jade/src/bdi4jade/plan/PlanBodyInterface.java b/bdi-jade/src/bdi4jade/plan/PlanBodyInterface.java
new file mode 100644
index 0000000..23f246b
--- /dev/null
+++ b/bdi-jade/src/bdi4jade/plan/PlanBodyInterface.java
@@ -0,0 +1,182 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011  Ingrid Nunes
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+// 
+// To contact the authors:
+// http://inf.ufrgs.br/~ingridnunes/bdi4jade/
+//
+//----------------------------------------------------------------------------
+
+package bdi4jade.plan;
+
+import jade.core.behaviours.Behaviour;
+import bdi4jade.core.BeliefBase;
+import bdi4jade.core.Intention;
+import bdi4jade.event.GoalFinishedEvent;
+import bdi4jade.event.GoalListener;
+import bdi4jade.exception.PlanInstantiationException;
+import bdi4jade.goal.Goal;
+import bdi4jade.plan.Plan.EndState;
+
+/**
+ * This interface defines a PlanBody. Plans are executed as behaviors (
+ * {@link Behaviour}), but executed in the BDI context, these behaviors should
+ * also implement this interface.
+ * 
+ * @author ingrid
+ */
+public interface PlanBodyInterface extends GoalListener {
+
+	/**
+	 * Dispatches a goal to be achieved.
+	 * 
+	 * @param goal
+	 *            the goal to be dispatched.
+	 */
+	public void dispatchGoal(Goal goal);
+
+	/**
+	 * Dispatches a goal to be achieved, using the capability (or its children
+	 * capabilities) associated with the plan.
+	 * 
+	 * @param goal
+	 *            the goal to be dispatched.
+	 */
+	public void dispatchProtectedGoal(Goal goal);
+
+	/**
+	 * Dispatches a subgoal to be achieved, using the capability (or its
+	 * children capabilities) associated with the plan.
+	 * 
+	 * @param subgoal
+	 *            the subgoal to be dispatched.
+	 */
+	public void dispatchProtectedSubgoal(Goal subgoal);
+
+	/**
+	 * Dispatches a subgoal to be achieved, using the capability (or its
+	 * children capabilities) associated with the plan, and registers itself as
+	 * a listener to receive a notification of the end of execution of the goal.
+	 * 
+	 * @param subgoal
+	 *            the subgoal to be dispatched.
+	 */
+	public void dispatchProtectedSubgoalAndListen(Goal subgoal);
+
+	/**
+	 * Dispatches a subgoal to be achieved.
+	 * 
+	 * @param subgoal
+	 *            the subgoal to be dispatched.
+	 */
+	public void dispatchSubgoal(Goal subgoal);
+
+	/**
+	 * Dispatches a subgoal to be achieved and registers itself as a listener to
+	 * receive a notification of the end of execution of the goal.
+	 * 
+	 * @param subgoal
+	 *            the subgoal to be dispatched.
+	 */
+	public void dispatchSubgoalAndListen(Goal subgoal);
+
+	/**
+	 * Returns the belief base of the capability.
+	 * 
+	 * @return the belief base containing the beliefs.
+	 */
+	public BeliefBase getBeliefBase();
+
+	/**
+	 * Returns the end state of the execution of this plan.
+	 * 
+	 * @return the end state of this plan, or null if it has not finished yet.
+	 */
+	public EndState getEndState();
+
+	/**
+	 * Returns the goal to be achieved by this plan instance.
+	 * 
+	 * @return the goal.
+	 */
+	public Goal getGoal();
+
+	/**
+	 * Returns a goal event from the queue. If the queue is empty, the behavior
+	 * associated with this plan instance is blocked.
+	 * 
+	 * @return the goal event or null if the queue is empty.
+	 */
+	public GoalFinishedEvent getGoalEvent();
+
+	/**
+	 * Returns a goal event from the queue. If the queue is empty, the behavior
+	 * associated with this plan instance is going to be blocked if the
+	 * parameter passed to this method is true.
+	 * 
+	 * @param block
+	 *            true if the behavior must be blocked if the queue is empty.
+	 * @return the goal event or null if the queue is empty.
+	 */
+	public GoalFinishedEvent getGoalEvent(boolean block);
+
+	/**
+	 * Returns a goal event from the queue. If the queue is empty, the behavior
+	 * associated with this plan instance is going to be blocked for the
+	 * specified milliseconds.
+	 * 
+	 * @param ms
+	 *            the maximum amount of time that the behavior must be blocked.
+	 * @return the goal event or null if the queue is empty.
+	 */
+	public GoalFinishedEvent getGoalEvent(long ms);
+
+	/**
+	 * Returns the {@link Plan} that is associated with this plan instance.
+	 * 
+	 * @return the plan.
+	 */
+	public Plan getPlan();
+
+	/**
+	 * Initializes this plan body. It associates this plan body with a plan
+	 * definition ({@link Plan}) and an {@link Intention}. If this plan body has
+	 * already been initialized, this method throws a
+	 * {@link PlanInstantiationException}.
+	 * 
+	 * @param plan
+	 *            the plan associated this this plan body.
+	 * @param intention
+	 *            the intention that this plan instance have to achieve.
+	 * @throws PlanBodyInstantiationException
+	 *             if this plan body has already been initialized.
+	 */
+	public void init(Plan plan, Intention intention)
+			throws PlanInstantiationException;
+
+	/**
+	 * Starts the plan body, a {@link Behaviour}, associated with this plan.
+	 */
+	public void start();
+
+	/**
+	 * Stops the plan body, a {@link Behaviour}, associated with this plan. If
+	 * the body implements the {@link DisposablePlanBody}, it invokes the method
+	 * to about the plan body, so it can perform finalizations.
+	 */
+	public void stop();
+
+}
diff --git a/bdi-jade/src/bdi4jade/util/plan/ParallelGoalPlanBody.java b/bdi-jade/src/bdi4jade/util/plan/ParallelGoalPlanBody.java
index c8e821f..3120b1a 100644
--- a/bdi-jade/src/bdi4jade/util/plan/ParallelGoalPlanBody.java
+++ b/bdi-jade/src/bdi4jade/util/plan/ParallelGoalPlanBody.java
@@ -22,8 +22,6 @@
 
 package bdi4jade.util.plan;
 
-import jade.core.behaviours.Behaviour;
-
 import java.util.ArrayList;
 import java.util.List;
 
@@ -34,17 +32,15 @@ import bdi4jade.event.GoalFinishedEvent;
 import bdi4jade.goal.Goal;
 import bdi4jade.goal.GoalStatus;
 import bdi4jade.plan.OutputPlanBody;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 import bdi4jade.util.goal.ParallelGoal;
 
 /**
  * @author ingrid
  * 
  */
-public class ParallelGoalPlanBody extends Behaviour implements PlanBody,
-		OutputPlanBody {
+public class ParallelGoalPlanBody extends PlanBody implements OutputPlanBody {
 
 	private static final long serialVersionUID = -5919677537834351951L;
 
@@ -53,8 +49,6 @@ public class ParallelGoalPlanBody extends Behaviour implements PlanBody,
 	protected GoalFinishedEvent failedGoal;
 	protected Log log;
 	protected ParallelGoal parallelGoal;
-	protected PlanInstance planInstance;
-	protected Boolean success;
 
 	/**
 	 * Created a new ParallelGoalPlan.
@@ -69,7 +63,7 @@ public class ParallelGoalPlanBody extends Behaviour implements PlanBody,
 	@Override
 	public void action() {
 		if (this.dispatched) {
-			GoalFinishedEvent goalEvent = planInstance.getGoalEvent();
+			GoalFinishedEvent goalEvent = getGoalEvent();
 			if (goalEvent == null) {
 				return;
 			} else {
@@ -77,18 +71,18 @@ public class ParallelGoalPlanBody extends Behaviour implements PlanBody,
 					this.completedGoals.add(goalEvent.getGoal());
 					log.debug("Goal " + goalEvent.getGoal() + " completed!");
 					if (completedGoals.size() == parallelGoal.getGoals().size()) {
-						this.success = Boolean.TRUE;
+						setEndState(EndState.SUCCESSFUL);
 						log.debug("All goals completed.");
 					}
 				} else {
 					this.failedGoal = goalEvent;
-					this.success = Boolean.FALSE;
+					setEndState(EndState.FAILED);
 					log.debug("A goal has failed: " + goalEvent.getGoal());
 				}
 			}
 		} else {
 			for (Goal goal : parallelGoal.getGoals()) {
-				planInstance.dispatchSubgoalAndListen(goal);
+				dispatchSubgoalAndListen(goal);
 			}
 			this.dispatched = true;
 			log.debug("Goals dispatched!");
@@ -96,39 +90,14 @@ public class ParallelGoalPlanBody extends Behaviour implements PlanBody,
 	}
 
 	/**
-	 * @see jade.core.behaviours.Behaviour#done()
-	 */
-	@Override
-	public boolean done() {
-		return (this.success != null);
-	}
-
-	/**
-	 * @see bdi4jade.plan.PlanBody#getEndState()
-	 */
-	@Override
-	public EndState getEndState() {
-		if (this.success == null) {
-			return null;
-		} else {
-			return this.success ? EndState.SUCCESSFUL : EndState.FAILED;
-		}
-	}
-
-	/**
 	 * Initializes this plan.
-	 * 
-	 * @param planInstance
-	 *            the plan instance associated with this plan.
 	 */
 	@Override
-	public void init(PlanInstance planInstance) {
-		this.planInstance = planInstance;
-		this.parallelGoal = (ParallelGoal) planInstance.getGoal();
+	public void onStart() {
+		this.parallelGoal = (ParallelGoal) getGoal();
 		this.completedGoals = new ArrayList<Goal>(parallelGoal.getGoals()
 				.size());
 		this.failedGoal = null;
-		this.success = null;
 		this.dispatched = false;
 	}
 
diff --git a/bdi-jade/src/bdi4jade/util/plan/SequentialGoalPlanBody.java b/bdi-jade/src/bdi4jade/util/plan/SequentialGoalPlanBody.java
index 25bb0a9..e2f1bda 100644
--- a/bdi-jade/src/bdi4jade/util/plan/SequentialGoalPlanBody.java
+++ b/bdi-jade/src/bdi4jade/util/plan/SequentialGoalPlanBody.java
@@ -22,8 +22,6 @@
 
 package bdi4jade.util.plan;
 
-import jade.core.behaviours.Behaviour;
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -35,9 +33,8 @@ import bdi4jade.event.GoalFinishedEvent;
 import bdi4jade.goal.Goal;
 import bdi4jade.goal.GoalStatus;
 import bdi4jade.plan.OutputPlanBody;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 import bdi4jade.util.goal.SequentialGoal;
 
 /**
@@ -45,8 +42,7 @@ import bdi4jade.util.goal.SequentialGoal;
  * 
  * @author ingrid
  */
-public class SequentialGoalPlanBody extends Behaviour implements PlanBody,
-		OutputPlanBody {
+public class SequentialGoalPlanBody extends PlanBody implements OutputPlanBody {
 
 	private static final long serialVersionUID = -5919677537834351951L;
 
@@ -55,8 +51,6 @@ public class SequentialGoalPlanBody extends Behaviour implements PlanBody,
 	protected GoalFinishedEvent failedGoal;
 	protected Iterator<Goal> it;
 	protected Log log;
-	protected PlanInstance planInstance;
-	protected Boolean success;
 
 	/**
 	 * Created a new SequentialGoalPlan.
@@ -72,7 +66,7 @@ public class SequentialGoalPlanBody extends Behaviour implements PlanBody,
 	public void action() {
 		if (this.currentGoal == null) {
 			if (!it.hasNext()) {
-				this.success = Boolean.TRUE;
+				setEndState(EndState.SUCCESSFUL);
 				log.debug("All goals completed.");
 			} else {
 				this.currentGoal = it.next();
@@ -80,11 +74,11 @@ public class SequentialGoalPlanBody extends Behaviour implements PlanBody,
 					setNextGoal(this.completedGoals.get(this.completedGoals
 							.size() - 1), this.currentGoal);
 				}
-				planInstance.dispatchSubgoalAndListen(currentGoal);
+				dispatchSubgoalAndListen(currentGoal);
 				log.debug("Dispatching goal: " + currentGoal);
 			}
 		} else {
-			GoalFinishedEvent goalEvent = planInstance.getGoalEvent();
+			GoalFinishedEvent goalEvent = getGoalEvent();
 			if (goalEvent == null) {
 				return;
 			} else {
@@ -94,7 +88,7 @@ public class SequentialGoalPlanBody extends Behaviour implements PlanBody,
 					log.debug("Goal " + goalEvent.getGoal() + " completed!");
 				} else {
 					this.failedGoal = goalEvent;
-					this.success = Boolean.FALSE;
+					setEndState(EndState.FAILED);
 					log.debug("A goal has failed: " + goalEvent.getGoal());
 				}
 			}
@@ -102,37 +96,12 @@ public class SequentialGoalPlanBody extends Behaviour implements PlanBody,
 	}
 
 	/**
-	 * @see jade.core.behaviours.Behaviour#done()
-	 */
-	@Override
-	public boolean done() {
-		return (this.success != null);
-	}
-
-	/**
-	 * @see bdi4jade.plan.PlanBody#getEndState()
-	 */
-	@Override
-	public EndState getEndState() {
-		if (this.success == null) {
-			return null;
-		} else {
-			return this.success ? EndState.SUCCESSFUL : EndState.FAILED;
-		}
-	}
-
-	/**
 	 * Initializes this plan. Starts the goals iterator.
-	 * 
-	 * @param planInstance
-	 *            the plan instance associated with this plan.
 	 */
 	@Override
-	public void init(PlanInstance planInstance) {
-		this.planInstance = planInstance;
-		SequentialGoal goal = (SequentialGoal) planInstance.getGoal();
+	public void onStart() {
+		SequentialGoal goal = (SequentialGoal) getGoal();
 		this.it = goal.getGoals().iterator();
-		this.success = null;
 		this.currentGoal = null;
 		this.failedGoal = null;
 		this.completedGoals = new ArrayList<Goal>(goal.getGoals().size());
diff --git a/bdi-jade/src/bdi4jade/util/plan/SimplePlan.java b/bdi-jade/src/bdi4jade/util/plan/SimplePlan.java
index 6d853d4..a55008a 100644
--- a/bdi-jade/src/bdi4jade/util/plan/SimplePlan.java
+++ b/bdi-jade/src/bdi4jade/util/plan/SimplePlan.java
@@ -27,7 +27,7 @@ import jade.lang.acl.MessageTemplate;
 import bdi4jade.exception.PlanInstantiationException;
 import bdi4jade.goal.Goal;
 import bdi4jade.plan.Plan;
-import bdi4jade.plan.PlanBody;
+import bdi4jade.plan.PlanBodyInterface;
 
 /**
  * This class represents a plan whose plan body is a class that can be
@@ -39,82 +39,82 @@ import bdi4jade.plan.PlanBody;
  */
 public class SimplePlan extends Plan {
 
-	protected final Class<? extends Behaviour> planBodyClass;
+	protected final Class<? extends PlanBodyInterface> planBodyClass;
 
 	/**
 	 * Creates a new Simple Plan. It is a plan whose body is the specified class
 	 * and its id is the plan body class name. The class must also implement the
-	 * {@link PlanBody} interface, otherwise an exception is going to be thrown
-	 * during the instantiation process.
+	 * {@link PlanBodyInterface} interface, otherwise an exception is going to
+	 * be thrown during the instantiation process. It sets that this plan can
+	 * achieve the specified goal class, but more goals can be specified by
+	 * overriding the initGoals() method.
 	 * 
+	 * @param goalClass
+	 *            the goal that this plan can achieve.
 	 * @param planBodyClass
 	 *            the class of the plan body. It must have the Behavior as super
-	 *            class and implement the {@link PlanBody} interface.
+	 *            class and implement the {@link PlanBodyInterface} interface.
 	 */
-	public SimplePlan(Class<? extends Behaviour> planBodyClass) {
-		super(planBodyClass.getSimpleName());
+	public SimplePlan(Class<? extends Goal> goalClass,
+			Class<? extends PlanBodyInterface> planBodyClass) {
+		super(planBodyClass.getSimpleName(), goalClass);
 		this.planBodyClass = planBodyClass;
 	}
 
 	/**
 	 * Creates a new Simple Plan. It is a plan whose body is the specified class
 	 * and its id is the plan body class name. The class must also implement the
-	 * {@link PlanBody} interface, otherwise an exception is going to be thrown
-	 * during the instantiation process. It sets that this plan can achieve the
-	 * specified goal class, but more goals can be specified by overriding the
-	 * initGoals() method.
+	 * {@link PlanBodyInterface} interface, otherwise an exception is going to
+	 * be thrown during the instantiation process. It sets that this plan can
+	 * achieve the specified goal class, but more goals can be specified by
+	 * overriding the initGoals() method. The message templates is initialized
+	 * with the provided template.
 	 * 
 	 * @param goalClass
 	 *            the goal that this plan can achieve.
+	 * @param messageTemplate
+	 *            the template of messages that this plan can process.
 	 * @param planBodyClass
 	 *            the class of the plan body. It must have the Behavior as super
-	 *            class and implement the {@link PlanBody} interface.
+	 *            class and implement the {@link PlanBodyInterface} interface.
 	 */
 	public SimplePlan(Class<? extends Goal> goalClass,
-			Class<? extends Behaviour> planBodyClass) {
-		super(planBodyClass.getSimpleName(), goalClass);
+			MessageTemplate messageTemplate,
+			Class<? extends PlanBodyInterface> planBodyClass) {
+		super(planBodyClass.getSimpleName(), goalClass, messageTemplate);
 		this.planBodyClass = planBodyClass;
 	}
 
 	/**
 	 * Creates a new Simple Plan. It is a plan whose body is the specified class
 	 * and its id is the plan body class name. The class must also implement the
-	 * {@link PlanBody} interface, otherwise an exception is going to be thrown
-	 * during the instantiation process. It sets that this plan can achieve the
-	 * specified goal class, but more goals can be specified by overriding the
-	 * initGoals() method. The message templates is initialized with the
-	 * provided template.
+	 * {@link PlanBodyInterface} interface, otherwise an exception is going to
+	 * be thrown during the instantiation process.
 	 * 
-	 * @param goalClass
-	 *            the goal that this plan can achieve.
-	 * @param messageTemplate
-	 *            the template of messages that this plan can process.
 	 * @param planBodyClass
 	 *            the class of the plan body. It must have the Behavior as super
-	 *            class and implement the {@link PlanBody} interface.
+	 *            class and implement the {@link PlanBodyInterface} interface.
 	 */
-	public SimplePlan(Class<? extends Goal> goalClass,
-			MessageTemplate messageTemplate,
-			Class<? extends Behaviour> planBodyClass) {
-		super(planBodyClass.getSimpleName(), goalClass, messageTemplate);
+	public SimplePlan(Class<? extends PlanBodyInterface> planBodyClass) {
+		super(planBodyClass.getSimpleName());
 		this.planBodyClass = planBodyClass;
 	}
 
 	/**
 	 * Creates a new Simple Plan. It is a plan whose body is the specified class
 	 * and its id is the plan body class name. The class must also implement the
-	 * {@link PlanBody} interface, otherwise an exception is going to be thrown
-	 * during the instantiation process. The message templates is initialized
-	 * with the provided template.
+	 * {@link PlanBodyInterface} interface, otherwise an exception is going to
+	 * be thrown during the instantiation process. The message templates is
+	 * initialized with the provided template.
 	 * 
 	 * @param messageTemplate
 	 *            the template of messages that this plan can process.
 	 * @param planBodyClass
 	 *            the class of the plan body. It must have the Behavior as super
-	 *            class and implement the {@link PlanBody} interface.
+	 *            class and implement the {@link PlanBodyInterface} interface.
 	 */
 	public SimplePlan(MessageTemplate messageTemplate,
-			Class<? extends Behaviour> planBodyClass) {
+			Class<? extends PlanBodyInterface> planBodyClass) {
 		super(planBodyClass.getSimpleName(), messageTemplate);
 		this.planBodyClass = planBodyClass;
 	}
@@ -122,74 +122,75 @@ public class SimplePlan extends Plan {
 	/**
 	 * Creates a new Simple Plan. It is a plan that has the provided id and
 	 * whose body is the specified class. The class must also implement the
-	 * {@link PlanBody} interface, otherwise an exception is going to be thrown
-	 * during the instantiation process.
+	 * {@link PlanBodyInterface} interface, otherwise an exception is going to
+	 * be thrown during the instantiation process. It sets that this plan can
+	 * achieve the specified goal class, but more goals can be specified by
+	 * overriding the initGoals() method.
 	 * 
 	 * @param id
 	 *            the id of this plan.
+	 * @param goalClass
+	 *            the goal that this plan can achieve.
 	 * @param planBodyClass
 	 *            the class of the plan body. It must have the Behavior as super
-	 *            class and implement the {@link PlanBody} interface.
+	 *            class and implement the {@link PlanBodyInterface} interface.
 	 */
-	public SimplePlan(String id, Class<? extends Behaviour> planBodyClass) {
-		super(id);
+	public SimplePlan(String id, Class<? extends Goal> goalClass,
+			Class<? extends PlanBodyInterface> planBodyClass) {
+		super(id, goalClass);
 		this.planBodyClass = planBodyClass;
 	}
 
 	/**
 	 * Creates a new Simple Plan. It is a plan that has the provided id and
 	 * whose body is the specified class. The class must also implement the
-	 * {@link PlanBody} interface, otherwise an exception is going to be thrown
-	 * during the instantiation process. It sets that this plan can achieve the
-	 * specified goal class, but more goals can be specified by overriding the
-	 * initGoals() method.
+	 * {@link PlanBodyInterface} interface, otherwise an exception is going to
+	 * be thrown during the instantiation process. It sets that this plan can
+	 * achieve the specified goal class, but more goals can be specified by
+	 * overriding the initGoals() method. The message templates is initialized
+	 * with the provided template.
 	 * 
 	 * @param id
 	 *            the id of this plan.
+	 * @param messageTemplate
+	 *            the template of messages that this plan can process.
 	 * @param goalClass
 	 *            the goal that this plan can achieve.
 	 * @param planBodyClass
 	 *            the class of the plan body. It must have the Behavior as super
-	 *            class and implement the {@link PlanBody} interface.
+	 *            class and implement the {@link PlanBodyInterface} interface.
 	 */
 	public SimplePlan(String id, Class<? extends Goal> goalClass,
-			Class<? extends Behaviour> planBodyClass) {
-		super(id, goalClass);
+			MessageTemplate messageTemplate,
+			Class<? extends PlanBodyInterface> planBodyClass) {
+		super(id, goalClass, messageTemplate);
 		this.planBodyClass = planBodyClass;
 	}
 
 	/**
 	 * Creates a new Simple Plan. It is a plan that has the provided id and
 	 * whose body is the specified class. The class must also implement the
-	 * {@link PlanBody} interface, otherwise an exception is going to be thrown
-	 * during the instantiation process. It sets that this plan can achieve the
-	 * specified goal class, but more goals can be specified by overriding the
-	 * initGoals() method. The message templates is initialized with the
-	 * provided template.
+	 * {@link PlanBodyInterface} interface, otherwise an exception is going to
+	 * be thrown during the instantiation process.
 	 * 
 	 * @param id
 	 *            the id of this plan.
-	 * @param messageTemplate
-	 *            the template of messages that this plan can process.
-	 * @param goalClass
-	 *            the goal that this plan can achieve.
 	 * @param planBodyClass
 	 *            the class of the plan body. It must have the Behavior as super
-	 *            class and implement the {@link PlanBody} interface.
+	 *            class and implement the {@link PlanBodyInterface} interface.
 	 */
-	public SimplePlan(String id, Class<? extends Goal> goalClass,
-			MessageTemplate messageTemplate,
-			Class<? extends Behaviour> planBodyClass) {
-		super(id, goalClass, messageTemplate);
+	public SimplePlan(String id,
+			Class<? extends PlanBodyInterface> planBodyClass) {
+		super(id);
 		this.planBodyClass = planBodyClass;
 	}
 
 	/**
 	 * Creates a new Simple Plan. It is a plan that has the provided id and
 	 * whose body is the specified class. The class must also implement the
-	 * {@link PlanBody} interface, otherwise an exception is going to be thrown
-	 * during the instantiation process. The message templates is initialized
-	 * with the provided template.
+	 * {@link PlanBodyInterface} interface, otherwise an exception is going to
+	 * be thrown during the instantiation process. The message templates is
+	 * initialized with the provided template.
 	 * 
 	 * @param id
 	 *            the id of this plan.
@@ -197,10 +198,10 @@ public class SimplePlan extends Plan {
 	 *            the template of messages that this plan can process.
 	 * @param planBodyClass
 	 *            the class of the plan body. It must have the Behavior as super
-	 *            class and implement the {@link PlanBody} interface.
+	 *            class and implement the {@link PlanBodyInterface} interface.
 	 */
 	public SimplePlan(String id, MessageTemplate messageTemplate,
-			Class<? extends Behaviour> planBodyClass) {
+			Class<? extends PlanBodyInterface> planBodyClass) {
 		super(id, messageTemplate);
 		this.planBodyClass = planBodyClass;
 	}
@@ -212,7 +213,7 @@ public class SimplePlan extends Plan {
 	 * @see bdi4jade.plan.Plan#createPlanBody()
 	 */
 	@Override
-	public Behaviour createPlanBody() throws PlanInstantiationException {
+	public PlanBodyInterface createPlanBody() throws PlanInstantiationException {
 		try {
 			return this.planBodyClass.newInstance();
 		} catch (Exception e) {
@@ -223,7 +224,7 @@ public class SimplePlan extends Plan {
 	/**
 	 * @return the planBodyClass
 	 */
-	public Class<? extends Behaviour> getPlanBodyClass() {
+	public Class<? extends PlanBodyInterface> getPlanBodyClass() {
 		return planBodyClass;
 	}
 
diff --git a/bdi-jade/src/bdi4jade/util/reasoning/UtilityBasedPlanSelectionStrategy.java b/bdi-jade/src/bdi4jade/util/reasoning/UtilityBasedPlanSelectionStrategy.java
index 80eb9cb..ff4647b 100644
--- a/bdi-jade/src/bdi4jade/util/reasoning/UtilityBasedPlanSelectionStrategy.java
+++ b/bdi-jade/src/bdi4jade/util/reasoning/UtilityBasedPlanSelectionStrategy.java
@@ -32,9 +32,9 @@ import org.apache.commons.logging.LogFactory;
 import bdi4jade.core.BDIAgent;
 import bdi4jade.goal.Goal;
 import bdi4jade.plan.Plan;
-import bdi4jade.plan.PlanContribution;
 import bdi4jade.preference.SoftgoalPreferences;
 import bdi4jade.reasoning.PlanSelectionStrategy;
+import bdi4jade.softgoal.PlanContribution;
 import bdi4jade.softgoal.Softgoal;
 
 /**
diff --git a/bdi-jade-test/.classpath b/bdi-jade-test/.classpath
index e222681..fb7fc90 100644
--- a/bdi-jade-test/.classpath
+++ b/bdi-jade-test/.classpath
@@ -5,7 +5,6 @@
 	<classpathentry combineaccessrules="false" kind="src" path="/bdi-jade"/>
 	<classpathentry kind="lib" path="/bdi-jade/lib/jade-4.3.2.jar"/>
 	<classpathentry kind="lib" path="/bdi-jade/lib/commons-logging-1.1.3.jar"/>
-	<classpathentry kind="lib" path="/bdi-jade/lib/log4j-api-2.0-rc1.jar"/>
-	<classpathentry kind="lib" path="/bdi-jade/lib/log4j-core-2.0-rc1.jar"/>
+	<classpathentry kind="lib" path="/bdi-jade/lib/log4j-1.2.17.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/bdi-jade-test/src/bdi4jade/examples/AgentStarter.java b/bdi-jade-test/src/bdi4jade/examples/AgentStarter.java
index 3e679f8..a9435d8 100644
--- a/bdi-jade-test/src/bdi4jade/examples/AgentStarter.java
+++ b/bdi-jade-test/src/bdi4jade/examples/AgentStarter.java
@@ -36,6 +36,7 @@ import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.PropertyConfigurator;
 
 /**
  * @author ingrid
@@ -50,13 +51,15 @@ public class AgentStarter {
 		// agents.put(HelloWorldAgent.class.getSimpleName(), new
 		// HelloWorldAgent());
 		agents.put(BDIAgent1.MY_NAME, new BDIAgent1());
-		agents.put(BDIAgent2.MY_NAME, new BDIAgent2());
+		// agents.put(BDIAgent2.MY_NAME, new BDIAgent2());
 		// agents.put(MyAgent.class.getSimpleName(), new MyAgent());
 		// agents.put(NestedCapabilitiesAgent.class.getSimpleName(),
 		// new NestedCapabilitiesAgent());
 	};
 
 	public static void main(String[] args) {
+		PropertyConfigurator.configure(AgentStarter.class
+				.getResource("log4j.properties"));
 		new AgentStarter();
 	}
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/BDIAgent1.java b/bdi-jade-test/src/bdi4jade/examples/BDIAgent1.java
index fb4c0a5..0a6d854 100644
--- a/bdi-jade-test/src/bdi4jade/examples/BDIAgent1.java
+++ b/bdi-jade-test/src/bdi4jade/examples/BDIAgent1.java
@@ -23,7 +23,7 @@
 package bdi4jade.examples;
 
 import bdi4jade.core.BDIAgent;
-import bdi4jade.examples.ping.PingPongCapability;
+import bdi4jade.examples.blocksworld.BlocksWorldCapability;
 
 /**
  * @author ingrid
@@ -31,16 +31,16 @@ import bdi4jade.examples.ping.PingPongCapability;
  */
 public class BDIAgent1 extends BDIAgent {
 
-	private static final long serialVersionUID = -8505187840524213951L;
 	public static final String MY_NAME = "AGENT_1";
+	private static final long serialVersionUID = -8505187840524213951L;
 
 	@Override
 	protected void init() {
-		// this.addCapability(new BlocksWorldCapability());
+		this.addCapability(new BlocksWorldCapability());
 		// this.addCapability(new PlanFailedCapability());
 		// this.addCapability(new SubgoalCapability());
-		this.addCapability(new PingPongCapability(BDIAgent1.MY_NAME,
-				BDIAgent2.MY_NAME));
+		// this.addCapability(new PingPongCapability(BDIAgent1.MY_NAME,
+		// BDIAgent2.MY_NAME));
 		// this.addCapability(new CompositeGoalCapability(true));
 		// this.addCapability(new CompositeGoalCapability(false));
 	}
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/AchieveOnPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/AchieveOnPlanBody.java
index 4f45f9f..874c309 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/AchieveOnPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/AchieveOnPlanBody.java
@@ -22,26 +22,24 @@
 
 package bdi4jade.examples.blocksworld.plan;
 
-import jade.core.behaviours.Behaviour;
 import bdi4jade.examples.blocksworld.BlocksWorldCapability;
 import bdi4jade.examples.blocksworld.domain.Clear;
 import bdi4jade.examples.blocksworld.domain.On;
 import bdi4jade.examples.blocksworld.domain.Thing;
 import bdi4jade.examples.blocksworld.goal.PerformMove;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 import bdi4jade.util.goal.BeliefSetValueGoal;
 
 /**
  * @author ingrid
  * 
  */
-public class AchieveOnPlanBody extends Behaviour implements PlanBody {
+public class AchieveOnPlanBody extends PlanBody {
+
 	private static final long serialVersionUID = -5919677537834351951L;
 
 	private int counter;
-	private PlanInstance planInstance;
 	private Thing thing1;
 	private Thing thing2;
 
@@ -54,8 +52,7 @@ public class AchieveOnPlanBody extends Behaviour implements PlanBody {
 		switch (counter) {
 		case 0:
 			if (new BeliefSetValueGoal<On>(BlocksWorldCapability.BELIEF_ON,
-					new On(thing1, thing2)).isAchieved(planInstance
-					.getBeliefBase())) {
+					new On(thing1, thing2)).isAchieved(getBeliefBase())) {
 				counter = 6;
 			} else {
 				counter = checkClearAndDispatch(thing1) ? 1 : 2;
@@ -65,23 +62,25 @@ public class AchieveOnPlanBody extends Behaviour implements PlanBody {
 			counter = checkClearAndDispatch(thing2) ? 3 : 4;
 			break;
 		case 4:
-			planInstance.dispatchSubgoalAndListen(new PerformMove(thing1,
-					thing2));
+			dispatchSubgoalAndListen(new PerformMove(thing1, thing2));
 			counter = 5;
 		case 1:
 		case 3:
 		case 5:
-			if (planInstance.getGoalEvent() != null)
+			if (getGoalEvent() != null)
 				counter++;
 			break;
 		}
+
+		if (counter == 6)
+			setEndState(EndState.SUCCESSFUL);
 	}
 
 	private boolean checkClearAndDispatch(Thing thing) {
 		BeliefSetValueGoal<Clear> clearBelief = new BeliefSetValueGoal<Clear>(
 				BlocksWorldCapability.BELIEF_CLEAR, new Clear(thing1));
-		if (!clearBelief.isAchieved(planInstance.getBeliefBase())) {
-			planInstance.dispatchSubgoalAndListen(clearBelief);
+		if (!clearBelief.isAchieved(getBeliefBase())) {
+			dispatchSubgoalAndListen(clearBelief);
 			return true;
 		} else {
 			return false;
@@ -89,21 +88,9 @@ public class AchieveOnPlanBody extends Behaviour implements PlanBody {
 	}
 
 	@Override
-	public boolean done() {
-		return counter == 6;
-	}
-
-	@Override
-	public EndState getEndState() {
-		return (counter == 6) ? EndState.SUCCESSFUL : null;
-	}
-
-	@Override
 	@SuppressWarnings("unchecked")
-	public void init(PlanInstance planInstance) {
-		this.planInstance = planInstance;
-		BeliefSetValueGoal<On> achieveOn = (BeliefSetValueGoal<On>) planInstance
-				.getGoal();
+	public void onStart() {
+		BeliefSetValueGoal<On> achieveOn = (BeliefSetValueGoal<On>) getGoal();
 		this.thing1 = achieveOn.getValue().getThing1();
 		this.thing2 = achieveOn.getValue().getThing2();
 	}
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/ClearPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/ClearPlanBody.java
index c23280a..032391f 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/ClearPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/ClearPlanBody.java
@@ -22,34 +22,30 @@
 
 package bdi4jade.examples.blocksworld.plan;
 
-import jade.core.behaviours.Behaviour;
 import bdi4jade.belief.BeliefSet;
 import bdi4jade.examples.blocksworld.BlocksWorldCapability;
 import bdi4jade.examples.blocksworld.domain.Clear;
 import bdi4jade.examples.blocksworld.domain.On;
 import bdi4jade.examples.blocksworld.domain.Thing;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 import bdi4jade.util.goal.BeliefSetValueGoal;
 
 /**
  * @author ingrid
  * 
  */
-public class ClearPlanBody extends Behaviour implements PlanBody {
+public class ClearPlanBody extends PlanBody {
+
 	private static final long serialVersionUID = -5919677537834351951L;
 
-	private boolean done;
 	private int index;
-	private Thing thing;
-	private PlanInstance planInstance;
 	private On on;
-	private boolean waiting;
 	private BeliefSet<On> onSet;
+	private Thing thing;
+	private boolean waiting;
 
 	public ClearPlanBody() {
-		this.done = false;
 		this.waiting = false;
 		this.index = 0;
 	}
@@ -61,15 +57,15 @@ public class ClearPlanBody extends Behaviour implements PlanBody {
 				Thing t = Thing.THINGS[index];
 				on = new On(t, thing);
 				if (onSet.hasValue(on)) {
-					planInstance
-							.dispatchSubgoalAndListen(new BeliefSetValueGoal<On>(
-									BlocksWorldCapability.BELIEF_ON, new On(t,
-											Thing.TABLE)));
+
+					dispatchSubgoalAndListen(new BeliefSetValueGoal<On>(
+							BlocksWorldCapability.BELIEF_ON, new On(t,
+									Thing.TABLE)));
 					waiting = true;
 					break;
 				}
 			}
-		} else if (planInstance.getGoalEvent() != null) {
+		} else if (getGoalEvent() != null) {
 			onSet.removeValue(on);
 			on = null;
 			waiting = false;
@@ -77,28 +73,16 @@ public class ClearPlanBody extends Behaviour implements PlanBody {
 		}
 
 		if (index >= Thing.THINGS.length) {
-			done = true;
+			setEndState(EndState.SUCCESSFUL);
 		}
 	}
 
 	@Override
-	public boolean done() {
-		return done;
-	}
-
-	@Override
-	public EndState getEndState() {
-		return done ? EndState.SUCCESSFUL : null;
-	}
-
-	@Override
 	@SuppressWarnings("unchecked")
-	public void init(PlanInstance planInstance) {
-		this.onSet = (BeliefSet<On>) planInstance.getBeliefBase().getBelief(
+	public void onStart() {
+		this.onSet = (BeliefSet<On>) getBeliefBase().getBelief(
 				BlocksWorldCapability.BELIEF_ON);
-		this.planInstance = planInstance;
-		BeliefSetValueGoal<Clear> achieveClear = (BeliefSetValueGoal<Clear>) planInstance
-				.getGoal();
+		BeliefSetValueGoal<Clear> achieveClear = (BeliefSetValueGoal<Clear>) getGoal();
 		this.thing = achieveClear.getValue().getThing();
 	}
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/PerformMovePlanBody.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/PerformMovePlanBody.java
index b5e233a..1bd5978 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/PerformMovePlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/PerformMovePlanBody.java
@@ -22,35 +22,28 @@
 
 package bdi4jade.examples.blocksworld.plan;
 
-import jade.core.behaviours.Behaviour;
 import bdi4jade.belief.BeliefSet;
 import bdi4jade.examples.blocksworld.BlocksWorldCapability;
 import bdi4jade.examples.blocksworld.domain.Clear;
 import bdi4jade.examples.blocksworld.domain.On;
 import bdi4jade.examples.blocksworld.domain.Thing;
 import bdi4jade.examples.blocksworld.goal.PerformMove;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
  * 
  */
-public class PerformMovePlanBody extends Behaviour implements PlanBody {
+public class PerformMovePlanBody extends PlanBody {
 
 	private static final long serialVersionUID = -5919677537834351951L;
 
 	private BeliefSet<Clear> clearSet;
-	private boolean done;
 	private BeliefSet<On> onSet;
 	private Thing thing1;
 	private Thing thing2;
 
-	public PerformMovePlanBody() {
-		this.done = false;
-	}
-
 	@Override
 	public void action() {
 		if (!thing2.equals(Thing.TABLE)) {
@@ -68,27 +61,17 @@ public class PerformMovePlanBody extends Behaviour implements PlanBody {
 		}
 
 		onSet.addValue(new On(thing1, thing2));
-		this.done = true;
-	}
-
-	@Override
-	public boolean done() {
-		return done;
-	}
-
-	@Override
-	public EndState getEndState() {
-		return done ? EndState.SUCCESSFUL : null;
+		setEndState(EndState.SUCCESSFUL);
 	}
 
 	@Override
 	@SuppressWarnings("unchecked")
-	public void init(PlanInstance planInstance) {
-		this.onSet = (BeliefSet<On>) planInstance.getBeliefBase().getBelief(
+	public void onStart() {
+		this.onSet = (BeliefSet<On>) getBeliefBase().getBelief(
 				BlocksWorldCapability.BELIEF_ON);
-		this.clearSet = (BeliefSet<Clear>) planInstance.getBeliefBase()
-				.getBelief(BlocksWorldCapability.BELIEF_CLEAR);
-		PerformMove goal = (PerformMove) planInstance.getGoal();
+		this.clearSet = (BeliefSet<Clear>) getBeliefBase().getBelief(
+				BlocksWorldCapability.BELIEF_CLEAR);
+		PerformMove goal = (PerformMove) getGoal();
 		this.thing1 = goal.getThing1();
 		this.thing2 = goal.getThing2();
 	}
diff --git a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/TopLevelPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/TopLevelPlanBody.java
index 48a087c..d7bb4b9 100644
--- a/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/TopLevelPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/blocksworld/plan/TopLevelPlanBody.java
@@ -22,30 +22,26 @@
 
 package bdi4jade.examples.blocksworld.plan;
 
-import jade.core.behaviours.Behaviour;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import bdi4jade.examples.blocksworld.BlocksWorldCapability;
 import bdi4jade.examples.blocksworld.domain.On;
 import bdi4jade.examples.blocksworld.goal.AchieveBlocksStacked;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 import bdi4jade.util.goal.BeliefSetValueGoal;
 
 /**
  * @author ingrid
  * 
  */
-public class TopLevelPlanBody extends Behaviour implements PlanBody {
+public class TopLevelPlanBody extends PlanBody {
 
 	private static final long serialVersionUID = -5919677537834351951L;
 
 	private int counter;
 	private Log log;
-	private PlanInstance planInstance;
 	private On[] target;
 
 	public TopLevelPlanBody() {
@@ -56,45 +52,33 @@ public class TopLevelPlanBody extends Behaviour implements PlanBody {
 	@Override
 	public void action() {
 		if (counter != 0) {
-			if ((planInstance.getGoalEvent() == null)) {
+			if ((getGoalEvent() == null)) {
 				return;
 			}
 		}
 		if (counter != target.length) {
-			planInstance.dispatchSubgoalAndListen(new BeliefSetValueGoal<On>(
+			dispatchSubgoalAndListen(new BeliefSetValueGoal<On>(
 					BlocksWorldCapability.BELIEF_ON, target[counter]));
 		}
 		counter++;
-	}
-
-	@Override
-	public boolean done() {
-		return counter > target.length;
-	}
 
-	@Override
-	public EndState getEndState() {
-		return (counter > target.length) ? EndState.SUCCESSFUL : null;
-	}
-
-	@Override
-	public void init(PlanInstance planInstance) {
-		this.planInstance = planInstance;
-		this.target = ((AchieveBlocksStacked) planInstance.getGoal())
-				.getTarget();
+		if (counter > target.length)
+			setEndState(EndState.SUCCESSFUL);
 	}
 
 	@Override
 	public int onEnd() {
 		log.info("World Model at end is:");
-		log.info(planInstance.getBeliefBase());
+		log.info(getBeliefBase());
 		return super.onEnd();
 	}
 
 	@Override
 	public void onStart() {
 		log.info("World Model at start is:");
-		log.info(planInstance.getBeliefBase());
+		this.target = ((AchieveBlocksStacked) getGoal())
+				.getTarget();
+		log.info(getBeliefBase());
 	}
 
 }
diff --git a/bdi-jade-test/src/bdi4jade/examples/compositegoal/MyPlan.java b/bdi-jade-test/src/bdi4jade/examples/compositegoal/MyPlan.java
index a8fa362..8b3d970 100644
--- a/bdi-jade-test/src/bdi4jade/examples/compositegoal/MyPlan.java
+++ b/bdi-jade-test/src/bdi4jade/examples/compositegoal/MyPlan.java
@@ -22,46 +22,33 @@
 
 package bdi4jade.examples.compositegoal;
 
-import jade.core.behaviours.Behaviour;
-
 import java.util.Random;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
- *
+ * 
  */
-public class MyPlan extends Behaviour implements PlanBody {
+public class MyPlan extends PlanBody {
 
 	private static final long serialVersionUID = -220345270457161508L;
-	
-	private EndState endState = null;
-	private PlanInstance planInstance;
+
 	private Log log = LogFactory.getLog(this.getClass());
 
 	public void action() {
 		long random = new Random().nextLong();
 		log.info("Random: " + random);
-		endState = (random % 3 != 0) ? EndState.SUCCESSFUL : EndState.FAILED;
-		log.info(planInstance.getGoal() + " Plan#"
-				+ planInstance.getPlan().getId() + " EndState: " + endState);
-	}
-
-	public boolean done() {
-		return true;
+		if (random % 3 != 0)
+			setEndState(EndState.SUCCESSFUL);
+		else
+			setEndState(EndState.FAILED);
+		log.info(getGoal() + " Plan#" + getPlan().getId() + " EndState: "
+				+ getEndState());
 	}
 
-	public EndState getEndState() {
-		return endState;
-	}
-
-	public void init(PlanInstance planInstance) {
-		this.planInstance = planInstance;
-	}
 }
diff --git a/bdi-jade-test/src/bdi4jade/examples/helloworld/HelloWorldPlan.java b/bdi-jade-test/src/bdi4jade/examples/helloworld/HelloWorldPlan.java
index 319484f..f469084 100644
--- a/bdi-jade-test/src/bdi4jade/examples/helloworld/HelloWorldPlan.java
+++ b/bdi-jade-test/src/bdi4jade/examples/helloworld/HelloWorldPlan.java
@@ -22,33 +22,21 @@
 
 package bdi4jade.examples.helloworld;
 
-import jade.core.behaviours.OneShotBehaviour;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingridn
  * 
  */
-public class HelloWorldPlan extends OneShotBehaviour implements PlanBody {
+public class HelloWorldPlan extends PlanBody {
 
 	private static final long serialVersionUID = -9039447524062487795L;
 
-	private String name;
-	private EndState endState;
-
 	public void action() {
-		System.out.println("Hello, " + name + "!");
-		this.endState = EndState.SUCCESSFUL;
-	}
-
-	public EndState getEndState() {
-		return endState;
+		System.out.println("Hello, " + ((HelloWorldGoal) getGoal()).getName()
+				+ "!");
+		setEndState(EndState.SUCCESSFUL);
 	}
 
-	public void init(PlanInstance planInstance) {
-		this.name = ((HelloWorldGoal) planInstance.getGoal()).getName();
-		this.endState = null;
-	}
 }
diff --git a/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/NestedCapabilitiesAgent.java b/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/NestedCapabilitiesAgent.java
index bc81eb6..4ed8e92 100644
--- a/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/NestedCapabilitiesAgent.java
+++ b/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/NestedCapabilitiesAgent.java
@@ -22,11 +22,11 @@
 
 package bdi4jade.examples.nestedcapabilities;
 
-import jade.core.behaviours.Behaviour;
 import bdi4jade.belief.TransientBelief;
 import bdi4jade.core.BDIAgent;
 import bdi4jade.core.Capability;
 import bdi4jade.goal.Goal;
+import bdi4jade.plan.PlanBodyInterface;
 import bdi4jade.util.plan.SimplePlan;
 
 class ChildGoal implements Goal {
@@ -53,7 +53,7 @@ public class NestedCapabilitiesAgent extends BDIAgent {
 	}
 
 	private void addPlan(Capability capability, Class<? extends Goal> goal,
-			Class<? extends Behaviour> planBody) {
+			Class<? extends PlanBodyInterface> planBody) {
 		capability.getPlanLibrary().addPlan(new SimplePlan(goal, planBody));
 	}
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/SuccessPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/SuccessPlanBody.java
index 7eb89c6..421b7c3 100644
--- a/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/SuccessPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/SuccessPlanBody.java
@@ -22,33 +22,25 @@
 
 package bdi4jade.examples.nestedcapabilities;
 
-import jade.core.behaviours.OneShotBehaviour;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
-public class SuccessPlanBody extends OneShotBehaviour implements PlanBody {
+public class SuccessPlanBody extends PlanBody {
 
 	private static final long serialVersionUID = -9039447524062487795L;
 
-	private EndState endState;
 	private Log log;
 
 	public void action() {
 		log.info(this.getClass().getSimpleName() + " executed.");
-		this.endState = EndState.SUCCESSFUL;
-	}
-
-	public EndState getEndState() {
-		return endState;
+		setEndState(EndState.SUCCESSFUL);
 	}
 
-	public void init(PlanInstance planInstance) {
+	public void onStart() {
 		this.log = LogFactory.getLog(this.getClass());
-		this.endState = null;
 	}
+
 }
diff --git a/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/TestPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/TestPlanBody.java
index f894551..37d1103 100644
--- a/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/TestPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/nestedcapabilities/TestPlanBody.java
@@ -22,19 +22,16 @@
 
 package bdi4jade.examples.nestedcapabilities;
 
-import jade.core.behaviours.Behaviour;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import bdi4jade.event.GoalFinishedEvent;
 import bdi4jade.examples.nestedcapabilities.NestedCapabilitiesAgent.Belief;
 import bdi4jade.goal.GoalStatus;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
-public class TestPlanBody extends Behaviour implements PlanBody {
+public class TestPlanBody extends PlanBody {
 
 	enum TestStep {
 		BELIEF, CHILD_GOAL, COMPLETED, MY_GOAL, PARENT_GOAL, PARENT_PROTECTED_GOAL, SIBLING_GOAL, SIBLING_PROTECTED_GOAL;
@@ -42,7 +39,6 @@ public class TestPlanBody extends Behaviour implements PlanBody {
 
 	private static final long serialVersionUID = -9039447524062487795L;
 
-	private PlanInstance instance;
 	private Log log;
 	private TestStep step;
 
@@ -58,65 +54,65 @@ public class TestPlanBody extends Behaviour implements PlanBody {
 			printBelief(Belief.CHILD_BELIEF);
 
 			log.info("Testing plans...");
-			instance.dispatchProtectedSubgoalAndListen(new MyGoal());
+			dispatchProtectedSubgoalAndListen(new MyGoal());
 			this.step = TestStep.MY_GOAL;
 			break;
 		case MY_GOAL:
-			GoalFinishedEvent goalEvent = instance.getGoalEvent();
+			GoalFinishedEvent goalEvent = getGoalEvent();
 			if (goalEvent == null) {
 				return;
 			} else {
 				printGoal(goalEvent, true);
-				instance.dispatchProtectedSubgoalAndListen(new ChildGoal());
+				dispatchProtectedSubgoalAndListen(new ChildGoal());
 			}
 			this.step = TestStep.CHILD_GOAL;
 			break;
 		case CHILD_GOAL:
-			goalEvent = instance.getGoalEvent();
+			goalEvent = getGoalEvent();
 			if (goalEvent == null) {
 				return;
 			} else {
 				printGoal(goalEvent, true);
-				instance.dispatchSubgoalAndListen(new ParentGoal());
+				dispatchSubgoalAndListen(new ParentGoal());
 			}
 
 			this.step = TestStep.PARENT_GOAL;
 			break;
 		case PARENT_GOAL:
-			goalEvent = instance.getGoalEvent();
+			goalEvent = getGoalEvent();
 			if (goalEvent == null) {
 				return;
 			} else {
 				printGoal(goalEvent, true);
-				instance.dispatchSubgoalAndListen(new SiblingGoal());
+				dispatchSubgoalAndListen(new SiblingGoal());
 			}
 
 			this.step = TestStep.SIBLING_GOAL;
 			break;
 		case SIBLING_GOAL:
-			goalEvent = instance.getGoalEvent();
+			goalEvent = getGoalEvent();
 			if (goalEvent == null) {
 				return;
 			} else {
 				printGoal(goalEvent, true);
-				instance.dispatchProtectedSubgoalAndListen(new ParentGoal());
+				dispatchProtectedSubgoalAndListen(new ParentGoal());
 			}
 
 			this.step = TestStep.PARENT_PROTECTED_GOAL;
 			break;
 		case PARENT_PROTECTED_GOAL:
-			goalEvent = instance.getGoalEvent();
+			goalEvent = getGoalEvent();
 			if (goalEvent == null) {
 				return;
 			} else {
 				printGoal(goalEvent, false);
-				instance.dispatchProtectedSubgoalAndListen(new SiblingGoal());
+				dispatchProtectedSubgoalAndListen(new SiblingGoal());
 			}
 
 			this.step = TestStep.SIBLING_PROTECTED_GOAL;
 			break;
 		case SIBLING_PROTECTED_GOAL:
-			goalEvent = instance.getGoalEvent();
+			goalEvent = getGoalEvent();
 			if (goalEvent == null) {
 				return;
 			} else {
@@ -128,26 +124,18 @@ public class TestPlanBody extends Behaviour implements PlanBody {
 		case COMPLETED:
 			break;
 		}
-	}
 
-	@Override
-	public boolean done() {
-		return getEndState() != null;
+		if (TestStep.COMPLETED.equals(step))
+			setEndState(EndState.SUCCESSFUL);
 	}
 
-	public EndState getEndState() {
-		return TestStep.COMPLETED.equals(step) ? EndState.SUCCESSFUL : null;
-	}
-
-	public void init(PlanInstance planInstance) {
+	public void onStart() {
 		this.log = LogFactory.getLog(this.getClass());
-		this.instance = planInstance;
 		this.step = TestStep.BELIEF;
 	}
 
 	private void printBelief(Belief belief) {
-		log.info(belief + ": "
-				+ instance.getBeliefBase().getBelief(belief.name()));
+		log.info(belief + ": " + getBeliefBase().getBelief(belief.name()));
 
 	}
 
@@ -163,4 +151,5 @@ public class TestPlanBody extends Behaviour implements PlanBody {
 		}
 
 	}
+
 }
diff --git a/bdi-jade-test/src/bdi4jade/examples/ping/PingPlan.java b/bdi-jade-test/src/bdi4jade/examples/ping/PingPlan.java
index b62968d..95173dd 100644
--- a/bdi-jade-test/src/bdi4jade/examples/ping/PingPlan.java
+++ b/bdi-jade-test/src/bdi4jade/examples/ping/PingPlan.java
@@ -23,32 +23,29 @@
 package bdi4jade.examples.ping;
 
 import jade.core.AID;
-import jade.core.behaviours.Behaviour;
 import jade.lang.acl.ACLMessage;
 import jade.lang.acl.MessageTemplate;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
  * 
  */
-public class PingPlan extends Behaviour implements PlanBody {
+public class PingPlan extends PlanBody {
 
 	private static final long serialVersionUID = -6288758975856575305L;
 
 	private String agent;
-	private boolean done;
+	private int counter;
 	private Log log;
 	private MessageTemplate mt;
 	private boolean sent;
 	private int times;
-	private int counter;
 
 	@Override
 	public void action() {
@@ -72,7 +69,7 @@ public class PingPlan extends Behaviour implements PlanBody {
 				log.info("Content: " + reply.getContent());
 				counter++;
 				if (counter == times) {
-					this.done = true;
+					setEndState(EndState.SUCCESSFUL);
 				} else {
 					this.sent = false;
 				}
@@ -83,22 +80,11 @@ public class PingPlan extends Behaviour implements PlanBody {
 	}
 
 	@Override
-	public boolean done() {
-		return done;
-	}
-
-	@Override
-	public EndState getEndState() {
-		return done ? EndState.SUCCESSFUL : null;
-	}
-
-	@Override
-	public void init(PlanInstance planInstance) {
+	public void onStart() {
 		this.log = LogFactory.getLog(this.getClass());
-		Ping ping = (Ping) planInstance.getGoal();
+		Ping ping = (Ping) getGoal();
 		this.agent = ping.getAgent();
 		this.sent = false;
-		this.done = false;
 		this.counter = 0;
 		this.times = 1;
 	}
diff --git a/bdi-jade-test/src/bdi4jade/examples/ping/PongPlan.java b/bdi-jade-test/src/bdi4jade/examples/ping/PongPlan.java
index 235ab1a..ecfc020 100644
--- a/bdi-jade-test/src/bdi4jade/examples/ping/PongPlan.java
+++ b/bdi-jade-test/src/bdi4jade/examples/ping/PongPlan.java
@@ -22,28 +22,25 @@
 
 package bdi4jade.examples.ping;
 
-import jade.core.behaviours.OneShotBehaviour;
 import jade.lang.acl.ACLMessage;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import bdi4jade.message.MessageGoal;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
  * 
  */
-public class PongPlan extends OneShotBehaviour implements PlanBody {
+public class PongPlan extends PlanBody {
 
 	private static final long serialVersionUID = -3352874506241004611L;
 
 	private Log log;
 	private ACLMessage pingMsg;
-	private EndState endState;
 
 	@Override
 	public void action() {
@@ -53,20 +50,14 @@ public class PongPlan extends OneShotBehaviour implements PlanBody {
 		reply.setContent(PingPongCapability.PONG);
 		this.myAgent.send(reply);
 		log.info("Pong sent to agent" + pingMsg.getSender().getName() + "!");
-		this.endState = EndState.SUCCESSFUL;
+		setEndState(EndState.SUCCESSFUL);
 	}
 
 	@Override
-	public EndState getEndState() {
-		return endState;
-	}
-
-	@Override
-	public void init(PlanInstance planInstance) {
+	public void onStart() {
 		this.log = LogFactory.getLog(this.getClass());
-		MessageGoal goal = (MessageGoal) planInstance.getGoal();
+		MessageGoal goal = (MessageGoal) getGoal();
 		pingMsg = goal.getMessage();
-		this.endState = null;
 	}
 
 }
diff --git a/bdi-jade-test/src/bdi4jade/examples/planfailed/MyPlan.java b/bdi-jade-test/src/bdi4jade/examples/planfailed/MyPlan.java
index f99f626..91814e0 100644
--- a/bdi-jade-test/src/bdi4jade/examples/planfailed/MyPlan.java
+++ b/bdi-jade-test/src/bdi4jade/examples/planfailed/MyPlan.java
@@ -22,46 +22,33 @@
 
 package bdi4jade.examples.planfailed;
 
-import jade.core.behaviours.Behaviour;
-
 import java.util.Random;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
  * 
  */
-public class MyPlan extends Behaviour implements PlanBody {
+public class MyPlan extends PlanBody {
 
 	private static final long serialVersionUID = -220345270457161508L;
-	
-	private EndState endState = null;
-	private PlanInstance planInstance;
+
 	private Log log = LogFactory.getLog(this.getClass());
 
 	public void action() {
 		long random = new Random().nextLong();
 		log.info("Random: " + random);
-		endState = (random % 3 == 0) ? EndState.SUCCESSFUL : EndState.FAILED;
-		log.info(planInstance.getGoal() + " Plan#"
-				+ planInstance.getPlan().getId() + " EndState: " + endState);
-	}
-
-	public boolean done() {
-		return true;
-	}
-
-	public EndState getEndState() {
-		return endState;
-	}
-
-	public void init(PlanInstance planInstance) {
-		this.planInstance = planInstance;
+		if (random % 3 == 0)
+			setEndState(EndState.SUCCESSFUL);
+		else
+			setEndState(EndState.FAILED);
+		log.info(getGoal() + " Plan#" + getPlan().getId() + " EndState: "
+				+ getEndState());
 	}
+	
 }
\ No newline at end of file
diff --git a/bdi-jade-test/src/bdi4jade/examples/planselection/ExperimentRunner.java b/bdi-jade-test/src/bdi4jade/examples/planselection/ExperimentRunner.java
index 18bbc22..c186894 100644
--- a/bdi-jade-test/src/bdi4jade/examples/planselection/ExperimentRunner.java
+++ b/bdi-jade-test/src/bdi4jade/examples/planselection/ExperimentRunner.java
@@ -33,10 +33,12 @@ import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.PropertyConfigurator;
 
 import bdi4jade.event.GoalEvent;
 import bdi4jade.event.GoalFinishedEvent;
 import bdi4jade.event.GoalListener;
+import bdi4jade.examples.AgentStarter;
 
 /**
  * @author ingrid
@@ -47,6 +49,8 @@ public class ExperimentRunner implements GoalListener {
 	public static final int ITERATIONS = 5000;
 
 	public static void main(String[] args) {
+		PropertyConfigurator.configure(AgentStarter.class
+				.getResource("log4j.properties"));
 		ExperimentRunner runner = new ExperimentRunner();
 		runner.run();
 	}
diff --git a/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlan.java b/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlan.java
index 75be25a..436e093 100644
--- a/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlan.java
+++ b/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlan.java
@@ -26,7 +26,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import bdi4jade.plan.PlanContribution;
+import bdi4jade.softgoal.PlanContribution;
 import bdi4jade.softgoal.Softgoal;
 import bdi4jade.util.plan.SimplePlan;
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlanBody.java
index bef3ab7..3cbcd97 100644
--- a/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/planselection/TransportationPlanBody.java
@@ -22,25 +22,21 @@
 
 package bdi4jade.examples.planselection;
 
-import jade.core.behaviours.OneShotBehaviour;
-
 import java.util.Random;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import bdi4jade.belief.TransientBelief;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 import bdi4jade.preference.SoftgoalPreferences;
 
 /**
  * @author ingrid
  * 
  */
-public class TransportationPlanBody extends OneShotBehaviour implements
-		PlanBody {
+public class TransportationPlanBody extends PlanBody {
 
 	class Scenario {
 
@@ -123,7 +119,6 @@ public class TransportationPlanBody extends OneShotBehaviour implements
 	private TransportationPlan plan;
 	private SoftgoalPreferences preferences;
 	private GenericValueFunction<Integer> satisfaction;
-	private EndState endState = null;
 
 	public void action() {
 		log.debug("Plan executed: " + this.plan.getId());
@@ -132,22 +127,17 @@ public class TransportationPlanBody extends OneShotBehaviour implements
 		this.satisfaction.addValue(this.satisfaction.getCount() + 1,
 				satisfaction);
 		log.debug("Plan finished!");
-		this.endState = EndState.SUCCESSFUL;
-	}
-
-	public EndState getEndState() {
-		return endState;
+		setEndState(EndState.SUCCESSFUL);
 	}
 
 	@SuppressWarnings("unchecked")
-	public void init(PlanInstance planInstance) {
+	public void onStart() {
 		this.log = LogFactory.getLog(this.getClass());
-		this.plan = (TransportationPlan) planInstance.getPlan();
-		this.satisfaction = ((TransientBelief<GenericValueFunction<Integer>>) planInstance
-				.getBeliefBase().getBelief(TransportationAgent.SATISFACTION))
-				.getValue();
-		this.preferences = (SoftgoalPreferences) planInstance.getBeliefBase()
-				.getBelief(SoftgoalPreferences.NAME);
-		this.endState = null;
+		this.plan = (TransportationPlan) getPlan();
+		this.satisfaction = ((TransientBelief<GenericValueFunction<Integer>>) getBeliefBase()
+				.getBelief(TransportationAgent.SATISFACTION)).getValue();
+		this.preferences = (SoftgoalPreferences) getBeliefBase().getBelief(
+				SoftgoalPreferences.NAME);
 	}
+	
 }
diff --git a/bdi-jade-test/src/bdi4jade/examples/subgoal/ChildPlan.java b/bdi-jade-test/src/bdi4jade/examples/subgoal/ChildPlan.java
index f4b84bc..e159e97 100644
--- a/bdi-jade-test/src/bdi4jade/examples/subgoal/ChildPlan.java
+++ b/bdi-jade-test/src/bdi4jade/examples/subgoal/ChildPlan.java
@@ -22,44 +22,39 @@
 
 package bdi4jade.examples.subgoal;
 
-import jade.core.behaviours.CyclicBehaviour;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import bdi4jade.plan.DisposablePlanBody;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
  * 
  */
-public class ChildPlan extends CyclicBehaviour implements PlanBody {
+public class ChildPlan extends PlanBody implements DisposablePlanBody {
 
 	private static final long serialVersionUID = -5432560989511973914L;
 
 	private int counter;
 	private Log log = LogFactory.getLog(this.getClass());
-	private PlanInstance planInstance;
 
 	@Override
 	public void action() {
 		if (counter == 0) {
-			this.planInstance.dispatchSubgoal(new Subgoal());
+			dispatchSubgoal(new Subgoal());
 		}
 		log.info("ChildPlan executing... counter " + counter);
 		counter++;
 	}
 
 	@Override
-	public EndState getEndState() {
-		return null;
+	public void onAbort() {
+		log.info("ChildPlan aborted.");
 	}
 
 	@Override
-	public void init(PlanInstance planInstance) {
-		this.planInstance = planInstance;
+	public void onStart() {
 		this.counter = 0;
 	}
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/subgoal/MyPlan.java b/bdi-jade-test/src/bdi4jade/examples/subgoal/MyPlan.java
index b478df6..7da6fd8 100644
--- a/bdi-jade-test/src/bdi4jade/examples/subgoal/MyPlan.java
+++ b/bdi-jade-test/src/bdi4jade/examples/subgoal/MyPlan.java
@@ -22,20 +22,17 @@
 
 package bdi4jade.examples.subgoal;
 
-import jade.core.behaviours.Behaviour;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
  * 
  */
-public class MyPlan extends Behaviour implements PlanBody {
+public class MyPlan extends PlanBody {
 
 	private static final long serialVersionUID = -5432560989511973914L;
 
@@ -46,20 +43,14 @@ public class MyPlan extends Behaviour implements PlanBody {
 	public void action() {
 		log.info("Plan executing... counter " + counter);
 		counter++;
-	}
-
-	@Override
-	public boolean done() {
-		return counter >= 10;
-	}
 
-	@Override
-	public EndState getEndState() {
-		return done() ? EndState.SUCCESSFUL : null;
+		if (counter >= 10) {
+			setEndState(EndState.SUCCESSFUL);
+		}
 	}
 
 	@Override
-	public void init(PlanInstance planInstance) {
+	public void onStart() {
 		this.counter = 0;
 	}
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/subgoal/ParentPlan.java b/bdi-jade-test/src/bdi4jade/examples/subgoal/ParentPlan.java
index 3a12bc5..63f792b 100644
--- a/bdi-jade-test/src/bdi4jade/examples/subgoal/ParentPlan.java
+++ b/bdi-jade-test/src/bdi4jade/examples/subgoal/ParentPlan.java
@@ -22,49 +22,45 @@
 
 package bdi4jade.examples.subgoal;
 
-import jade.core.behaviours.Behaviour;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
  * 
  */
-public class ParentPlan extends Behaviour implements PlanBody {
+public class ParentPlan extends PlanBody {
 
 	private static final long serialVersionUID = -5432560989511973914L;
 
 	private int counter;
 	private Log log = LogFactory.getLog(this.getClass());
-	private PlanInstance planInstance;
 
 	@Override
 	public void action() {
 		if (counter == 0) {
-			this.planInstance.dispatchSubgoal(new Subgoal());
+			dispatchSubgoal(new Subgoal());
 		}
 		log.info("ParentPlan executing... counter " + counter);
 		counter++;
-	}
 
-	@Override
-	public boolean done() {
-		return counter >= 10;
+		if (counter >= 10) {
+			setEndState(EndState.FAILED);
+			log.info("Finishing ParentPlan.");
+		}
 	}
 
 	@Override
-	public EndState getEndState() {
-		return done() ? EndState.FAILED : null;
+	public int onEnd() {
+		log.info("ParentPlan ended.");
+		return super.onEnd();
 	}
-
+	
 	@Override
-	public void init(PlanInstance planInstance) {
-		this.planInstance = planInstance;
+	public void onStart() {
 		this.counter = 0;
 	}
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan1.java b/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan1.java
index a6eed63..6a2cd42 100644
--- a/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan1.java
+++ b/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan1.java
@@ -28,7 +28,7 @@ import java.util.Map;
 
 import bdi4jade.examples.template.MyAgentSoftgoals;
 import bdi4jade.examples.template.goal.MyGoal;
-import bdi4jade.plan.PlanContribution;
+import bdi4jade.softgoal.PlanContribution;
 import bdi4jade.softgoal.Softgoal;
 import bdi4jade.util.plan.SimplePlan;
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan1Body.java b/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan1Body.java
index 66c3f0c..ccb887c 100644
--- a/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan1Body.java
+++ b/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan1Body.java
@@ -22,37 +22,21 @@
 
 package bdi4jade.examples.template.plan;
 
-import jade.core.behaviours.OneShotBehaviour;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
  * 
  */
-public class MyPlan1Body extends OneShotBehaviour implements PlanBody {
+public class MyPlan1Body extends PlanBody {
 
 	private static final long serialVersionUID = -3947024373151941681L;
 
-	private EndState endState;
-
 	@Override
 	public void action() {
 		// TODO Auto-generated method stub
-		this.endState = EndState.SUCCESSFUL;
-	}
-
-	@Override
-	public EndState getEndState() {
-		// TODO Auto-generated method stub
-		return endState;
-	}
-
-	@Override
-	public void init(PlanInstance planInstance) {
-		// TODO Auto-generated method stub
-		this.endState = null;
+		setEndState(EndState.SUCCESSFUL);
 	}
 
 }
diff --git a/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan2.java b/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan2.java
index e1e4b8d..d7e1cf1 100644
--- a/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan2.java
+++ b/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan2.java
@@ -28,7 +28,7 @@ import java.util.Map;
 
 import bdi4jade.examples.template.MyAgentSoftgoals;
 import bdi4jade.examples.template.goal.MyGoal;
-import bdi4jade.plan.PlanContribution;
+import bdi4jade.softgoal.PlanContribution;
 import bdi4jade.softgoal.Softgoal;
 import bdi4jade.util.plan.SimplePlan;
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan2Body.java b/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan2Body.java
index 00e0d26..8041ea0 100644
--- a/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan2Body.java
+++ b/bdi-jade-test/src/bdi4jade/examples/template/plan/MyPlan2Body.java
@@ -22,37 +22,21 @@
 
 package bdi4jade.examples.template.plan;
 
-import jade.core.behaviours.OneShotBehaviour;
+import bdi4jade.plan.Plan.EndState;
 import bdi4jade.plan.PlanBody;
-import bdi4jade.plan.PlanInstance;
-import bdi4jade.plan.PlanInstance.EndState;
 
 /**
  * @author ingrid
  * 
  */
-public class MyPlan2Body extends OneShotBehaviour implements PlanBody {
+public class MyPlan2Body extends PlanBody {
 
 	private static final long serialVersionUID = -3947024373151941681L;
 
-	private EndState endState;
-
 	@Override
 	public void action() {
 		// TODO Auto-generated method stub
-		this.endState = EndState.SUCCESSFUL;
-	}
-
-	@Override
-	public EndState getEndState() {
-		// TODO Auto-generated method stub
-		return endState;
-	}
-
-	@Override
-	public void init(PlanInstance planInstance) {
-		// TODO Auto-generated method stub
-		this.endState = null;
+		setEndState(EndState.SUCCESSFUL);
 	}
 
 }