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

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

?? agent.java

?? java實現的P2P多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
import jade.util.leap.Properties;

/*#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-11-28 12:56:47 +0100 (mer, 28 nov 2007) $ $Revision: 6010 $
 */
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一区二区三区免费野_久草精品视频
亚洲视频在线观看三级| 成人动漫av在线| 国产91在线观看丝袜| 欧美私人免费视频| 国产精品麻豆一区二区 | 久久国产免费看| 97久久精品人人做人人爽50路| 这里只有精品视频在线观看| 中文字幕日韩一区| 国产精品亚洲第一| 日韩视频一区二区三区| 亚洲精品v日韩精品| 国产传媒欧美日韩成人| 精品国产乱码久久久久久夜甘婷婷 | 中文字幕欧美激情| 久久精品国产99国产| 精品国产免费久久 | 免费成人美女在线观看.| 色综合天天在线| 欧美激情一区二区三区蜜桃视频| 免费一级片91| 欧美一区二区福利视频| 午夜视频在线观看一区二区| 欧美性色黄大片| 亚洲愉拍自拍另类高清精品| 91色在线porny| 中文字幕亚洲不卡| 一本大道久久a久久精品综合| 日本一区二区电影| 成人avav影音| 日韩美女精品在线| 色综合色狠狠天天综合色| 中文字幕一区二区三区精华液 | 国产v综合v亚洲欧| 久久久久久久综合| 粉嫩av一区二区三区在线播放| 久久亚洲春色中文字幕久久久| 加勒比av一区二区| 欧美精品一区二区久久久| 久久精品国产99国产精品| 日韩精品专区在线影院观看| 美女视频网站久久| 久久―日本道色综合久久| 欧美精品一卡二卡| 五月婷婷综合网| 日韩欧美亚洲一区二区| 久久9热精品视频| 日本一区二区免费在线| aaa亚洲精品| 亚洲大片精品永久免费| 日韩欧美成人一区| 不卡的电影网站| 亚洲国产日韩精品| 欧美一区二区三区免费视频| 激情综合亚洲精品| 亚洲天堂a在线| 欧美日韩精品高清| 国产一区视频网站| 亚洲最大色网站| 欧美高清一级片在线| 国产乱码精品1区2区3区| 亚洲免费视频成人| 日韩午夜在线观看| 91蜜桃网址入口| 日本不卡的三区四区五区| 国产欧美日韩精品一区| 99久久综合精品| 日本最新不卡在线| 中文字幕 久热精品 视频在线| 色www精品视频在线观看| 日本午夜精品一区二区三区电影| 久久久青草青青国产亚洲免观| 一本到不卡精品视频在线观看| 裸体健美xxxx欧美裸体表演| 中文字幕中文字幕一区二区| 日韩精品中文字幕一区二区三区| 国产一区二区网址| 亚洲成人av电影在线| 国产亚洲一区二区三区| 欧美精品黑人性xxxx| 成人一级片在线观看| 日韩和欧美一区二区| 中文字幕日韩欧美一区二区三区| 欧美日高清视频| 99久久国产综合精品麻豆| 免费在线视频一区| 一区二区三区四区国产精品| 久久精品亚洲国产奇米99| 8x福利精品第一导航| 91免费国产在线| 成人黄色小视频| 久草这里只有精品视频| 水野朝阳av一区二区三区| 国产精品久久久久精k8 | 欧美日韩亚洲丝袜制服| 成人手机电影网| 黑人巨大精品欧美黑白配亚洲| 日韩中文字幕1| 亚洲国产成人av| 日韩美女精品在线| 国产精品视频你懂的| 国产色产综合色产在线视频| 日韩美女一区二区三区| 欧美精品日日鲁夜夜添| 欧美日韩在线不卡| 欧美这里有精品| 日本电影亚洲天堂一区| 91在线无精精品入口| caoporn国产精品| 成人午夜精品在线| 国产成人精品亚洲777人妖| 国产精品综合二区| 国内精品久久久久影院色| 精品一区二区国语对白| 老司机精品视频导航| 久久99精品一区二区三区三区| 日韩va亚洲va欧美va久久| 日韩av网站免费在线| 五月激情丁香一区二区三区| 亚洲成人av中文| 麻豆精品视频在线观看视频| 蜜桃精品视频在线| 国精产品一区一区三区mba视频 | 午夜久久久影院| 午夜视频在线观看一区二区| 日韩和欧美的一区| 狠狠狠色丁香婷婷综合久久五月| 国产精品一区一区| 波多野结衣中文字幕一区| 91啪在线观看| 91精品国模一区二区三区| 日韩免费高清av| 国产精品素人视频| 一区二区激情小说| 日韩成人一级片| 国产91高潮流白浆在线麻豆| 成人在线一区二区三区| 99久久免费精品| 欧美久久久影院| 精品少妇一区二区三区在线播放 | 久久精品av麻豆的观看方式| 国产一区二区视频在线| 成人综合日日夜夜| 色婷婷亚洲一区二区三区| 欧美高清激情brazzers| 欧美成人a视频| 亚洲欧洲国产日韩| 性欧美大战久久久久久久久| 精品一区二区精品| 日本黄色一区二区| 精品国产91洋老外米糕| 亚洲欧洲99久久| 日韩成人免费在线| 99热99精品| 2021久久国产精品不只是精品| 18成人在线观看| 欧美丝袜自拍制服另类| 日韩精品一区二区在线| 亚洲欧美怡红院| 精品中文字幕一区二区| 色呦呦国产精品| 欧美精品一区二区蜜臀亚洲| 一区二区三区精密机械公司| 九九视频精品免费| 欧美特级限制片免费在线观看| 国产欧美日韩三区| 老司机精品视频导航| 在线一区二区三区做爰视频网站| 久久综合色8888| 亚洲1区2区3区4区| 一本色道综合亚洲| 国产精品网曝门| 国产一区二区三区久久久| 欧美肥大bbwbbw高潮| ㊣最新国产の精品bt伙计久久| 久久精品国产免费| 欧美精品在线观看播放| 亚洲一区av在线| 91在线播放网址| 国产精品乱人伦中文| 国产综合久久久久久鬼色| 日韩一区二区中文字幕| 亚洲一区免费视频| 91免费精品国自产拍在线不卡| 国产女主播在线一区二区| 久久99在线观看| 日韩欧美中文一区| 日本不卡免费在线视频| 欧美日韩精品是欧美日韩精品| 亚洲综合一区二区精品导航| www.日韩大片| 国产精品久久毛片| 成人综合婷婷国产精品久久免费| 久久中文字幕电影| 黑人精品欧美一区二区蜜桃 | 欧美日韩国产高清一区二区 | 久久爱另类一区二区小说| 欧美一区二区大片| 美女视频黄免费的久久| 精品福利av导航|