Class aglet.Aglet
All Packages Class Hierarchy This Package Previous Next Index
Class aglet.Aglet
java.lang.Object
|
+----aglet.Aglet
- public class Aglet
- extends Object
- implements Serializable
The Aglet class is the abstract base class for aglets. Use this
class to create your own personalized aglets.
-
ACTIVE
- State of Aglet.
-
INACTIVE
-
-
MAJOR_VERSION
-
-
MINOR_VERSION
-
-
Aglet()
- Constructs an uninitialized aglet.
-
addCloneListener(CloneListener)
- Adds the specified clone listener to receive clone events
from this aglet
-
addMobilityListener(MobilityListener)
- Adds the specified mobility listener to receive mobility events
from this aglet
-
addPersistencyListener(PersistencyListener)
- Adds the specified persistency listener to receive persistency events
from this aglet
-
clone()
- Clones the aglet and the proxy that holds the aglet.
-
deactivate(long)
- Deactivates the aglet.
-
dispatch(URL)
- Dispatches the aglet to the location (host) specified by the
destination argument.
-
dispose()
- Destroys and removes the aglet from its current aglet context.
-
exitMonitor()
- Exits the current monitor.
-
getAgletContext()
- Gets the context in which the aglet is currently executing.
-
getAgletID()
- Returns the id of this aglet.
-
getAgletInfo()
- Gets the info object of this aglet
-
getAudioData(URL)
- Gets an audio data
-
getCodeBase()
- Gets the code base URL of this aglet
-
getIdentifier()
- Returns the identity of this aglet.
-
getImage(URL)
- Gets an image
-
getImage(URL, String)
- Gets an image
-
getMessageManager()
- Gets the message manager.
-
getText()
- Gets the message line of this Aglet.
-
handleMessage(Message)
- Handles the message form outside.
-
notifyAllMessages()
- Notifies all of waiting threads.
-
notifyMessage()
- Notifies a single waiting thread.
-
onCreation(Object)
- Initializes the new aglet.
-
onDisposing()
- Is called when an attempt is made to dispose of the aglet.
-
removeCloneListener(CloneListener)
- Removes the specified clone listener so it no longer receives clone
events
-
removeMobilityListener(MobilityListener)
- Removes the specified mobility listener so it no longer receives
mobility events
-
removePersistencyListener(PersistencyListener)
- Removes the specified persistency listener so it no longer receives
persistency events
-
run()
- Is the entry point for the aglet's own thread of execution.
-
setStub(AgletStub)
- Sets the proxy for the aglet.
-
setText(String)
- Sets the text of this Aglet.
-
snapshot()
- [Preliminary]
Save a snapshot of this aglet into a 2nd storage.
-
subscribeMessage(String)
- Subscribes to a named message.
-
unsubscribeAllMessages()
- Unsubscribes from all message kinds.
-
unsubscribeMessage(String)
- Unsubscribes from a named message.
-
waitMessage()
- Waits until it is notified.
-
waitMessage(long)
- Waits until it is notified or the timeout expires
MAJOR_VERSION
public final static short MAJOR_VERSION
MINOR_VERSION
public final static short MINOR_VERSION
ACTIVE
public final static int ACTIVE
- State of Aglet.
- See Also:
- getAgletProxies
INACTIVE
public final static int INACTIVE
Aglet
protected Aglet()
- Constructs an uninitialized aglet. This method is called only
once in the life cycle of an aglet. As a rule, you should never
override this constructor. Instead, you should override
onCreation() to initialize the aglet upon creation.
- See Also:
- onCreation
clone
public final Object clone() throws CloneNotSupportedException
- Clones the aglet and the proxy that holds the aglet. Notice that
it is the cloned aglet proxy which is returned by this method.
- Returns:
- the cloned proxy.
- Throws: CloneNotSupportedException
- when the cloning fails.
- Overrides:
- clone in class Object
- See Also:
- onCloning, onClone
dispatch
public final void dispatch(URL destination) throws IOException, RequestRefusedException
- Dispatches the aglet to the location (host) specified by the
destination argument.
- Parameters:
- destination - dispatch destination.
- Throws: ServerNotFoundException
- if the server could not be found.
- Throws: UnknownHostException
- if the host given in the URL does not
exist.
- Throws: RequestRefusedException
- if the remote server refused the
dispatch request.
- Throws: ServerNotFoundException
- if the the destination is
unavailable
- Throws: NotSerializableException
- if the entire aglet is not
serializable
- See Also:
- onDispatching, onArrival
dispose
public final void dispose()
- Destroys and removes the aglet from its current aglet context.
A successful invocation of this method will kill all threads
created by the given aglet.
- See Also:
- onDisposing
deactivate
public final void deactivate(long duration) throws IOException
- Deactivates the aglet. The aglet will temporarily be stopped and
removed from its current context. It will return to the context and
resume execution after the specified period has elapsed.
- Parameters:
- duration - deactivation period specified in milliseconds
- Throws: NotSerializableException
- if the entire aglet is not
serializable
- Throws: IOException
- if I/O failed
- Throws: IllegalArgumentException
- if the argument is negative.
snapshot
public final void snapshot() throws IOException
- [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.
- Throws: NotSerializableException
- if the entire aglet is not
serializable
- Throws: IOException
- if I/O failed
run
public void run()
- 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 Also:
- onCreation, onClone, onArrival, onActivation
onCreation
public void onCreation(Object init)
- 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.
- Parameters:
- init - the argument with which the aglet is initialized.
- See Also:
- createAglet
addCloneListener
public final void addCloneListener(CloneListener listener)
- Adds the specified clone listener to receive clone events
from this aglet
- Parameters:
- listener - the mobility listener
addMobilityListener
public final void addMobilityListener(MobilityListener listener)
- Adds the specified mobility listener to receive mobility events
from this aglet
- Parameters:
- listener - the mobility listener
addPersistencyListener
public final void addPersistencyListener(PersistencyListener listener)
- Adds the specified persistency listener to receive persistency events
from this aglet
- Parameters:
- listener - the persistency listener
removeCloneListener
public final void removeCloneListener(CloneListener l)
- Removes the specified clone listener so it no longer receives clone
events
- Parameters:
- l - the clone listener
removeMobilityListener
public final void removeMobilityListener(MobilityListener l)
- Removes the specified mobility listener so it no longer receives
mobility events
- Parameters:
- l - the mobility listener
removePersistencyListener
public final void removePersistencyListener(PersistencyListener l)
- Removes the specified persistency listener so it no longer receives
persistency events
- Parameters:
- l - the persistency listener
onDisposing
public void onDisposing()
- 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.
- Throws: SecurityException
- if the request for disposal is rejected.
- See Also:
- dispose, dispose
handleMessage
public boolean handleMessage(Message message)
- Handles the message form outside.
- Parameters:
- msg - the message sent to the aglet
- Returns:
- true if the message was handled. Returns false if the message
was not handled. If false is returned, the MessageNotHandled exception
is thrown in the FutureReply.getReply and AgletProxy.sendMessage
methods.
- See Also:
- getReply, sendReply, sendMessage
waitMessage
public void waitMessage()
- Waits until it is notified.
- Throws: IllegalMonitorStateException
- If the current thread
is not the owner of the monitor.
- See Also:
- waitMessage, notifyMessage, notifyAllMessage
waitMessage
public void waitMessage(long timeout)
- Waits until it is notified or the timeout expires
- Parameters:
- timeout - the maximum value to wait in milliseconds
- Throws: IllegalMonitorStateException
- If the current thread
is not the owner of the monitor.
- See Also:
- waitMessage, notifyMessage, notifyAllMessage
notifyMessage
public void notifyMessage()
- Notifies a single waiting thread.
- Throws: IllegalMonitorStateException
- If the current thread
is not the owner of the monitor.
- See Also:
- notifyMessage, waitMessage, notifyAllMessage
notifyAllMessages
public void notifyAllMessages()
- Notifies all of waiting threads.
- Throws: IllegalMonitorStateException
- If the current thread
is not the owner of the monitor.
- See Also:
- notifyAllMessage, waitMessage, notifyMessage
exitMonitor
public void exitMonitor()
- Exits the current monitor.
- Throws: IllegalMonitorStateException
- if the current thread is not the
owner of the monitor.
- See Also:
- exitMonitor, waitMessage, notifyMessage, notifyAllMessages
getAgletContext
public final AgletContext getAgletContext()
- Gets the context in which the aglet is currently executing.
- Returns:
- the current execution context.
getMessageManager
public final MessageManager getMessageManager()
- Gets the message manager.
- Returns:
- the message manager.
getIdentifier
public final AgletIdentifier getIdentifier()
- Returns the identity of this aglet.
- Throws: InvalidAgletException
- if the aglet is not valid.
getAgletID
public final AgletID getAgletID()
- Returns the id of this aglet.
- Throws: InvalidAgletException
- if the aglet is not valid.
getCodeBase
public final URL getCodeBase()
- Gets the code base URL of this aglet
getAgletInfo
public final AgletInfo getAgletInfo()
- Gets the info object of this aglet
getText
public final String getText()
- Gets the message line of this Aglet.
setText
public final void setText(String text)
- Sets the text of this Aglet. A way for the aglet to display messages
without opening a window.
- Parameters:
- message - the message.
subscribeMessage
public final void subscribeMessage(String name)
- Subscribes to a named message.
- Parameters:
- name - the message kind.
unsubscribeMessage
public final boolean unsubscribeMessage(String name)
- Unsubscribes from a named message.
- Parameters:
- name - the message kind.
- Returns:
- true if the message kind was subscribed.
unsubscribeAllMessages
public final void unsubscribeAllMessages()
- Unsubscribes from all message kinds.
getImage
public final Image getImage(URL url) throws IOException
- Gets an image
getImage
public final Image getImage(URL url,
String name) throws IOException
- Gets an image
getAudioData
public final AudioClip getAudioData(URL url) throws IOException
- Gets an audio data
setStub
public final synchronized void setStub(AgletStub stub)
- Sets the proxy for the aglet. This cannot be set twice.
Called by the system.
- Parameters:
- proxy - the proxy to set
All Packages Class Hierarchy This Package Previous Next Index