当前位置: 首页>>代码示例>>Java>>正文


Java Runtime.instance方法代码示例

本文整理汇总了Java中jade.core.Runtime.instance方法的典型用法代码示例。如果您正苦于以下问题:Java Runtime.instance方法的具体用法?Java Runtime.instance怎么用?Java Runtime.instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jade.core.Runtime的用法示例。


在下文中一共展示了Runtime.instance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import jade.core.Runtime; //导入方法依赖的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();
	}

}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:25,代码来源:MultiplePlatformsTest.java

示例2: testJade1

import jade.core.Runtime; //导入方法依赖的package包/类
/**
 * from: Luis Lezcano Airaldi <[email protected]> to:
 * [email protected] date: Sat, Jun 7, 2014 at 3:10 PM
 * 
 * Hello! It's very easy to use Jade as a library. Here's an example from a
 * small application I made:
 */
public void testJade1()
{
	// This is the important method. This launches the jade platform.
	final Runtime rt = Runtime.instance();

	final Profile profile = new ProfileImpl();

	// With the Profile you can set some options for the container
	profile.setParameter(Profile.PLATFORM_ID, "Platform Name");
	profile.setParameter(Profile.CONTAINER_NAME, "Container Name");

	// Create the Main Container
	final AgentContainer mainContainer = rt.createMainContainer(profile);
	final String agentName = "manager";
	final String agentType = "ia.main.AgentManager"; // FIXME
	final Object[] agentArgs = {};

	try
	{
		// Here I create an agent in the main container and start it.
		final AgentController ac = mainContainer.createNewAgent(agentName,
				agentType, agentArgs);
		ac.start();
	} catch (final StaleProxyException e)
	{
		LOG.error(String.format("Problem creating/starting Jade agent '%s'"
				+ " of type: %s with args: %s", agentName, agentType,
				Arrays.asList(agentArgs)), e);
	}
}
 
开发者ID:krevelen,项目名称:coala,代码行数:38,代码来源:JadeTest.java

示例3: action

import jade.core.Runtime; //导入方法依赖的package包/类
@Override
public void action() {
	sm.Log("Create Agent - start");
	Runtime rt = Runtime.instance();
	Profile p = new ProfileImpl();
	p.setParameter(Profile.MAIN_HOST, "localhost");
	p.setParameter(Profile.MAIN_PORT, "1099");
	p.setParameter(Profile.CONTAINER_NAME, "Main-Container");

	ContainerController cc = null;
	if (myAgent.getConfiguration().getClassifiersUseSameContainer()) {
		if (myAgent.getContainerController() == null)
			myAgent.setMainContainerController(rt.createAgentContainer(p));
		cc = myAgent.getContainerController();

	} else
		cc = rt.createAgentContainer(p);
	if (cc != null) {
		try {
			int agentId = myAgent.getNumberOfAgents() + 1;
			AgentController ac = cc.createNewAgent("Classifier" + agentId, "ddm.agents.ClassifierAgent", null);
			ac.start();
			myAgent.setNumberOfAgents(myAgent.getNumberOfAgents()+1);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	sm.Log("Create Agent - end");
}
 
开发者ID:JordiCorbilla,项目名称:DDM,代码行数:30,代码来源:CreateAgentBehaviour.java

示例4: launchPlatform

import jade.core.Runtime; //导入方法依赖的package包/类
@Override
public void launchPlatform() {
    logger.fine("Launching Jade Platform...");

    this.runtime = Runtime.instance();

    // TODO make this configurable
    Profile p = new ProfileImpl();
    p.setParameter(Profile.GUI, TRUE);
    p.setParameter(Profile.NO_MTP, TRUE);
    p.setParameter(Profile.PLATFORM_ID, PLATFORM_ID);
    p.setParameter(Profile.LOCAL_HOST, MAIN_HOST);
    p.setParameter(Profile.LOCAL_PORT, MAIN_PORT);
    p.setParameter(Profile.AGENTS, AGENTS);
    p.setParameter(Profile.SERVICES, SERVICES);

    this.mainContainer = this.runtime.createMainContainer(p);
    logger.fine("Main container launched");

    this.createdAgents = new HashMap<String, AgentController>();
    this.platformContainers = new HashMap<String, ContainerController>();
    this.platformContainers.put("Main-Container", mainContainer);

    this.createAgent(BEAST_MESSENGER,
            "es.upm.dit.gsi.beast.platform.jade.agent.MessengerAgent");

}
 
开发者ID:gsi-upm,项目名称:BeastTool,代码行数:28,代码来源:JadeConnector.java

示例5: main

import jade.core.Runtime; //导入方法依赖的package包/类
public static void main(String args[])
{
	// READ XML FILE
	
	log.trace("Hello World");
	
	// load the scenario
	
	WindowLayout.staticLayout = new WindowLayout(1200, 700, new LayoutIndications(10, 8)
		.indicateBar(BarPosition.LEFT, 70, 0)
		.indicateWindowType("agent", 4, 4)
		.indicateWindowType("system", 6, 4)
		, null);

	
	XMLTree scenarioTree = XMLParser.validateParse(schemaName, scenarioFileName);
	log.info(scenarioTree.toString());
	
	// do operations. e.g. find the list of agents to start in the first of the containers, and their type:
	// note! we suppose that the structure of the scenario XML tree is known
	
	// list of containers
	List<XMLNode> containers = scenarioTree.getRoot().getNodeIterator("initial").next().getNodes();
	//List<XMLNode> events = scenarioTree.getRoot().getNodeIterator("timeline").next().getNodes();
	
	// create the platform
	rt = Runtime.instance();
	/*****
	 * CREATE CONTAINERS AND AGENTS
	 */
	ContainerController mainController = createContainers(containers, rt);
	/****
	 * LOAD EVENTS (message)
	 */
	//loadEvent(events, mainController);
	Log.exitLogger(unitName);
}
 
开发者ID:tATAmI-Project,项目名称:tATAmI-PC,代码行数:38,代码来源:ScenarioLoadTest_NGA.java

示例6: start

import jade.core.Runtime; //导入方法依赖的package包/类
/**
 * Starts JADE.
 * @param showRMA set true, if you want also to start the RMA agent and its visualisation 
 * @param containerProfile the actual container Profile
 * @return true, if successful
 */
public boolean start(boolean showRMA, Profile containerProfile) {
	
	boolean startSucceed = false;		
	
	if (this.isMainContainerRunning()==false) {
		try {
			// --------------------------------------------------
			// --- In case of execution as Service, check -------
			// --- Master-URL and maybe delay the JADE start ----
			// --------------------------------------------------
			this.delayHeadlessServerStartByCheckingMasterURL();
			
			// --- Notify plugins for agent Start --------------- 
			this.notifyPluginsForStartMAS();
			
			// --- Check for valid plugin preconditions --------- 
			if (this.hasValidPreconditionsInPlugins()==false) {
				return false;
			}
			
			// --- Start Platform -------------------------------
			Runtime jadeRuntime = Runtime.instance();	
			jadeRuntime.invokeOnTermination(new Runnable() {
				public void run() {
					// --- terminate platform -------------------
					LoadMeasureThread.removeMonitoringTasksForAgents();
					jadeMainContainer = null;
					getAgentContainerList().clear();
					Application.setStatusJadeRunning(false);
					if (Application.getMainWindow()!=null){
						Application.getMainWindow().setSimulationReady2Start();
					}
					// --- Notify plugins for termination -------
					Platform.this.notifyPluginsForTerminatedMAS();
				}
			});
			// --- Start MainContainer --------------------------
			if (containerProfile!=null) {
				jadeMainContainer = jadeRuntime.createMainContainer(containerProfile);
			} else {
				jadeMainContainer = jadeRuntime.createMainContainer(this.getContainerProfile());
			}
			startSucceed = true;
			
		} catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
		
	} else {
		System.out.println( "JADE läuft bereits! => " + Runtime.instance().toString() );			
	}

	// --- Start the Application Background-Agents ---------------
	if (this.startBackgroundAgents(showRMA)==false) return false;
	
	Application.setStatusJadeRunning(true);
	return startSucceed;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:66,代码来源:Platform.java

示例7: init

import jade.core.Runtime; //导入方法依赖的package包/类
public void init( Properties params, AServProtocolManager manager ) throws AServException {
	int port = 8888;
	int debug = 0;
	Object args[] = new Object[2];
	
	//set up the manager as an argument to pass to the JADEFIPAAServiceAgent
	args[0]=manager;
	
	// set up the Parameters as an argument to pass to the JADEFIPAServiceAgent
	args[1]=params;
	
	if ( params.getProperty( "jade" ) != null )
		port = Integer.parseInt( params.getProperty( "jade" ) );
	if ( params.getProperty( "debug" ) != null )
	    debug = Integer.parseInt( params.getProperty( "debug" ) ) - 1;

	/**		
Properties props = new Properties();
	 **/
	try {
		// Get a hold on JADE runtime
		Runtime rt = Runtime.instance();

		// Exit the JVM when there are no more containers around
		rt.setCloseVM(true);

		/** Profile with no MTP( Message Transfer Protocol
	props.setProperty("nomtp", "true");
	Profile pMain = new ProfileImpl(props);
		 **/
		// create a default Profile
		Profile pMain = new ProfileImpl(null, port, null);

		if ( debug > 0 )
			System.out.println("Launching a whole in-process platform..."+pMain);
		mc = rt.createMainContainer(pMain);
		algagentcontroller = mc.createNewAgent("JadeFIPAAServiceAgent", JadeFIPAAServiceAgent.class.getName(), args);
		algagentcontroller.start();
	}
	catch(Exception e) {
		throw new AServException ( "Cannot launch Jade Server" , e );
	}
}
 
开发者ID:dozed,项目名称:align-api-project,代码行数:44,代码来源:JadeFIPAAServProfile.java


注:本文中的jade.core.Runtime.instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。