本文整理汇总了Java中jade.wrapper.AgentContainer类的典型用法代码示例。如果您正苦于以下问题:Java AgentContainer类的具体用法?Java AgentContainer怎么用?Java AgentContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AgentContainer类属于jade.wrapper包,在下文中一共展示了AgentContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getComboBoxModelContainer
import jade.wrapper.AgentContainer; //导入依赖的package包/类
private DefaultComboBoxModel<String> getComboBoxModelContainer() {
if (comboBoxModelContainer==null) {
comboBoxModelContainer = new DefaultComboBoxModel<>();
if (Application.getJadePlatform().isMainContainerRunning(false)==true) {
// --- Get the known container ------------
try {
comboBoxModelContainer.addElement(Application.getJadePlatform().getMainContainer().getContainerName());
for (AgentContainer container : Application.getJadePlatform().getAgentContainerList()) {
comboBoxModelContainer.addElement(container.getContainerName());
}
} catch (ControllerException e) {
e.printStackTrace();
}
} else {
// --- Just take the Main-Container -------
comboBoxModelContainer.addElement(jade.core.AgentContainer.MAIN_CONTAINER_NAME);
}
}
return comboBoxModelContainer;
}
示例2: main
import jade.wrapper.AgentContainer; //导入依赖的package包/类
public static void main(String[] args) {
Runtime rt = Runtime.instance();
// Exit the JVM when there are no more containers around
rt.setCloseVM(true);
// Create a default profile
Profile profile = new ProfileImpl("192.168.111.1", 8888, "main");
AgentContainer mainContainer = rt.createMainContainer(profile);
addStationToRuntime(rt);
addTransporterContainer(rt);
addCleanerContainer(rt);
addPainterContainer(rt);
AgentController rma = null;
try {
rma = mainContainer.createNewAgent("rma", "jade.tools.rma.rma", new Object[0]);
rma.start();
} catch (StaleProxyException e) {
e.printStackTrace();
}
}
示例3: main
import jade.wrapper.AgentContainer; //导入依赖的package包/类
public static void main(String[] args) throws StaleProxyException {
// Start a new JADE runtime system
Runtime.instance().setCloseVM(true);
Runtime rt = jade.core.Runtime.instance();
Properties props = new ExtendedProperties();
props.setProperty(Profile.GUI, "true");
props.setProperty(Profile.LOCAL_HOST, "172.16.0.83");
AgentContainer cc = rt.createMainContainer(new ProfileImpl(props));
// Start a FTPAgent
AgentController ftpAgent = cc.createNewAgent("ftp", "com.jools.jade.agent.FTPAgent",
new String[]{
"username",
"password",
"ftp.server.net"
}
);
ftpAgent.start();
}
示例4: getContainer
import jade.wrapper.AgentContainer; //导入依赖的package包/类
private static AgentContainer getContainer() throws Exception
{
if (container != null)
return container;
if (profile.getBooleanProperty(Profile.MAIN, true))
{
LOG.trace("Creating main container...");
container = Runtime.instance().createMainContainer(profile);
} else
{
LOG.trace("Creating peripheral agent container...");
container = Runtime.instance().createAgentContainer(profile);
}
if (container == null)
throw new Exception("Unable to create new agent platform");
LOG.trace("Initialized " + container.getContainerName());
return container;
}
示例5: agentTest
import jade.wrapper.AgentContainer; //导入依赖的package包/类
@Test
public void agentTest() throws Exception
{
final AgentContainer container = getContainer();
final String agName = "MyTestAgent";
final MySemanticAgent agObject = new MySemanticAgent();
LOG.trace("Adding new agent: " + agName + "...");
container.acceptNewAgent(agName, agObject);
while (agObject.getAgentState().getValue() != Agent.AP_DELETED)
{
LOG.trace("Waiting for " + agName + " (state: "
+ agObject.getAgentState() + ") to be killed via GUI...");
try
{
Thread.sleep(1000);
} catch (final InterruptedException ignore)
{
//
}
}
container.kill();
}
示例6: gettersAndSetters
import jade.wrapper.AgentContainer; //导入依赖的package包/类
@Test
public void gettersAndSetters(){
AID ambient = new AID("ambient", true);
Util.setAmbientAID(ambient);
assertEquals("ambient", Util.getAmbientAID().getLocalName());
AgentController ambientController = null;
Util.setAmbient(ambientController);
assertNull(Util.getAmbient());
AgentContainer container = new AgentContainer(null, null, "container");
Util.setSimulatorContainer(container);
assertEquals("container", Util.getSimulatorContainer().getName());
assertTrue(Util.getMainContainer().getName().endsWith("/JADE"));
}
示例7: setup
import jade.wrapper.AgentContainer; //导入依赖的package包/类
protected void setup() {
// listen to requestdummy
addBehaviour(new CyclicBehaviour(this) {
public void action() {
ACLMessage msg = receive();
if (msg != null) {
orders = msg.getContent().split(", ");
AgentContainer container = getContainerController();
try {
// TODO: Fix agent hash
orderAgent = container.createNewAgent(
"order:" + msg.hashCode(), "src.kiva.Order",
orders);
orderAgent.start();
} catch (StaleProxyException e1) {
e1.printStackTrace();
}
}
block();
}
});
}
示例8: startContainerWithArguments
import jade.wrapper.AgentContainer; //导入依赖的package包/类
/**
* Method which creates a new container, with the given command line arguments
*
* @param _args
* - arguments, as specified in the command line. The <code>-container</code> option is not mandatory
*/
@Deprecated
public void startContainerWithArguments(String _args)
{
String args = _args;
if(_args.indexOf("-container") == -1)
args = (new String("-container ")) + _args;
AgentContainer container = runJadeWithArguments(args);
try
{
containerList.put(container.getContainerName(), container);
} catch(ControllerException e)
{
e.printStackTrace();
}
}
示例9: runJadeWithArguments
import jade.wrapper.AgentContainer; //导入依赖的package包/类
/**
* Method which runs JADE with the specified arguments, which are equivalent to the arguments that JADE receives in the command line.
*
* @param args
* - arguments, as specified in the command line.
*/
@Deprecated
public static AgentContainer runJadeWithArguments(String args)
{
// decompose the args String into tokens:
Vector<String> argsVector = new Vector<String>();
String[] argsArray = new String[0];
StringTokenizer tokenizer = new StringTokenizer(args);
while(tokenizer.hasMoreTokens())
argsVector.addElement(tokenizer.nextToken());
// parse the vector of arguments:
Properties props = jade.Boot.parseCmdLineArgs(argsVector.toArray(argsArray));
ProfileImpl profile = new ProfileImpl(props);
// launch the main container:
// System.out.println("Launching a main-container..."+profile);
if(argsVector.contains(new String("-container")))
return Runtime.instance().createAgentContainer(profile);
return Runtime.instance().createMainContainer(profile);
}
示例10: getExecutionMode
import jade.wrapper.AgentContainer; //导入依赖的package包/类
/**
* Gets the execution mode from configuration.
* @return the execution mode from configuration
*/
public ExecutionMode getExecutionMode() {
ExecutionMode execMode = this.fileExecutionMode;
if (execMode==ExecutionMode.SERVER) {
// ------------------------------------------------------
// --- Does JADE run? -----------------------------------
// ------------------------------------------------------
AgentContainer mainContainer = Application.getJadePlatform().getMainContainer();
if (mainContainer!=null) {
// --------------------------------------------------
// --- JADE is running ------------------------------
// --------------------------------------------------
// --- Default: Running as Server [Slave] -----------
execMode = ExecutionMode.SERVER_SLAVE;
JadeUrlConfiguration masterConfigured = this.getJadeUrlConfigurationForMaster();
if (masterConfigured.isLocalhost()==true) {
// --- Compare to MainContainer address ---------
JadeUrlConfiguration platformRunning = new JadeUrlConfiguration(mainContainer.getPlatformName());
if (platformRunning.isEqualJadePlatform(masterConfigured)==true) {
// --- Running as Server [Master] -----------
execMode = ExecutionMode.SERVER_MASTER;
}
}
}
// ------------------------------------------------------
}
return execMode;
}
示例11: isAgentRunning
import jade.wrapper.AgentContainer; //导入依赖的package包/类
/**
* Checks, if the specified Agent is running (or not).
*
* @param localAgentName the agent name
* @return true, if the agent is running
*/
public boolean isAgentRunning(String localAgentName) {
// --- Check if agent is running in the main container ------
if (this.isAgentRunningInMainContainer(localAgentName)) return true;
// --- Check if agent is running in other container ---------
for (AgentContainer agentContainer : this.getAgentContainerList()) {
if (this.isAgentRunning(localAgentName, agentContainer)) return true;
}
return false;
}
示例12: getMainContainer
import jade.wrapper.AgentContainer; //导入依赖的package包/类
/**
* Returns the Jade main container.
* @return the agent container
*/
public AgentContainer getMainContainer() {
if (this.isMainContainerRunning()==false) {
return null;
}
return this.jadeMainContainer;
}
示例13: createAgentContainer
import jade.wrapper.AgentContainer; //导入依赖的package包/类
/**
* Adding an AgentContainer to the local platform.
*
* @param newContainerName the container name
* @return the agent container
*/
public AgentContainer createAgentContainer(String newContainerName) {
ProfileImpl pSub = this.getContainerProfile();
pSub.setParameter(Profile.CONTAINER_NAME, newContainerName);
pSub.setParameter(Profile.MAIN, (new Boolean(false)).toString());
pSub.setParameter(Profile.MTPS, null);
AgentContainer agentContainer = Runtime.instance().createAgentContainer(pSub);
this.getAgentContainerList().add(agentContainer);
return agentContainer;
}
示例14: getAgentContainerList
import jade.wrapper.AgentContainer; //导入依赖的package包/类
/**
* Returns the List of local agent container.
* @return the agent container local
*/
public ArrayList<AgentContainer> getAgentContainerList() {
if (agentContainerList==null) {
agentContainerList = new ArrayList<>();
}
return agentContainerList;
}
示例15: getContainer
import jade.wrapper.AgentContainer; //导入依赖的package包/类
/**
* Returns the {@link AgentContainer} given by it's name.
*
* @param containerNameSearch the container name search
* @return the agent container
*/
public AgentContainer getContainer(String containerNameSearch ) {
// --- If JADE is not already running -------------------
if (this.isMainContainerRunning()==false) {
return null;
}
// --- Searching for the 'Main-Container'? -------------
if (containerNameSearch.equals(this.mainContainerName)==true) {
return this.jadeMainContainer;
}
// --- Get the right container -------------------------
for (int i=0; i < this.getAgentContainerList().size(); i++) {
AgentContainer agentContainer = this.getAgentContainerList().get(i);
try {
String acName = agentContainer.getContainerName();
if (acName!=null && acName.equalsIgnoreCase(containerNameSearch)==true) {
return agentContainer;
}
} catch (ControllerException ex) {
ex.printStackTrace();
}
}
return null;
}