亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? agent.java

?? JADE(JAVA Agent開發框架)是一個完全由JAVA語言開發的軟件,它簡化了多Agent系統的實現。
?? JAVA
?? 第 1 頁 / 共 5 頁
字號:
/*****************************************************************
 JADE - Java Agent DEvelopment Framework is a framework to develop 
 multi-agent systems in compliance with the FIPA specifications.
 Copyright (C) 2000 CSELT S.p.A. 
 
 GNU Lesser General Public License
 
 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, 
 version 2.1 of the License. 
 
 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.
 *****************************************************************/

package jade.core;

import java.io.IOException;
import java.io.InterruptedIOException;

import jade.util.leap.Serializable;
import jade.util.leap.Iterator;
import java.util.Hashtable;
import java.util.Enumeration;

import jade.core.behaviours.Behaviour;

import jade.lang.acl.*;

import jade.security.JADESecurityException;

//#MIDP_EXCLUDE_BEGIN
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

import jade.core.mobility.AgentMobilityHelper;
import jade.core.mobility.Movable;

import jade.util.leap.List;
import jade.util.leap.ArrayList;
import jade.util.leap.Map;
import jade.util.leap.HashMap;
//#MIDP_EXCLUDE_END

/*#MIDP_INCLUDE_BEGIN
 import javax.microedition.midlet.*;
 #MIDP_INCLUDE_END*/

/**
 The <code>Agent</code> class is the common superclass for user
 defined software agents. It provides methods to perform basic agent
 tasks, such as:
 <ul>
 <li> <b> Message passing using <code>ACLMessage</code> objects,
 both unicast and multicast with optional pattern matching. </b></li>
 <li> <b> Complete Agent Platform life cycle support, including
 starting, suspending and killing an agent. </b></li>
 <li> <b> Scheduling and execution of multiple concurrent activities. </b></li>
 </ul>
 
 Application programmers must write their own agents as
 <code>Agent</code> subclasses, adding specific behaviours as needed
 and exploiting <code>Agent</code> class capabilities.
 
 @author Giovanni Rimassa - Universita' di Parma
 @author Giovanni Caire - TILAB
 @version $Date: 2007-06-14 11:02:43 +0200 (gio, 14 giu 2007) $ $Revision: 5969 $
 */
public class Agent implements Runnable, Serializable 
//#APIDOC_EXCLUDE_BEGIN
, TimerListener 
//#APIDOC_EXCLUDE_END
{
	private static final long     serialVersionUID = 3487495895819000L;
	
	/**
	 Inner class Interrupted.
	 This class is used to handle change state requests that occur
	 in particular situations such as when the agent thread is 
	 blocked in the doWait() method.
	 */
	public static class Interrupted extends Error {
		public Interrupted() {
			super();
		}
	}  // END of inner class Interrupted
	
	
	/**
	 Inner class AssociationTB.
	 This class manages bidirectional associations between Timer and
	 Behaviour objects, using hash tables. This class is 
	 synchronized with the operations
	 carried out by the TimerDispatcher. It allows also to avoid a deadlock when:
	 1) A behaviour blocks for a very short time --> A Timer is added
	 to the TimerDispatcher
	 2) The Timer immediately expires and the TimerDispatcher try to 
	 restart the behaviour before the pair (b, t) is added to the 
	 pendingTimers of this agent.
	 */
	private class AssociationTB {
		private Hashtable BtoT = new Hashtable();
		private Hashtable TtoB = new Hashtable();
		
		public void clear() {
			synchronized (theDispatcher) {
				Enumeration e = timers();
				while (e.hasMoreElements()) {
					Timer t = (Timer) e.nextElement();
					theDispatcher.remove(t);
				}
				
				BtoT.clear();
				TtoB.clear();
				
				//#J2ME_EXCLUDE_BEGIN
				
				// For persistence service
				persistentPendingTimers.clear();
				
				//#J2ME_EXCLUDE_END
			} //end synch
		}
		
		public void addPair(Behaviour b, Timer t) {
			TBPair pair = new TBPair(Agent.this, t, b);
			addPair(pair);
		}
		
		public void addPair(TBPair pair) {
			synchronized (theDispatcher) {
				if(pair.getOwner() == null) {
					pair.setOwner(Agent.this);
				}
				
				pair.setTimer(theDispatcher.add(pair.getTimer()));
				TBPair old = (TBPair)BtoT.put(pair.getBehaviour(), pair);
				if(old != null) {
					theDispatcher.remove(old.getTimer());
					//#J2ME_EXCLUDE_BEGIN
					persistentPendingTimers.remove(old);
					//#J2ME_EXCLUDE_END
					TtoB.remove(old.getTimer());
				}
				// Note that timers added to the TimerDispatcher are unique --> there
				// can't be an old value to handle
				TtoB.put(pair.getTimer(), pair);
				
				//#J2ME_EXCLUDE_BEGIN
				// For persistence service
				persistentPendingTimers.add(pair);
				//#J2ME_EXCLUDE_END
			} //end synch
		}
		
		public void removeMapping(Behaviour b) {
			synchronized (theDispatcher) {
				TBPair pair = (TBPair)BtoT.remove(b);
				if(pair != null) {
					TtoB.remove(pair.getTimer());
					
					//#J2ME_EXCLUDE_BEGIN
					// For persistence service
					persistentPendingTimers.remove(pair);
					//#J2ME_EXCLUDE_END
					
					theDispatcher.remove(pair.getTimer());
				}
			} //end synch
		}
		
		
		public Timer getPeer(Behaviour b) {
			// this is not synchronized because BtoT is an Hashtable (that is already synch!)
			TBPair pair = (TBPair)BtoT.get(b);
			if(pair != null) {
				return pair.getTimer();
			}
			else {
				return null;
			}
		}
		
		public Behaviour getPeer(Timer t) {
			// this is not synchronized because BtoT is an Hashtable (that is already synch!)
			TBPair pair = (TBPair)TtoB.get(t);
			if(pair != null) {
				return pair.getBehaviour();
			}
			else {
				return null;
			}
		}
		
		private Enumeration timers() {
			return TtoB.keys();
		}
		
		
	} // End of inner class AssociationTB 
	
	/** Inner class TBPair
	 *
	 */
	private static class TBPair {
		
		public TBPair() {
			expirationTime = -1;
		}
		
		public TBPair(Agent a, Timer t, Behaviour b) {
			owner = a;
			myTimer = t;
			expirationTime = t.expirationTime();
			myBehaviour = b;
		}
		
		public void setTimer(Timer t) {
			myTimer = t;
		}
		
		public Timer getTimer() {
			return myTimer;
		}
		
		public Behaviour getBehaviour() {
			return myBehaviour;
		}
		
		public void setBehaviour(Behaviour b) {
			myBehaviour = b;
		}
		
		
		public Agent getOwner() {
			return owner;
		}
		
		public void setOwner(Agent o) {
			owner = o;
			createTimerIfNeeded();
		}
		
		public long getExpirationTime() {
			return expirationTime;
		}
		
		public void setExpirationTime(long when) {
			expirationTime = when;
			createTimerIfNeeded();
		}
		
		// If both the owner and the expiration time have been set,
		// but the Timer object is still null, create one
		private void createTimerIfNeeded() {
			if(myTimer == null) {
				if((owner != null) && (expirationTime > 0)) {
					myTimer = new Timer(expirationTime, owner);
				}
			}
		}  
		
		private Timer myTimer;
		private long expirationTime;
		private Behaviour myBehaviour;
		private Agent owner;
		
	} // End of inner class TBPair 
	
	
	//#MIDP_EXCLUDE_BEGIN
	/**
	 Inner class CondVar
	 A simple class for a boolean condition variable
	 */
	private static class CondVar {
		private boolean value = false;
		
		public synchronized void waitOn() throws InterruptedException {
			while(!value) {
				wait();
			}
		}
		
		public synchronized void set() {
			value = true;
			notifyAll();
		}
		
	} // End of inner class CondVar 
	//#MIDP_EXCLUDE_END
	
	
	//#APIDOC_EXCLUDE_BEGIN
	
	/**
	 Schedules a restart for a behaviour, after a certain amount of
	 time has passed.
	 @param b The behaviour to restart later.
	 @param millis The amount of time to wait before restarting
	 <code>b</code>.
	 @see jade.core.behaviours.Behaviour#block(long millis)
	 */
	public void restartLater(Behaviour b, long millis) {
		if (millis <= 0) 
			return;
		Timer t = new Timer(System.currentTimeMillis() + millis, this);
		pendingTimers.addPair(b, t);
	}
	
	/**
	 Restarts the behaviour associated with t. 
	 This method runs within the time-critical Timer Dispatcher thread and
	 is not intended to be called by users. It is defined public only because
	 is part of the <code>TimerListener</code> interface.
	 */
	public void doTimeOut(Timer t) {
		Behaviour b = null;
		// This synchronized block avoids that if a behaviour is blocked 
		// again just after pendingTimers.getPeer(t) is called, a new mapping
		// is added before the old one is removed --> The new mapping is 
		// removed instead of the old one.
		// In any case b.restart() must be called outside the synchronized
		// block to avoid a deadlock between the TimerDispatcher and the Scheduler.
		synchronized (theDispatcher) {
			b = pendingTimers.getPeer(t);
			if(b != null) {
				pendingTimers.removeMapping(b);
			}
		}
		if(b != null) {
			b.restart();
		}
		else {
			System.out.println("Warning: No mapping found for expired timer "+t.expirationTime());
		}
	}
	
	/**
	 Notifies this agent that one of its behaviours has been restarted
	 for some reason. This method clears any timer associated with
	 behaviour object <code>b</code>, and it is unneeded by
	 application level code. To explicitly schedule behaviours, use
	 <code>block()</code> and <code>restart()</code> methods.
	 @param b The behaviour object which was restarted.
	 @see jade.core.behaviours.Behaviour#restart()
	 */
	public void notifyRestarted(Behaviour b) {
		// Did this restart() cause the root behaviour to become runnable ?
		// If so, put the root behaviour back into the ready queue.
		Behaviour root = b.root();
		if(root.isRunnable()) {
			myScheduler.restart(root);
		}
	}

	public void removeTimer(Behaviour b) {
		// The mapping for b in general has already been removed in doTimeOut().
		// There is however a case related to ParallelBehaviours where 
		// notifyRestarted() is not called as a consequence of a timer
		// expiration --> doTimeOut() is not called in this case -->
		// We remove the mapping in any case.
		Timer t = pendingTimers.getPeer(b);
		if(t != null) {
			pendingTimers.removeMapping(b);
		}
	}
	
	
	/**
	 Out of band value for Agent Platform Life Cycle states.
	 */
	public static final int AP_MIN = 0;   // Hand-made type checking
	
	/**
	 Represents the <em>initiated</em> agent state.
	 */
	public static final int AP_INITIATED = 1;
	
	/**
	 Represents the <em>active</em> agent state.
	 */
	public static final int AP_ACTIVE = 2;
	
	/**
	 Represents the <em>idle</em> agent state.
	 */
	public static final int AP_IDLE = 3;
	
	/**
	 Represents the <em>suspended</em> agent state.
	 */
	public static final int AP_SUSPENDED = 4;
	
	/**
	 Represents the <em>waiting</em> agent state.
	 */
	public static final int AP_WAITING = 5;
	
	/**
	 Represents the <em>deleted</em> agent state.
	 */
	public static final int AP_DELETED = 6;
	
	
	/**
	 Out of band value for Agent Platform Life Cycle states.
	 */
	public static final int AP_MAX = 13;    // Hand-made type checking
	
	//#MIDP_EXCLUDE_BEGIN  
	
	/**
	 These constants represent the various Domain Life Cycle states
	 */
	
	/**
	 Out of band value for Domain Life Cycle states.
	 */
	public static final int D_MIN = 9;     // Hand-made type checking
	
	/**
	 Represents the <em>active</em> agent state.
	 */
	public static final int D_ACTIVE = 10;
	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一级淫片007| 午夜私人影院久久久久| 一区二区三区蜜桃| 狠狠色丁香久久婷婷综合_中| 91色porny| 国产免费成人在线视频| 蜜臀久久99精品久久久画质超高清| 波多野结衣精品在线| 久久久久国产一区二区三区四区| 亚洲va国产天堂va久久en| 91亚洲精品久久久蜜桃| 久久欧美一区二区| 久久精工是国产品牌吗| 欧美精品色综合| 一区二区三区欧美激情| 一本在线高清不卡dvd| 日本一区二区三区在线不卡| 国产精品自拍一区| 久久久亚洲精华液精华液精华液| 蜜臀a∨国产成人精品| 777奇米四色成人影色区| 亚洲成人激情社区| 欧美日韩你懂得| 亚洲一区二区三区在线看| 色综合中文字幕国产 | 久久这里只精品最新地址| 五月婷婷激情综合网| 欧美在线观看视频一区二区| 亚洲综合色噜噜狠狠| 欧美亚洲尤物久久| 亚洲一区免费观看| 欧美日韩国产一二三| 亚洲国产精品久久不卡毛片| 欧美日韩一二三区| 天天爽夜夜爽夜夜爽精品视频| 欧美三级日韩三级国产三级| 亚洲综合在线观看视频| 精品视频一区二区三区免费| 亚洲成av人影院在线观看网| 欧美色图第一页| 亚洲地区一二三色| 日韩女优视频免费观看| 国产在线视视频有精品| 国产精品欧美久久久久无广告 | 欧美视频精品在线观看| 香蕉久久一区二区不卡无毒影院| 欧美精品在线观看一区二区| 精品一区二区三区免费视频| 久久夜色精品国产噜噜av| 成人国产电影网| 亚洲人成网站色在线观看| 色屁屁一区二区| 日韩在线一二三区| 国产亚洲精品aa| 日本高清不卡视频| 日韩国产精品久久久| 久久久久88色偷偷免费| 国产成人精品亚洲日本在线桃色| 最新久久zyz资源站| 欧美精品aⅴ在线视频| 狠狠网亚洲精品| 亚洲欧美日韩中文播放| 欧美xxxx在线观看| 大胆欧美人体老妇| 日产欧产美韩系列久久99| 亚洲国产成人自拍| 欧美夫妻性生活| 成人午夜看片网址| 日日噜噜夜夜狠狠视频欧美人| 久久天天做天天爱综合色| 波多野结衣91| 久久精品国产99国产精品| 亚洲精品自拍动漫在线| 日韩欧美国产一二三区| 91网站最新网址| 国产尤物一区二区在线| 亚洲mv在线观看| 中文字幕精品在线不卡| 日韩午夜激情视频| 91同城在线观看| 国内精品久久久久影院薰衣草 | 8v天堂国产在线一区二区| 国产成+人+日韩+欧美+亚洲| 亚洲在线中文字幕| 国产精品情趣视频| 欧美电视剧在线看免费| 色呦呦国产精品| 国产99久久久国产精品| 五月激情六月综合| 亚洲女爱视频在线| 久久久久久久久久久电影| 678五月天丁香亚洲综合网| aaa欧美日韩| 国产盗摄精品一区二区三区在线| 蜜桃久久av一区| 五月婷婷综合在线| 亚洲愉拍自拍另类高清精品| 亚洲国产精品国自产拍av| 精品人在线二区三区| 91麻豆精品国产自产在线 | 国产精品视频在线看| 久久综合色8888| 日韩欧美亚洲国产精品字幕久久久| 色成人在线视频| 99在线精品免费| 国产99久久久国产精品免费看| 激情小说欧美图片| 精品一区在线看| 美国欧美日韩国产在线播放| 日日骚欧美日韩| 日韩影院在线观看| 日韩av一区二| 免费av网站大全久久| 日韩高清在线观看| 日日摸夜夜添夜夜添国产精品| 午夜精品福利在线| 日本欧美韩国一区三区| 美脚の诱脚舐め脚责91| 韩日av一区二区| 国产主播一区二区三区| 国产成人高清视频| 成人a级免费电影| 色综合久久中文综合久久牛| 色欧美乱欧美15图片| 欧美亚洲日本国产| 欧美精品久久99久久在免费线 | 欧美亚洲动漫精品| 欧美日韩国产中文| 欧美电影免费观看高清完整版在线| 日韩精品一区在线观看| 国产欧美日韩不卡免费| 亚洲女同一区二区| 奇米色一区二区| 国产精品一区在线观看乱码| 97久久超碰国产精品电影| 在线观看亚洲a| 欧美草草影院在线视频| 国产精品无人区| 亚洲午夜免费视频| 美国av一区二区| 岛国av在线一区| 欧美二区在线观看| 久久久久九九视频| 亚洲一区在线电影| 国产一区二区三区高清播放| 不卡在线视频中文字幕| 欧美老肥妇做.爰bbww| 久久精品夜夜夜夜久久| 亚洲欧洲综合另类| 久久99日本精品| 91黄色免费网站| 久久免费美女视频| 亚洲午夜久久久久久久久电影院 | 久久久久久日产精品| 一区二区三区日本| 国产一区二区三区久久久| 91久久久免费一区二区| 久久综合av免费| 丝袜美腿亚洲色图| 91视频免费看| 久久亚洲一区二区三区明星换脸| 亚洲激情第一区| 国产综合色在线视频区| 欧美老肥妇做.爰bbww| 国产精品国产精品国产专区不片| 天堂成人国产精品一区| 99在线热播精品免费| 久久久久久久综合狠狠综合| 香蕉乱码成人久久天堂爱免费| 成人av电影在线播放| 欧美va亚洲va| 日韩激情视频网站| 精品成人一区二区| 亚洲午夜一区二区三区| 91在线丨porny丨国产| 亚洲精品一区二区在线观看| 日韩高清电影一区| 欧美日韩一区成人| 亚洲乱码中文字幕| 99久久精品免费精品国产| 久久精品一区蜜桃臀影院| 久久se精品一区精品二区| 91精品国产91久久久久久最新毛片 | 日韩欧美在线影院| 亚洲电影在线免费观看| 日本韩国欧美在线| 亚洲精品中文字幕乱码三区| 99久久精品情趣| 国产精品美女久久久久久久| 久久成人18免费观看| 欧美mv日韩mv亚洲| 久久91精品国产91久久小草| 精品国产乱码久久久久久老虎 | 成人免费三级在线| 久久综合成人精品亚洲另类欧美 | 欧美私人免费视频| 亚洲精品va在线观看| 欧洲av在线精品| 亚洲一区二区三区四区五区黄 | 中文字幕国产一区|