I run JADE embedded in a Java program, i.e. not with java jade.Boot ...
.
Now I wanted to stop the JADE system, but I have found no nice way to do that.
I can exit the whole program using System.exit(), but that's not what I want to do.
I tried several different things, and I succeeded stopping my agent behaviours, but a couple of Threads continue running: the AMS, the DF, a web server, the JADE Timer dispatcher, several Deliverer threads, etc.
This is how my current shutdown method looks like:
@Override
public void shutdown() {
// TODO This does not work yet..
try {
for (WeakReference<AgentController> acr : agents) {
AgentController ac = acr.get(); // jade.wrapper.AgentController
if ( ac != null ) ac.kill();
}
container.kill(); // jade.wrapper.AgentContainer
Runtime.instance().shutDown(); // jade.core.Runtime
} catch ( StaleProxyException e ) {
e.printStackTrace();
}
}
The reason I want to do that is that I have some JUnit tests for my agent system.
Any ideas how to accomplish that?