bdi4jade
Changes
bdi-jade/.classpath 11(+4 -7)
bdi-jade/lib/jade-4.3.2.jar 0(+0 -0)
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/belief/AbstractBelief.java 153(+153 -0)
bdi-jade/src/bdi4jade/belief/Belief.java 90(+7 -83)
bdi-jade/src/bdi4jade/belief/BeliefSet.java 25(+7 -18)
bdi-jade/src/bdi4jade/core/Capability.java 14(+14 -0)
bdi-jade/src/bdi4jade/plan/Plan.java 4(+2 -2)
bdi-jade-test/.classpath 11(+4 -7)
bdi-jade-test/APDescription.txt 1(+1 -0)
Details
bdi-jade/.classpath 11(+4 -7)
diff --git a/bdi-jade/.classpath b/bdi-jade/.classpath
index d08c055..cfaaa3e 100644
--- a/bdi-jade/.classpath
+++ b/bdi-jade/.classpath
@@ -3,12 +3,9 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="examples-src"/>
<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/commons-codec-1.3.jar"/>
- <classpathentry kind="lib" path="lib/commons-logging-1.0.4.jar"/>
- <classpathentry kind="lib" path="lib/http.jar"/>
- <classpathentry kind="lib" path="lib/iiop.jar"/>
- <classpathentry kind="lib" path="lib/jade.jar"/>
- <classpathentry kind="lib" path="lib/jadeTools.jar"/>
- <classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
+ <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="output" path="bin"/>
</classpath>
diff --git a/bdi-jade/.settings/org.eclipse.jdt.ui.prefs b/bdi-jade/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..a80706a
--- /dev/null
+++ b/bdi-jade/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">//----------------------------------------------------------------------------\r\n// Copyright (C) 2011 Ingrid Nunes\r\n// \r\n// This library is free software; you can redistribute it and/or\r\n// modify it under the terms of the GNU Lesser General Public\r\n// License as published by the Free Software Foundation; either\r\n// version 2.1 of the License, or (at your option) any later version.\r\n// \r\n// This library is distributed in the hope that it will be useful,\r\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r\n// Lesser General Public License for more details.\r\n// \r\n// You should have received a copy of the GNU Lesser General Public\r\n// License along with this library; if not, write to the Free Software\r\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r\n// \r\n// To contact the authors\:\r\n// http\://inf.ufrgs.br/~ingridnunes/bdi4jade/\r\n//\r\n//----------------------------------------------------------------------------\r\n</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/bdi-jade/lib/commons-logging-1.1.3.jar b/bdi-jade/lib/commons-logging-1.1.3.jar
new file mode 100644
index 0000000..ab51254
Binary files /dev/null and b/bdi-jade/lib/commons-logging-1.1.3.jar differ
bdi-jade/lib/jade-4.3.2.jar 0(+0 -0)
diff --git a/bdi-jade/lib/jade-4.3.2.jar b/bdi-jade/lib/jade-4.3.2.jar
new file mode 100644
index 0000000..23c3bec
Binary files /dev/null and b/bdi-jade/lib/jade-4.3.2.jar differ
bdi-jade/lib/log4j-api-2.0-rc1.jar 0(+0 -0)
diff --git a/bdi-jade/lib/log4j-api-2.0-rc1.jar b/bdi-jade/lib/log4j-api-2.0-rc1.jar
new file mode 100644
index 0000000..a8b9261
Binary files /dev/null and b/bdi-jade/lib/log4j-api-2.0-rc1.jar differ
bdi-jade/lib/log4j-core-2.0-rc1.jar 0(+0 -0)
diff --git a/bdi-jade/lib/log4j-core-2.0-rc1.jar b/bdi-jade/lib/log4j-core-2.0-rc1.jar
new file mode 100644
index 0000000..5a9f29a
Binary files /dev/null and b/bdi-jade/lib/log4j-core-2.0-rc1.jar differ
bdi-jade/src/bdi4jade/belief/AbstractBelief.java 153(+153 -0)
diff --git a/bdi-jade/src/bdi4jade/belief/AbstractBelief.java b/bdi-jade/src/bdi4jade/belief/AbstractBelief.java
new file mode 100644
index 0000000..8e79d77
--- /dev/null
+++ b/bdi-jade/src/bdi4jade/belief/AbstractBelief.java
@@ -0,0 +1,153 @@
+//----------------------------------------------------------------------------
+// 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.belief;
+
+import java.security.InvalidParameterException;
+import java.util.HashSet;
+import java.util.Set;
+
+import bdi4jade.core.BeliefBase;
+import bdi4jade.util.MetadataElementImpl;
+
+/**
+ * @author ingrid
+ *
+ */
+public abstract class AbstractBelief<T> extends MetadataElementImpl implements
+ Belief<T> {
+
+ private static final long serialVersionUID = 5098122115249071355L;
+
+ private final Set<BeliefBase> beliefBases;
+ protected final String name;
+
+ /**
+ * Initializes a belief with its name.
+ *
+ * @param name
+ * the belief name.
+ */
+ public AbstractBelief(String name) {
+ if (name == null)
+ throw new InvalidParameterException("Belief name must be not null.");
+ this.name = name;
+ this.beliefBases = new HashSet<BeliefBase>();
+ }
+
+ /**
+ * Initializes a belief with its name.
+ *
+ * @param name
+ * the belief name.
+ * @param value
+ * the belief initial value.
+ */
+ public AbstractBelief(String name, T value) {
+ this(name);
+ setValue(value);
+ }
+
+ /**
+ * Adds a belief base that contains this belief. The agent whose capability
+ * contains this belief in the belief base believes in this belief.
+ *
+ * @param beliefBase
+ * the belief base to be added.
+ */
+ public void addBeliefBase(BeliefBase beliefBase) {
+ this.beliefBases.add(beliefBase);
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public final boolean equals(Object obj) {
+ if (obj instanceof Belief<?>) {
+ Belief<?> b = (Belief<?>) obj;
+ return this.name.equals(b.getName());
+ }
+ return false;
+ }
+
+ /**
+ * @return the beliefBases
+ */
+ public Set<BeliefBase> getBeliefBases() {
+ return beliefBases;
+ }
+
+ /**
+ * Gets the name of the Belief.
+ *
+ * @return the belief name.
+ */
+ public final String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the current value of the Belief.
+ *
+ * @return the belief value.
+ */
+ public abstract T getValue();
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return this.name.hashCode();
+ }
+
+ /**
+ * Removes a belief base that does not contain this belief anymore. The
+ * agent whose capability does not contain this belief in the belief base
+ * does not believe in this belief anymore.
+ *
+ * @param beliefBases
+ * the belief base to be removed.
+ */
+ public void removeBeliefBase(BeliefBase beliefBases) {
+ this.beliefBases.remove(beliefBases);
+ }
+
+ /**
+ * Sets a new value to the belief.
+ *
+ * @param value
+ * the new value.
+ */
+ public abstract void setValue(T value);
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return new StringBuffer(name).append(" = ").append(getValue())
+ .toString();
+ }
+
+}
bdi-jade/src/bdi4jade/belief/Belief.java 90(+7 -83)
diff --git a/bdi-jade/src/bdi4jade/belief/Belief.java b/bdi-jade/src/bdi4jade/belief/Belief.java
index 93edc57..0a71eff 100644
--- a/bdi-jade/src/bdi4jade/belief/Belief.java
+++ b/bdi-jade/src/bdi4jade/belief/Belief.java
@@ -25,8 +25,6 @@ package bdi4jade.belief;
import jade.content.Concept;
import java.io.Serializable;
-import java.security.InvalidParameterException;
-import java.util.HashSet;
import java.util.Set;
import bdi4jade.core.BeliefBase;
@@ -38,39 +36,7 @@ import bdi4jade.util.MetadataElement;
*
* @author ingrid
*/
-public abstract class Belief<T> extends MetadataElement implements
- Serializable, Concept {
-
- private static final long serialVersionUID = 5098122115249071355L;
-
- private final Set<BeliefBase> beliefBases;
- protected final String name;
-
- /**
- * Initializes a belief with its name.
- *
- * @param name
- * the belief name.
- */
- public Belief(String name) {
- if (name == null)
- throw new InvalidParameterException("Belief name must be not null.");
- this.name = name;
- this.beliefBases = new HashSet<BeliefBase>();
- }
-
- /**
- * Initializes a belief with its name.
- *
- * @param name
- * the belief name.
- * @param value
- * the belief initial value.
- */
- public Belief(String name, T value) {
- this(name);
- setValue(value);
- }
+public interface Belief<T> extends MetadataElement, Serializable, Concept {
/**
* Adds a belief base that contains this belief. The agent whose capability
@@ -79,52 +45,21 @@ public abstract class Belief<T> extends MetadataElement implements
* @param beliefBase
* the belief base to be added.
*/
- public void addBeliefBase(BeliefBase beliefBase) {
- this.beliefBases.add(beliefBase);
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public final boolean equals(Object obj) {
- if (obj instanceof Belief<?>) {
- Belief<?> b = (Belief<?>) obj;
- return this.name.equals(b.getName());
- }
- return false;
- }
+ public void addBeliefBase(BeliefBase beliefBase);
/**
* @return the beliefBases
*/
- public Set<BeliefBase> getBeliefBases() {
- return beliefBases;
- }
+ public Set<BeliefBase> getBeliefBases();
- /**
- * Gets the name of the Belief.
- *
- * @return the belief name.
- */
- public final String getName() {
- return name;
- }
+ public String getName();
/**
* Gets the current value of the Belief.
*
* @return the belief value.
*/
- public abstract T getValue();
-
- /**
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return this.name.hashCode();
- }
+ public T getValue();
/**
* Removes a belief base that does not contain this belief anymore. The
@@ -134,9 +69,7 @@ public abstract class Belief<T> extends MetadataElement implements
* @param beliefBases
* the belief base to be removed.
*/
- public void removeBeliefBase(BeliefBase beliefBases) {
- this.beliefBases.remove(beliefBases);
- }
+ public void removeBeliefBase(BeliefBase beliefBase);
/**
* Sets a new value to the belief.
@@ -144,15 +77,6 @@ public abstract class Belief<T> extends MetadataElement implements
* @param value
* the new value.
*/
- public abstract void setValue(T value);
-
- /**
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return new StringBuffer(name).append(" = ").append(getValue())
- .toString();
- }
+ public void setValue(T value);
}
bdi-jade/src/bdi4jade/belief/BeliefSet.java 25(+7 -18)
diff --git a/bdi-jade/src/bdi4jade/belief/BeliefSet.java b/bdi-jade/src/bdi4jade/belief/BeliefSet.java
index 50e5c75..886c5cb 100644
--- a/bdi-jade/src/bdi4jade/belief/BeliefSet.java
+++ b/bdi-jade/src/bdi4jade/belief/BeliefSet.java
@@ -26,23 +26,12 @@ import java.util.Iterator;
import java.util.Set;
/**
- * This class represents a belief that has a set of values associated with it.
+ * This interface represents a belief that has a set of values associated with
+ * it.
*
* @author ingrid
*/
-public abstract class BeliefSet<T> extends Belief<Set<T>> {
-
- private static final long serialVersionUID = 8345025506647930L;
-
- /**
- * Creates a new belief set with the provided name.
- *
- * @param name
- * the name of this belief set.
- */
- public BeliefSet(String name) {
- super(name);
- }
+public interface BeliefSet<T> extends Belief<Set<T>> {
/**
* Adds a new value to this belief set.
@@ -50,7 +39,7 @@ public abstract class BeliefSet<T> extends Belief<Set<T>> {
* @param value
* the value to be added.
*/
- public abstract void addValue(T value);
+ public void addValue(T value);
/**
* Checks if this belief set has the provided value.
@@ -59,14 +48,14 @@ public abstract class BeliefSet<T> extends Belief<Set<T>> {
* the value to be tested.
* @return true if the belief set contains this value.
*/
- public abstract boolean hasValue(T value);
+ public boolean hasValue(T value);
/**
* Returns an iterator for this belief set.
*
* @return the iterator.
*/
- public abstract Iterator<T> iterator();
+ public Iterator<T> iterator();
/**
* Removes a value from this belief set.
@@ -75,6 +64,6 @@ public abstract class BeliefSet<T> extends Belief<Set<T>> {
* the value to be removed.
* @return true if the value was removed.
*/
- public abstract boolean removeValue(T value);
+ public boolean removeValue(T value);
}
diff --git a/bdi-jade/src/bdi4jade/belief/PersistentBelief.java b/bdi-jade/src/bdi4jade/belief/PersistentBelief.java
index 73580e1..b712f04 100644
--- a/bdi-jade/src/bdi4jade/belief/PersistentBelief.java
+++ b/bdi-jade/src/bdi4jade/belief/PersistentBelief.java
@@ -22,16 +22,11 @@
package bdi4jade.belief;
-import jade.content.Concept;
-
-import java.io.Serializable;
-
/**
* @author ingrid
*
*/
-public class PersistentBelief<T> extends Belief<T> implements Serializable,
- Concept {
+public class PersistentBelief<T> extends AbstractBelief<T> {
private static final long serialVersionUID = 2893517209462636003L;
@@ -48,13 +43,6 @@ public class PersistentBelief<T> extends Belief<T> implements Serializable,
}
/**
- * @see bdi4jade.belief.Belief#setValue(java.lang.Object)
- */
- public void setValue(T value) {
- // XXX PersistentBelief.setValue(T value)
- }
-
- /**
* @see bdi4jade.belief.Belief#getValue()
*/
@Override
@@ -63,4 +51,11 @@ public class PersistentBelief<T> extends Belief<T> implements Serializable,
return null;
}
+ /**
+ * @see bdi4jade.belief.Belief#setValue(java.lang.Object)
+ */
+ public void setValue(T value) {
+ // XXX PersistentBelief.setValue(T value)
+ }
+
}
diff --git a/bdi-jade/src/bdi4jade/belief/TransientBelief.java b/bdi-jade/src/bdi4jade/belief/TransientBelief.java
index 252d050..9ce8411 100644
--- a/bdi-jade/src/bdi4jade/belief/TransientBelief.java
+++ b/bdi-jade/src/bdi4jade/belief/TransientBelief.java
@@ -22,18 +22,13 @@
package bdi4jade.belief;
-import jade.content.Concept;
-
-import java.io.Serializable;
-
/**
* This class extends the {@link Belief} and represents a transient belief,
* which is not persisted in a permanent memory.
*
* @author ingrid
*/
-public class TransientBelief<T> extends Belief<T> implements Serializable,
- Concept {
+public class TransientBelief<T> extends AbstractBelief<T> {
private static final long serialVersionUID = 2893517209462636003L;
diff --git a/bdi-jade/src/bdi4jade/belief/TransientBeliefSet.java b/bdi-jade/src/bdi4jade/belief/TransientBeliefSet.java
index 75d697d..87046eb 100644
--- a/bdi-jade/src/bdi4jade/belief/TransientBeliefSet.java
+++ b/bdi-jade/src/bdi4jade/belief/TransientBeliefSet.java
@@ -27,26 +27,25 @@ import java.util.Iterator;
import java.util.Set;
/**
- * This class extends the {@link BeliefSet} and represents a transient belief
- * set, which is not persisted in a permanent memory.
+ * This class extends the {@link TransientBeliefSet} and implements
+ * {@link BeliefSet} and represents a transient belief set, which is not
+ * persisted in a permanent memory.
*
* @author ingrid
*/
-public class TransientBeliefSet<T> extends BeliefSet<T> {
+public class TransientBeliefSet<T> extends TransientBelief<Set<T>> implements
+ BeliefSet<T> {
private static final long serialVersionUID = 8345025506647930L;
- protected Set<T> values;
-
/**
- * Creates a transient belief set.
+ * Creates a new transient belief set with the provided name.
*
* @param name
- * the name of the belief set.
+ * the name of this belief set.
*/
public TransientBeliefSet(String name) {
- super(name);
- this.values = new HashSet<T>();
+ super(name, new HashSet<T>());
}
/**
@@ -58,58 +57,39 @@ public class TransientBeliefSet<T> extends BeliefSet<T> {
* the initial values of this belief set.
*/
public TransientBeliefSet(String name, Set<T> values) {
- super(name);
- this.values = values;
+ super(name, values);
}
/**
* @see bdi4jade.belief.BeliefSet#addValue(java.lang.Object)
*/
+ @Override
public void addValue(T value) {
- this.values.add(value);
+ this.value.add(value);
}
/**
- * @see bdi4jade.belief.Belief#getValue()
- */
- @Override
- public Set<T> getValue() {
- return values;
- };
-
- /**
* @see bdi4jade.belief.BeliefSet#hasValue(java.lang.Object)
*/
+ @Override
public boolean hasValue(T value) {
- return this.values.contains(value);
+ return this.value.contains(value);
}
/**
* @see bdi4jade.belief.BeliefSet#iterator()
*/
+ @Override
public Iterator<T> iterator() {
- return this.values.iterator();
+ return this.value.iterator();
}
/**
* @see bdi4jade.belief.BeliefSet#removeValue(java.lang.Object)
*/
+ @Override
public boolean removeValue(T value) {
- return this.values.remove(value);
- }
-
- /**
- * @see bdi4jade.belief.Belief#setValue(java.lang.Object)
- */
- public void setValue(Set<T> values) {
- this.values = values;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return this.values.toString();
+ return this.value.remove(value);
}
}
\ No newline at end of file
diff --git a/bdi-jade/src/bdi4jade/core/BDIAgent.java b/bdi-jade/src/bdi4jade/core/BDIAgent.java
index 8fd7171..e060953 100644
--- a/bdi-jade/src/bdi4jade/core/BDIAgent.java
+++ b/bdi-jade/src/bdi4jade/core/BDIAgent.java
@@ -201,7 +201,14 @@ public class BDIAgent extends Agent {
* Default constructor.
*/
public BDIAgent() {
- this.rootCapability = new Capability();
+ this(new Capability());
+ }
+
+ /**
+ * Default constructor.
+ */
+ public BDIAgent(Capability rootCapability) {
+ this.rootCapability = rootCapability;
this.intentions = new LinkedList<Intention>();
this.softgoals = new HashSet<Softgoal>();
this.bdiInterpreter = new BDIInterpreter(this);
bdi-jade/src/bdi4jade/core/Capability.java 14(+14 -0)
diff --git a/bdi-jade/src/bdi4jade/core/Capability.java b/bdi-jade/src/bdi4jade/core/Capability.java
index 6fd57d5..8cd179f 100644
--- a/bdi-jade/src/bdi4jade/core/Capability.java
+++ b/bdi-jade/src/bdi4jade/core/Capability.java
@@ -28,6 +28,9 @@ import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* This capability represents a component that aggregates the mental attitudes
* defined by the BDI architecture. It has a belief base with the associated
@@ -46,6 +49,7 @@ public class Capability implements Serializable {
protected Capability parent;
protected final PlanLibrary planLibrary;
private boolean start;
+ private final Log log;
/**
* Creates a new capability. It uses {@link BeliefBase} and
@@ -123,6 +127,9 @@ public class Capability implements Serializable {
*/
public Capability(String id, Capability parent, BeliefBase beliefBase,
PlanLibrary planLibrary) {
+ this.log = LogFactory.getLog(getClass());
+
+ // Id initialization
if (id == null) {
if (this.getClass().getCanonicalName() == null
|| Capability.class.equals(this.getClass())) {
@@ -134,14 +141,21 @@ public class Capability implements Serializable {
} else {
this.id = id;
}
+
+ // Setting up parent
this.children = new HashSet<>();
if (parent != null) {
parent.addChild(this);
}
+
+ // Initializing belief base
beliefBase.setCapability(this);
this.beliefBase = beliefBase;
+
+ // Initializing plan library
planLibrary.setCapability(this);
this.planLibrary = planLibrary;
+
this.start = false;
}
bdi-jade/src/bdi4jade/plan/Plan.java 4(+2 -2)
diff --git a/bdi-jade/src/bdi4jade/plan/Plan.java b/bdi-jade/src/bdi4jade/plan/Plan.java
index f6fd415..b57cea1 100644
--- a/bdi-jade/src/bdi4jade/plan/Plan.java
+++ b/bdi-jade/src/bdi4jade/plan/Plan.java
@@ -37,7 +37,7 @@ import bdi4jade.exception.PlanInstantiationException;
import bdi4jade.goal.Goal;
import bdi4jade.message.MessageGoal;
import bdi4jade.softgoal.Softgoal;
-import bdi4jade.util.MetadataElement;
+import bdi4jade.util.MetadataElementImpl;
/**
* This class represents the plan abstraction. It defines the goals that the
@@ -45,7 +45,7 @@ import bdi4jade.util.MetadataElement;
*
* @author ingrid
*/
-public abstract class Plan extends MetadataElement {
+public abstract class Plan extends MetadataElementImpl {
public enum DefaultMetadata {
diff --git a/bdi-jade/src/bdi4jade/util/MetadataElement.java b/bdi-jade/src/bdi4jade/util/MetadataElement.java
index 3c487e1..c9434cb 100644
--- a/bdi-jade/src/bdi4jade/util/MetadataElement.java
+++ b/bdi-jade/src/bdi4jade/util/MetadataElement.java
@@ -22,27 +22,18 @@
package bdi4jade.util;
-import java.util.HashMap;
import java.util.Map;
/**
* @author ingrid
*
*/
-public abstract class MetadataElement {
-
- protected Map<Object, Object> metadata;
-
- public MetadataElement() {
- this.metadata = new HashMap<>();
- }
+public interface MetadataElement {
/**
* @return the metadata
*/
- public Map<?, ?> getMetadata() {
- return metadata;
- }
+ public Map<?, ?> getMetadata();
/**
* Gets a value of a metadata.
@@ -51,9 +42,7 @@ public abstract class MetadataElement {
* the name of the metadata.
* @return the existing value of this metadata.
*/
- public Object getMetadata(Object name) {
- return this.metadata.get(name);
- }
+ public Object getMetadata(Object name);
/**
* Verifies if a metadata is associated with this element.
@@ -62,22 +51,18 @@ public abstract class MetadataElement {
* the name of the metadata.
* @return true if the element has this metadata.
*/
- public boolean hasMetadata(Object name) {
- return this.hasMetadata(name);
- }
+ public boolean hasMetadata(Object name);
/**
- * Put a metadata in this element. If it does not exists, it is added, and it
- * is update otherwise.
+ * Put a metadata in this element. If it does not exists, it is added, and
+ * it is update otherwise.
*
* @param name
* the name of the metadata.
* @param value
* the value associated with this metadata.
*/
- public void putMetadata(Object name, Object value) {
- this.metadata.put(name, value);
- }
+ public void putMetadata(Object name, Object value);
/**
* Removes a metadata of this element.
@@ -86,8 +71,6 @@ public abstract class MetadataElement {
* the name of the metadata.
* @return the existing value of this metadata.
*/
- public Object removeMetadata(Object name) {
- return this.metadata.remove(name);
- }
+ public Object removeMetadata(Object name);
}
diff --git a/bdi-jade/src/bdi4jade/util/MetadataElementImpl.java b/bdi-jade/src/bdi4jade/util/MetadataElementImpl.java
new file mode 100644
index 0000000..a65469c
--- /dev/null
+++ b/bdi-jade/src/bdi4jade/util/MetadataElementImpl.java
@@ -0,0 +1,98 @@
+//----------------------------------------------------------------------------
+// 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.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author ingrid
+ *
+ */
+public abstract class MetadataElementImpl implements MetadataElement {
+
+ protected Map<Object, Object> metadata;
+
+ public MetadataElementImpl() {
+ this.metadata = new HashMap<>();
+ }
+
+ /**
+ * @return the metadata
+ */
+ @Override
+ public Map<?, ?> getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * Gets a value of a metadata.
+ *
+ * @param name
+ * the name of the metadata.
+ * @return the existing value of this metadata.
+ */
+ @Override
+ public Object getMetadata(Object name) {
+ return this.metadata.get(name);
+ }
+
+ /**
+ * Verifies if a metadata is associated with this element.
+ *
+ * @param name
+ * the name of the metadata.
+ * @return true if the element has this metadata.
+ */
+ @Override
+ public boolean hasMetadata(Object name) {
+ return this.hasMetadata(name);
+ }
+
+ /**
+ * Put a metadata in this element. If it does not exists, it is added, and
+ * it is update otherwise.
+ *
+ * @param name
+ * the name of the metadata.
+ * @param value
+ * the value associated with this metadata.
+ */
+ @Override
+ public void putMetadata(Object name, Object value) {
+ this.metadata.put(name, value);
+ }
+
+ /**
+ * Removes a metadata of this element.
+ *
+ * @param name
+ * the name of the metadata.
+ * @return the existing value of this metadata.
+ */
+ @Override
+ public Object removeMetadata(Object name) {
+ return this.metadata.remove(name);
+ }
+
+}
bdi-jade-test/.classpath 11(+4 -7)
diff --git a/bdi-jade-test/.classpath b/bdi-jade-test/.classpath
index ce37146..e222681 100644
--- a/bdi-jade-test/.classpath
+++ b/bdi-jade-test/.classpath
@@ -3,12 +3,9 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/bdi-jade"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/commons-codec-1.3.jar"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/commons-logging-1.0.4.jar"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/http.jar"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/iiop.jar"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/jade.jar"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/jadeTools.jar"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/log4j-1.2.15.jar"/>
+ <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="output" path="bin"/>
</classpath>
bdi-jade-test/APDescription.txt 1(+1 -0)
diff --git a/bdi-jade-test/APDescription.txt b/bdi-jade-test/APDescription.txt
new file mode 100644
index 0000000..398983c
--- /dev/null
+++ b/bdi-jade-test/APDescription.txt
@@ -0,0 +1 @@
+( ap-description :name "192.168.0.2:1099/JADE" :ap-services (set ( ap-service :name fipa.mts.mtp.http.std :type fipa.mts.mtp.http.std :addresses (sequence http://ingrid-asus:7778/acc))))
diff --git a/bdi-jade-test/MTPs-Main-Container.txt b/bdi-jade-test/MTPs-Main-Container.txt
new file mode 100644
index 0000000..6b6c35d
--- /dev/null
+++ b/bdi-jade-test/MTPs-Main-Container.txt
@@ -0,0 +1 @@
+http://ingrid-asus:7778/acc
diff --git a/bdi-jade-test/src/bdi4jade/examples/AgentStarter.java b/bdi-jade-test/src/bdi4jade/examples/AgentStarter.java
index bb54f13..3e679f8 100644
--- a/bdi-jade-test/src/bdi4jade/examples/AgentStarter.java
+++ b/bdi-jade-test/src/bdi4jade/examples/AgentStarter.java
@@ -36,9 +36,6 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.log4j.PropertyConfigurator;
-
-import bdi4jade.examples.helloworld.HelloWorldAgent;
/**
* @author ingrid
@@ -50,17 +47,16 @@ public class AgentStarter {
static {
agents = new HashMap<String, Agent>();
- agents.put(HelloWorldAgent.class.getSimpleName(), new HelloWorldAgent());
- // agents.put(BDIAgent1.MY_NAME, new BDIAgent1());
- // agents.put(BDIAgent2.MY_NAME, new BDIAgent2());
+ // agents.put(HelloWorldAgent.class.getSimpleName(), new
+ // HelloWorldAgent());
+ agents.put(BDIAgent1.MY_NAME, new BDIAgent1());
+ 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 7de5919..fb4c0a5 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.blocksworld.BlocksWorldCapability;
+import bdi4jade.examples.ping.PingPongCapability;
/**
* @author ingrid
@@ -36,13 +36,12 @@ public class BDIAgent1 extends BDIAgent {
@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/planselection/ExperimentRunner.java b/bdi-jade-test/src/bdi4jade/examples/planselection/ExperimentRunner.java
index 390ef25..18bbc22 100644
--- a/bdi-jade-test/src/bdi4jade/examples/planselection/ExperimentRunner.java
+++ b/bdi-jade-test/src/bdi4jade/examples/planselection/ExperimentRunner.java
@@ -33,12 +33,10 @@ 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
@@ -61,8 +59,6 @@ public class ExperimentRunner implements GoalListener {
private final TransportationAgent transportationAgent;
public ExperimentRunner() {
- PropertyConfigurator.configure(AgentStarter.class
- .getResource("log4j.properties"));
this.log = LogFactory.getLog(this.getClass());
List<String> params = new ArrayList<String>();