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


Java Runtime类代码示例

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


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

示例1: isMainContainerRunning

import jade.core.Runtime; //导入依赖的package包/类
/**
 * Jade main container is running.
 *
 * @return true, if the Main-Container is running
 */
public boolean isMainContainerRunning () {
	boolean isRunning;		
	try {
		jadeMainContainer.getState();
		isRunning = true;
		
	} catch (Exception eMC) {
		isRunning = false; //	eMC.printStackTrace();	
		jadeMainContainer = null;
		try {
			Runtime.instance().shutDown();				
		} catch (Exception ex) { 
			//ex.printStackTrace();				
		}			
	}
	return isRunning;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:Platform.java

示例2: 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

示例3: main

import jade.core.Runtime; //导入依赖的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();
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:20,代码来源:App.java

示例4: getContainer

import jade.core.Runtime; //导入依赖的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;
}
 
开发者ID:krevelen,项目名称:coala,代码行数:22,代码来源:TestSemanticAgent.java

示例5: runJadeWithArguments

import jade.core.Runtime; //导入依赖的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);
}
 
开发者ID:tATAmI-Project,项目名称:tATAmI-PC,代码行数:30,代码来源:PCJadeInterface.java

示例6: createAgentContainer

import jade.core.Runtime; //导入依赖的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;		
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:16,代码来源:Platform.java

示例7: addStationToRuntime

import jade.core.Runtime; //导入依赖的package包/类
private static void addStationToRuntime(Runtime rt){
	ProfileImpl pContainer = new ProfileImpl("192.168.111.1", 8888, "stations");

	AgentContainer cont = rt.createAgentContainer(pContainer);
	
	try {
		cont.createNewAgent("CleaningFloor", "gseproject.passive.CleaningFloorAgent", null);
		cont.createNewAgent("PaintingFloor", "gseproject.passive.PaintingFloorAgent", null);
		cont.createNewAgent("SourcePalette", "gseproject.passive.SourcepaletteAgent", null);
		cont.createNewAgent("GoalPalette", "gseproject.passive.GoalpaletteAgent", null);
	} catch (StaleProxyException e1) {
		e1.printStackTrace();
	}
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:15,代码来源:MultiplePlatformsTest.java

示例8: addTransporterContainer

import jade.core.Runtime; //导入依赖的package包/类
private static void addTransporterContainer(Runtime rt){
	ProfileImpl pContainer = new ProfileImpl("192.168.111.1", 8888, "transporter");
	AgentContainer cont = rt.createAgentContainer(pContainer);
	try {
		cont.createNewAgent("Transporter", "gseproject.robot.RobotAgent", null);
	} catch (StaleProxyException e1) {
		e1.printStackTrace();
	}
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:10,代码来源:MultiplePlatformsTest.java

示例9: addCleanerContainer

import jade.core.Runtime; //导入依赖的package包/类
private static void addCleanerContainer(Runtime rt){
	ProfileImpl pContainer = new ProfileImpl("192.168.111.1", 8888, "cleaner");
	AgentContainer cont = rt.createAgentContainer(pContainer);
	try {
		cont.createNewAgent("Cleaner", "gseproject.robot.RobotAgent", null);
	} catch (StaleProxyException e1) {
		e1.printStackTrace();
	}
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:10,代码来源:MultiplePlatformsTest.java

示例10: addPainterContainer

import jade.core.Runtime; //导入依赖的package包/类
private static void addPainterContainer(Runtime rt){
	ProfileImpl pContainer = new ProfileImpl("192.168.111.1", 8888, "painter");
	AgentContainer cont = rt.createAgentContainer(pContainer);
	try {
		cont.createNewAgent("Painter", "gseproject.robot.RobotAgent", null);
	} catch (StaleProxyException e1) {
		e1.printStackTrace();
	}
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:10,代码来源:MultiplePlatformsTest.java

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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