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

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

?? agent.java

?? JADE(JAVA Agent開發框架)是一個完全由JAVA語言開發的軟件,它簡化了多Agent系統的實現。
?? JAVA
?? 第 1 頁 / 共 5 頁
字號:
			if (!Thread.currentThread().equals(myThread)) {
				// If the state-change is forced from the outside, interrupt 
				// the agent thread to allow the state change to take place
				interruptThread();
			}
		}
	}
	
	public void restoreBufferedState() {
		changeStateTo(myBufferedLifeCycle);
	}
	
	/**
	 The ActiveLifeCycle handles different internal states (INITIATED, 
	 ACTIVE, WAITING, IDLE). This method switches between them.
	 */
	private void setActiveState(int newState) {
		synchronized (stateLock) {
			if (myLifeCycle == myActiveLifeCycle) {
				int oldState = myLifeCycle.getState();
				if (newState != oldState) {
					((ActiveLifeCycle) myLifeCycle).setState(newState);
					//#MIDP_EXCLUDE_BEGIN
					notifyChangedAgentState(oldState, newState);
					//#MIDP_EXCLUDE_END
				}
			}
			else {
				// A change state request arrived in the meanwhile. 
				// Let it take place.
				throw new Interrupted();
			}
		}
	}
	
	//#APIDOC_EXCLUDE_BEGIN
	/**
	 Read current agent state. This method can be used to query an
	 agent for its state from the outside.
	 @return the Agent Platform Life Cycle state this agent is currently in.
	 */
	public int getState() {
		return myLifeCycle.getState();
	}
	//#APIDOC_EXCLUDE_END
	
	
	//#MIDP_EXCLUDE_BEGIN
	public AgentState getAgentState() {
		return AgentState.getInstance(getState());
	}
	
	/**
	 This is only called by the NotificationService to provide the Introspector
	 agent with a snapshot of the behaviours currently loaded in the agent
	 */
	Scheduler getScheduler() {
		return myScheduler;
	}
	
	/**
	 This is only called by AgentContainerImpl
	 */
	MessageQueue getMessageQueue() {
		return msgQueue;
	}
	
	// For persistence service
	private void setMessageQueue(MessageQueue mq) {
		msgQueue = mq;
	}
	
	
	/////////////////////////////
	// Mobility related code
	/////////////////////////////
	private transient AgentMobilityHelper mobHelper;
	
	private void initMobHelper() throws ServiceException {
		if (mobHelper == null) {
			mobHelper = (AgentMobilityHelper) getHelper(AgentMobilityHelper.NAME);
			mobHelper.registerMovable(new Movable() {
				public void beforeMove() {
					Agent.this.beforeMove();
				}
				
				public void afterMove() {
					Agent.this.afterMove();
				}
				
				public void beforeClone() {
					Agent.this.beforeClone();
				}
				
				public void afterClone() {
					Agent.this.afterClone();
				}
			} );
		}
	}
	
	/**
	 Make this agent move to a remote location. This method
	 is intended to support agent mobility and is called either by the
	 Agent Platform or by the agent itself to start a migration process.
	 It should be noted that this method just changes the agent 
	 state to <code>AP_TRANSIT</code>. The actual migration takes
	 place asynchronously.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @param destination The <code>Location</code> to migrate to.
	 */
	public void doMove(Location destination) {
		// Do nothing if the mobility service is not installed
		try {
			initMobHelper();
			mobHelper.move(destination);
		}
		catch(ServiceException se) {
			// FIXME: Log a proper warning
			return;
		}
	}
	
	
	/**
	 Make this agent be cloned on another location. This method
	 is intended to support agent mobility and is called either by the
	 Agent Platform or by the agent itself to start a clonation process.
	 It should be noted that this method just changes the agent 
	 state to <code>AP_COPY</code>. The actual clonation takes
	 place asynchronously.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @param destination The <code>Location</code> where the copy agent will start.
	 @param newName The name that will be given to the copy agent.
	 */
	public void doClone(Location destination, String newName) {
		// Do nothing if the mobility service is not installed
		try {
			initMobHelper();
			mobHelper.clone(destination, newName);
		}
		catch(ServiceException se) {
			// FIXME: Log a proper warning
			return;
		}
	}  
	//#MIDP_EXCLUDE_END
	
	/**
	 Make a state transition from <em>active</em> or <em>waiting</em>
	 to <em>suspended</em> within Agent Platform Life Cycle; the
	 original agent state is saved and will be restored by a
	 <code>doActivate()</code> call. This method can be called from
	 the Agent Platform or from the agent iself and stops all agent
	 activities. Incoming messages for a suspended agent are buffered
	 by the Agent Platform and are delivered as soon as the agent
	 resumes. Calling <code>doSuspend()</code> on a suspended agent
	 has no effect.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @see jade.core.Agent#doActivate()
	 */
	public void doSuspend() {
		//#MIDP_EXCLUDE_BEGIN
		if (mySuspendedLifeCycle == null) {
			mySuspendedLifeCycle = new SuspendedLifeCycle();
		}
		changeStateTo(mySuspendedLifeCycle);
		//#MIDP_EXCLUDE_END
	}
	
	/**
	 Make a state transition from <em>suspended</em> to
	 <em>active</em> or <em>waiting</em> (whichever state the agent
	 was in when <code>doSuspend()</code> was called) within Agent
	 Platform Life Cycle. This method is called from the Agent
	 Platform and resumes agent execution. Calling
	 <code>doActivate()</code> when the agent is not suspended has no
	 effect.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @see jade.core.Agent#doSuspend()
	 */
	public void doActivate() {
		//#MIDP_EXCLUDE_BEGIN
		//doExecute();
		restoreBufferedState();
		//#MIDP_EXCLUDE_END
	}
	
	/**
	 Make a state transition from <em>active</em> to <em>waiting</em>
	 within Agent Platform Life Cycle. This method has only effect 
	 when called by the agent thread and causes the agent to
	 block, stopping all its activities until  
	 a message arrives or 	the
	 <code>doWake()</code> method is called. 
	 @see jade.core.Agent#doWake()
	 */
	public void doWait() {
		doWait(0);
	}
	
	/**
	 Make a state transition from <em>active</em> to <em>waiting</em>
	 within Agent Platform Life Cycle. This method adds a timeout to
	 the other <code>doWait()</code> version.
	 @param millis The timeout value, in milliseconds.
	 @see jade.core.Agent#doWait()
	 */
	public void doWait(long millis) {
		if (Thread.currentThread().equals(myThread)) {
			setActiveState(AP_WAITING);
			
			synchronized(msgQueue) {
				try {
					// Blocks on msgQueue monitor for a while
					waitOn(msgQueue, millis);
				}
				catch (InterruptedException ie) {
					if (myLifeCycle != myActiveLifeCycle && !terminating) {
						// Change state request from the outside
						throw new Interrupted();
					}
					else {
						// Spurious wake up. Just print a warning
						System.out.println("Agent "+getName()+" interrupted while waiting");
					}    			
				}
				setActiveState(AP_ACTIVE);
			}
		}
	}
	
	/**
	 Make a state transition from <em>waiting</em> to <em>active</em>
	 within Agent Platform Life Cycle. This method is called from
	 Agent Platform and resumes agent execution. Calling
	 <code>doWake()</code> when an agent is not waiting has no effect.
	 @see jade.core.Agent#doWait()
	 */
	public void doWake() {
		synchronized(stateLock) {
			int previous = myLifeCycle.getState();
			if((previous == AP_WAITING) || (previous == AP_IDLE)) {
				setActiveState(AP_ACTIVE);
			}
		}
		if(myLifeCycle.isMessageAware()) {
			activateAllBehaviours();
			synchronized(msgQueue) {
				msgQueue.notifyAll(); // Wakes up the embedded thread
			}
		}
	}
	
	/**
	 Make a state transition from <em>active</em>, <em>suspended</em>
	 or <em>waiting</em> to <em>deleted</em> state within Agent
	 Platform Life Cycle, thereby destroying the agent. This method
	 can be called either from the Agent Platform or from the agent
	 itself. Calling <code>doDelete()</code> on an already deleted
	 agent has no effect.
	 */
	public void doDelete() {
		if (myDeletedLifeCycle == null) {
			myDeletedLifeCycle = new DeletedLifeCycle();
		}
		changeStateTo(myDeletedLifeCycle);
	}
	
	// This is called only by the scheduler
	void idle() throws InterruptedException {
		setActiveState(AP_IDLE);
		// No need for synchronized block since this is only called by the 
		// scheduler in the synchronized schedule() method
		waitOn(myScheduler, 0);
		setActiveState(AP_ACTIVE);
	}
	
	//#MIDP_EXCLUDE_BEGIN
	/**
	 Write this agent to an output stream; this method can be used to
	 record a snapshot of the agent state on a file or to send it
	 through a network connection. Of course, the whole agent must
	 be serializable in order to be written successfully.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @param s The stream this agent will be sent to. The stream is
	 <em>not</em> closed on exit.
	 @exception IOException Thrown if some I/O error occurs during
	 writing.
	 @see jade.core.Agent#read(InputStream s)
	 */
	public void write(OutputStream s) throws IOException {
		ObjectOutput out = new ObjectOutputStream(s);
		out.writeUTF(myName);
		out.writeObject(this);
	}
	
	/**
	 Read a previously saved agent from an input stream and restarts
	 it under its former name. This method can realize some sort of
	 mobility through time, where an agent is saved, then destroyed
	 and then restarted from the saved copy.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @param s The stream the agent will be read from. The stream is
	 <em>not</em> closed on exit.
	 @exception IOException Thrown if some I/O error occurs during
	 stream reading.
	 @see jade.core.Agent#write(OutputStream s)
	 *
	 public static void read(InputStream s) throws IOException {
	 try {
	 ObjectInput in = new ObjectInputStream(s);
	 String name = in.readUTF();
	 Agent a = (Agent)in.readObject();
	 a.doStart(name);
	 }
	 catch(ClassNotFoundException cnfe) {
	 cnfe.printStackTrace();
	 }
	 }*/
	
	/**
	 Read a previously saved agent from an input stream and restarts
	 it under a different name. This method can realize agent cloning
	 through streams, where an agent is saved, then an exact copy of
	 it is restarted as a completely separated agent, with the same
	 state but with different identity and address.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @param s The stream the agent will be read from. The stream is
	 <em>not</em> closed on exit.
	 @param agentName The name of the new agent, copy of the saved
	 original one.
	 @exception IOException Thrown if some I/O error occurs during
	 stream reading.
	 @see jade.core.Agent#write(OutputStream s)
	 *
	 public static void read(InputStream s, String agentName) throws IOException {
	 try {
	 ObjectInput in = new ObjectInputStream(s);
	 String oldName = in.readUTF();
	 Agent a = (Agent)in.readObject();
	 a.doStart(agentName);
	 }
	 catch(ClassNotFoundException cnfe) {
	 cnfe.printStackTrace();
	 }
	 }*/
	
	/**
	 This method reads a previously saved agent, replacing the current
	 state of this agent with the one previously saved. The stream
	 must contain the saved state of <b>the same agent</b> that it is
	 trying to restore itself; that is, <em>both</em> the Java object
	 <em>and</em> the agent name must be the same.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @param s The input stream the agent state will be read from.
	 @exception IOException Thrown if some I/O error occurs during
	 stream reading.
	 <em>Note: This method is currently not implemented</em>
	 */
	public void restore(InputStream s) throws IOException {
		// FIXME: Not implemented
	}
	
	/**
	 This method should not be used by application code. Use the
	 same-named method of <code>jade.wrapper.Agent</code> instead.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @see jade.wrapper.Agent#putO2AObject(Object o, boolean blocking)
	 */
	public void putO2AObject(Object o, boolean blocking) throws InterruptedException {
		// Drop object on the floor if object-to-agent communication is
		// disabled.
		if(o2aQueue == null)
			return;
		
		CondVar cond = null;
		// the following block is synchronized because o2aQueue.add and o2aLocks.put must be
		// an atomic operation
		synchronized (o2aQueue) {
			// If the queue has a limited capacity and it is full, discard the
			// first element
			if((o2aQueueSize != 0) && (o2aQueue.size() == o2aQueueSize))
				o2aQueue.remove(0);
			
			o2aQueue.add(o);
			
			// If we are going to block, then activate behaviours after storing the CondVar object
			if(blocking) {
				cond = new CondVar();
				
				// Store lock for later, when getO2AObject will be called
				o2aLocks.put(o, cond);
			}
		} // end synchronization
		
		// Reactivate the agent. This method is synchronized on the scheduler
		activateAllBehaviours();
		if (blocking)
			// Sleep on the condition. This method is synchronized on the condvar
			cond.waitOn();
	}
	
	/**
	 This method picks an object (if present) from the internal
	 object-to-agent communication queue. In order for this method to
	 work, the agent must have declared its will to accept objects
	 from other software components running within its JVM. This can
	 be achieved by calling the
	 <code>jade.core.Agent.setEnabledO2ACommunication()</code> method.
	 If the retrieved object was originally inserted by an external
	 component using a blocking call, that call will return during the
	 execution of this method.
	 <br>
	 <b>NOT available in MIDP</b>
	 <br>
	 @return the first object in the queue, or <code>null</code> if
	 the queue is empty.
	 @see jade.wrapper.Agent#putO2AObject(Object o, boolean blocking)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品人人做| 91视频免费播放| 亚洲福利视频一区二区| 亚洲视频一区二区在线| 国产欧美日韩在线| 久久精品综合网| 国产午夜亚洲精品不卡| 国产免费观看久久| 国产精品色婷婷| 亚洲日本乱码在线观看| 亚洲精品国产成人久久av盗摄| 亚洲欧美偷拍三级| 亚洲成人tv网| 精品亚洲成av人在线观看| 精品制服美女久久| 成人一区在线观看| 在线免费亚洲电影| 欧美一卡二卡在线观看| 精品粉嫩超白一线天av| 国产亚洲人成网站| 一区二区三区中文字幕精品精品 | 中文乱码免费一区二区| 国产精品久久毛片av大全日韩| 国产精品久久久久久久久搜平片 | 91免费精品国自产拍在线不卡| 91极品视觉盛宴| 69p69国产精品| 久久久www成人免费无遮挡大片| 欧美激情综合五月色丁香 | 欧美电影在线免费观看| 精品免费日韩av| 亚洲色图制服诱惑| 日本不卡一区二区三区| 国产成人av一区二区| 色8久久精品久久久久久蜜| 欧美一卡二卡三卡四卡| 国产精品色哟哟| 日本v片在线高清不卡在线观看| 国产91精品精华液一区二区三区 | 国产亚洲欧美日韩俺去了| 一区二区三国产精华液| 国产在线一区二区综合免费视频| 97久久精品人人澡人人爽| 日韩一区二区三区视频在线观看| 亚洲日本免费电影| 久久www免费人成看片高清| 色嗨嗨av一区二区三区| 久久香蕉国产线看观看99| 亚洲一级二级三级| av在线这里只有精品| 日韩欧美中文字幕一区| 亚洲综合激情另类小说区| 国产a精品视频| 91精品国产91热久久久做人人| 亚洲日本在线观看| 国产尤物一区二区在线| 日韩欧美激情四射| 亚洲成av人片在线观看无码| 91免费版在线| 亚洲视频一二三区| kk眼镜猥琐国模调教系列一区二区| 欧美一区二区三区在| 亚洲在线视频免费观看| 91蝌蚪porny成人天涯| 久久精品一区四区| 国产乱一区二区| 欧美大黄免费观看| 麻豆高清免费国产一区| 欧美日本一区二区在线观看| 夜夜嗨av一区二区三区四季av| 成人免费高清视频| 国产精品乱人伦| 国产成人在线视频网站| 日本一区二区久久| 国产成+人+日韩+欧美+亚洲| 中文字幕第一区二区| 成人午夜碰碰视频| 中文字幕一区二区在线观看| 成人国产精品免费观看视频| 国产精品久久免费看| 成人午夜视频在线观看| 1区2区3区国产精品| 91免费看`日韩一区二区| 一区二区欧美在线观看| 欧美日韩免费视频| 日本在线不卡视频一二三区| 欧美一区二区精美| 国产做a爰片久久毛片| 欧美极品少妇xxxxⅹ高跟鞋| 91丨porny丨户外露出| 亚洲一区二区在线播放相泽| 欧美日韩精品一区视频| 美国十次综合导航| 国产视频一区不卡| av中文字幕不卡| 午夜精品福利在线| 久久久久久久国产精品影院| 不卡欧美aaaaa| 亚洲一区二区三区国产| 日韩美一区二区三区| 成人av影院在线| 亚洲风情在线资源站| 国产午夜精品在线观看| 欧美在线视频日韩| 国产精品一色哟哟哟| 亚洲免费成人av| 欧美成人精品1314www| 成人深夜视频在线观看| 天天综合色天天| 欧美国产精品中文字幕| 欧美日韩精品欧美日韩精品| 国模娜娜一区二区三区| 亚洲一区二区视频在线观看| 精品国产乱子伦一区| 色噜噜久久综合| 国产在线一区观看| 亚洲成人av电影在线| 日本一区二区在线不卡| 9191国产精品| 日本黄色一区二区| 国产一区二区免费看| 亚洲最新视频在线播放| 国产亚洲午夜高清国产拍精品| 欧美亚洲综合网| 粉嫩13p一区二区三区| 五月天亚洲婷婷| 亚洲欧美另类久久久精品2019| 久久综合久久久久88| 717成人午夜免费福利电影| 不卡一区二区中文字幕| 精品一区二区免费视频| 午夜影院久久久| 亚洲视频一区二区在线观看| 国产蜜臀97一区二区三区| 精品日韩欧美在线| 777精品伊人久久久久大香线蕉| 成人午夜碰碰视频| 国产裸体歌舞团一区二区| 日韩不卡一区二区| 亚洲v中文字幕| 亚洲久草在线视频| 亚洲视频一区二区在线观看| 国产三级精品在线| 久久久久久久久久久久久女国产乱| 777精品伊人久久久久大香线蕉| 欧美在线免费视屏| 色婷婷综合五月| 97se亚洲国产综合自在线观| 成人高清视频免费观看| 国产 日韩 欧美大片| 国产成人欧美日韩在线电影| 国产在线一区观看| 国产高清成人在线| 国产精品系列在线播放| 国产xxx精品视频大全| 国产成人三级在线观看| 国产不卡在线视频| 成人一区在线看| 一本色道a无线码一区v| 一本大道久久a久久精二百 | 午夜精品成人在线| 午夜精品福利一区二区三区av | 色婷婷综合久久久| 91免费看视频| 欧美乱熟臀69xxxxxx| 91精品国产欧美一区二区18| 精品少妇一区二区三区在线播放| 欧美mv日韩mv| 国产精品嫩草影院av蜜臀| 亚洲欧洲精品天堂一级 | 精品嫩草影院久久| 国产欧美日产一区| 亚洲视频中文字幕| 五月婷婷色综合| 国产真实精品久久二三区| 北条麻妃国产九九精品视频| 在线免费观看视频一区| 日韩一区二区在线观看视频| 久久视频一区二区| 亚洲另类春色校园小说| 日韩av网站免费在线| 国产精品91xxx| 欧美性一区二区| 亚洲精品一线二线三线无人区| 中文无字幕一区二区三区| 午夜精品久久久久久久| 国产精品一区久久久久| 欧美视频中文一区二区三区在线观看| 日韩片之四级片| 亚洲精品国产一区二区精华液 | 成人综合婷婷国产精品久久蜜臀| 91在线国内视频| 日韩一二三区视频| 国产精品久久久久久久蜜臀| 日本亚洲电影天堂| 91亚洲精品久久久蜜桃| 久久久综合精品| 日韩精品一二三区| 91蝌蚪porny| 中文成人综合网|