⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aglet.java

📁 aglet的部分源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	/**	 * Handles the message form outside.	 * @param msg the message sent to the aglet	 * @return true if the message was handled. Returns false if the message	 * was not handled. If false is returned, the <tt>MessageNotHandled</tt> exception	 * is thrown in the <tt>FutureReply.getReply</tt> and <tt>AgletProxy.sendMessage</tt>	 * methods.	 * @see FutureReply#getReply	 * @see Message#sendReply	 * @see AgletProxy#sendMessage	 */	public boolean handleMessage(Message message) {		return false;	}	/**	 * Notifies all of waiting threads.	 * @exception IllegalMonitorStateException If the current thread	 * is not the owner of the monitor.	 * @see Aglet#notifyAllMessages	 * @see waitMessage	 * @see notifyMessage	 */	public void notifyAllMessages() {		getMessageManager().notifyAllMessages();	}	/**	 * Notifies a single waiting thread.	 * @exception IllegalMonitorStateException If the current thread	 * is not the owner of the monitor.	 * @see Aglet#notifyMessage	 * @see waitMessage	 * @see notifyAllMessages	 */	public void notifyMessage() {		getMessageManager().notifyMessage();	}	/**	 * Initializes the new aglet. This method is called only once	 * in the life cycle of an aglet. Override this method for custom	 * initialization of the aglet.	 * @param init the argument with which the aglet is initialized.	 * @see AgletContext#createAglet	 */	public void onCreation(Object init) {}	/**	 * Is called when an attempt is made to dispose of the aglet.	 * Subclasses may override this method to implement actions that	 * should be taken in response to a request for disposal.	 * @exception SecurityException if the request for disposal is rejected.	 * @see Aglet#dispose	 * @see AgletProxy#dispose	 */	public void onDisposing() {}	/**	 * Processes clone events occurring on this aglet by dispatching them	 * to any registered CloneListener objects.	 * @param ev the clone event	 */	protected void processCloneEvent(CloneEvent ev) {		if (cloneListener != null) {			switch (ev.getID()) {			case CloneEvent.CLONING:				cloneListener.onCloning(ev);				break;			case CloneEvent.CLONE:				cloneListener.onClone(ev);				break;			case CloneEvent.CLONED:				cloneListener.onCloned(ev);				break;			}		} 	}	/**	 * Processes mobility events occurring on this aglet by dispatching them	 * to any registered MobilityListener objects.	 * @param ev the mobility event	 */	protected void processMobilityEvent(MobilityEvent ev) {		if (mobilityListener != null) {			switch (ev.getID()) {			case MobilityEvent.DISPATCHING:				mobilityListener.onDispatching(ev);				break;			case MobilityEvent.REVERTING:				mobilityListener.onReverting(ev);				break;			case MobilityEvent.ARRIVAL:				mobilityListener.onArrival(ev);				break;			}		} 	}	/**	 * Processes persistency events occurring on this aglet by dispatching them	 * to any registered PersistencyListener objects.	 * @param ev the persistency event	 */	protected void processPersistencyEvent(PersistencyEvent ev) {		if (persistencyListener != null) {			switch (ev.getID()) {			case PersistencyEvent.DEACTIVATING:				persistencyListener.onDeactivating(ev);				break;			case PersistencyEvent.ACTIVATION:				persistencyListener.onActivation(ev);				break;			}		} 	}	/**	 * Removes the specified clone listener so it no longer receives clone	 * events.	 * @param l the clone listener	 */	synchronized final public void removeCloneListener(CloneListener l) {		if (cloneListener == l) {			cloneListener = null;		} else if (cloneListener instanceof AgletEventListener) {			((AgletEventListener)cloneListener).removeCloneListener(l);			if (((AgletEventListener)cloneListener).size() == 0) {				cloneListener = null;			} 		} 	}	/**	 * Removes the specified mobility listener so it no longer receives	 * mobility events.	 * @param l the mobility listener	 */	synchronized final public void removeMobilityListener(MobilityListener l) {		if (mobilityListener == l) {			mobilityListener = null;		} else if (mobilityListener instanceof AgletEventListener) {			((AgletEventListener)mobilityListener).removeMobilityListener(l);			if (((AgletEventListener)mobilityListener).size() == 0) {				mobilityListener = null;			} 		} 	}	/**	 * Removes the specified persistency listener so it no longer receives	 * persistency events.	 * @param l the persistency listener	 */	synchronized final public void removePersistencyListener(PersistencyListener l) {		if (persistencyListener == l) {			persistencyListener = null;		} else if (persistencyListener instanceof AgletEventListener) {			((AgletEventListener)persistencyListener)				.removePersistencyListener(l);			if (((AgletEventListener)persistencyListener).size() == 0) {				persistencyListener = null;			} 		} 	}	/**	 * Is the entry point for the aglet's own thread of execution.	 * This method is invoked upon a successful creation, dispatch,	 * retraction, or activation of the aglet.	 * @see Aglet#onCreation	 * @see CloneListener#onClone	 * @see MobilityListener#onArrival	 * @see PersistencyListener#onActivation	 */	public void run() {}	/**	 * Sets the protections: permission collection about	 * who can send what kind of messages to the aglet	 * @param protections collection of protections about who can send	 * what kind of messages to the aglet	 */	public void setProtections(PermissionCollection protections) {		_stub.setProtections(protections);	}	/**	 * Sets the proxy for the aglet. This cannot be set twice.	 * Called by the system.	 * @param proxy the proxy to set	 */	public synchronized final void setStub(AgletStub stub) {		if (_stub != null) {			throw new SecurityException();		} 		stub.setAglet(this);		_stub = stub;	}	/**	 * Sets the text of this Aglet. A way for the aglet to display	 * messages on the viewer window.	 * @param message the message.	 */	public final void setText(String text) {		_stub.setText(text);	}	/**	 * [Preliminary]	 * Save a snapshot of this aglet into a 2nd storage. The snapshot will	 * be activated only if the aglet is accidentally killed.	 * (because of the system clash for instance)	 * If one of dispose, dispatch and deactivate are invoked, this	 * snapshot will be removed from 2nd storate. This call doesn't fire	 * the persistency event, hence no lister is invoked.	 * @exception NotSerializableException if the entire aglet is not	 * serializable	 * @exception IOException if I/O failed	 */	public final void snapshot() throws IOException {		_stub.snapshot();	}	/**	 * Gets the aglet property indicated by the key.	 * @param key the name of the aglet property.	 * @return the value of the specified key.	 * public final String getProperty(String key) {	 * return _proxy._getProperty(key);	 * }	 */	/**	 * Gets the aglet property indicated by the key and default value.	 * @param key the name of the aglet property.	 * @param defValue the default value to use if this property is not set.	 * @return the value of the specified key.	 * public final String getProperty(String key, String defValue) {	 * return _proxy._getProperty(key, defValue);	 * }	 */	/**	 * Sets the aglet property indicated by the key and the value.	 * @param key the name of the aglet property.	 * @param value the value to put	 * public final void setProperty(String key, String value) {	 * _proxy._setProperty(key, value);	 * }	 */	/**	 * Enumerates all the property keys.	 * @return property key enumeration.	 * public final Enumeration getPropertyKeys() {	 * return _proxy._getPropertyKeys();	 * }	 */	/**	 * Subscribes to a named message.	 * @param name the message kind.	 */	public final void subscribeMessage(String name) {		_stub.subscribeMessage(name);	}	/**	 * <b>This is an experimental feature.</b>	 * <p>This is almost like <tt>deactivate(long duration)</tt>,	 * but there are some differences.	 * <ol>	 * <li>The object of the aglet remains at the memory.	 * <li>No event is notified, thus ContextListener and PersistencyListener	 * cannot know the suspend/activation.	 * </ol>	 * The aglet will be re-activated by the <tt>resume()</tt>.	 * The caller will need the "deactivate" permissoin.	 * 	 * @param duration duration of the aglet deactivating in milliseconds.	 * If this is 0, it will be activeted at the next startup time.	 * @exception AgletException if the aglet cannot be suspended.	 * @exception IllegalArgumentException if the minutes parameter is	 * negative.	 */	public final void suspend(long duration) 			throws AgletException, IllegalArgumentException {		_stub.suspend(duration);	}	/**	 * Unsubscribes from all message kinds.	 */	public final void unsubscribeAllMessages() {		_stub.unsubscribeAllMessages();	}	/**	 * Unsubscribes from a named message.	 * @param name the message kind.	 * @return true if the message kind was subscribed.	 */	public final boolean unsubscribeMessage(String name) {		return _stub.unsubscribeMessage(name);	}	/**	 * Waits until it is notified.	 * @exception IllegalMonitorStateException If the current thread	 * is not the owner of the monitor.	 * @see MessageManager#waitMessage	 * @see notifyMessage	 * @see notifyAllMessages	 */	public void waitMessage() {		getMessageManager().waitMessage();	}	/**	 * Waits until it is notified or the timeout expires	 * @param timeout the maximum value to wait in milliseconds	 * @exception IllegalMonitorStateException If the current thread	 * is not the owner of the monitor.	 * @see MessageManager#waitMessage	 * @see notifyMessage	 * @see notifyAllMessages	 */	public void waitMessage(long timeout) {		getMessageManager().waitMessage(timeout);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -