All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.aglet.Aglet

java.lang.Object
   |
   +----com.ibm.aglet.Aglet

public abstract 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.


Variable Index

 o ACTIVE
State of Aglet.
 o INACTIVE
 o MAJOR_VERSION
 o MINOR_VERSION

Method Index

 o addCloneListener(CloneListener)
Adds the specified clone listener to receive clone events from this aglet.
 o addMobilityListener(MobilityListener)
Adds the specified mobility listener to receive mobility events from this aglet.
 o addPersistencyListener(PersistencyListener)
Adds the specified persistency listener to receive persistency events from this aglet.
 o clone()
Clones the aglet and the proxy that holds the aglet.
 o deactivate(long)
Deactivates the aglet.
 o dispatch(URL)
Dispatches the aglet to the location (host) specified by the argument.
 o dispose()
Destroys and removes the aglet from its current aglet context.
 o exitMonitor()
Exits the current monitor.
 o getAgletContext()
Gets the context in which the aglet is currently executing.
 o getAgletID()
Gets the id of this aglet.
 o getAgletInfo()
Gets the info object of this aglet
 o getAudioData(URL)
Gets an audio data
 o getCodeBase()
Gets the code base URL of this aglet
 o getImage(URL)
Gets an image
 o getImage(URL, String)
Gets an image
 o getMessageManager()
Gets the message manager.
 o getProxy()
Gets the proxy of aglet.
 o getText()
Gets the message line of this Aglet.
 o handleMessage(Message)
Handles the message form outside.
 o notifyAllMessages()
Notifies all of waiting threads.
 o notifyMessage()
Notifies a single waiting thread.
 o onCreation(Object)
Initializes the new aglet.
 o onDisposing()
Is called when an attempt is made to dispose of the aglet.
 o removeCloneListener(CloneListener)
Removes the specified clone listener so it no longer receives clone events.
 o removeMobilityListener(MobilityListener)
Removes the specified mobility listener so it no longer receives mobility events.
 o removePersistencyListener(PersistencyListener)
Removes the specified persistency listener so it no longer receives persistency events.
 o run()
Is the entry point for the aglet's own thread of execution.
 o setStub(AgletStub)
Sets the proxy for the aglet.
 o setText(String)
Sets the text of this Aglet.
 o snapshot()
[Preliminary] Save a snapshot of this aglet into a 2nd storage.
 o subscribeMessage(String)
Subscribes to a named message.
 o unsubscribeAllMessages()
Unsubscribes from all message kinds.
 o unsubscribeMessage(String)
Unsubscribes from a named message.
 o waitMessage()
Waits until it is notified.
 o waitMessage(long)
Waits until it is notified or the timeout expires

Variables

 o MAJOR_VERSION
 public static final short MAJOR_VERSION
 o MINOR_VERSION
 public static final short MINOR_VERSION
 o ACTIVE
 public static final int ACTIVE
State of Aglet.

See Also:
getAgletProxies
 o INACTIVE
 public static final int INACTIVE

Methods

 o 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
 o dispatch
 public final void dispatch(URL destination) throws IOException, RequestRefusedException
Dispatches the aglet to the location (host) specified by the 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
 o 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
 o 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:
millisecounds - duration of the aglet deactivating. If this is 0, it will be activeted at the next startup time.
Throws: NotSerializableException
if the entire aglet is not serializable.
Throws: IOException
if I/O failed
Throws: IllegalArgumentException
if the argument is negative.
 o 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
 o 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
 o 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
 o addCloneListener
 public final void addCloneListener(CloneListener listener)
Adds the specified clone listener to receive clone events from this aglet.

Parameters:
listener - the mobility listener
 o addMobilityListener
 public final void addMobilityListener(MobilityListener listener)
Adds the specified mobility listener to receive mobility events from this aglet.

Parameters:
listener - the mobility listener
 o addPersistencyListener
 public final void addPersistencyListener(PersistencyListener listener)
Adds the specified persistency listener to receive persistency events from this aglet.

Parameters:
listener - the persistency listener
 o removeCloneListener
 public final void removeCloneListener(CloneListener l)
Removes the specified clone listener so it no longer receives clone events.

Parameters:
l - the clone listener
 o removeMobilityListener
 public final void removeMobilityListener(MobilityListener l)
Removes the specified mobility listener so it no longer receives mobility events.

Parameters:
l - the mobility listener
 o removePersistencyListener
 public final void removePersistencyListener(PersistencyListener l)
Removes the specified persistency listener so it no longer receives persistency events.

Parameters:
l - the persistency listener
 o 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
 o 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
 o 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, notifyAllMessages
 o 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, notifyAllMessages
 o 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, notifyAllMessages
 o notifyAllMessages
 public void notifyAllMessages()
Notifies all of waiting threads.

Throws: IllegalMonitorStateException
If the current thread is not the owner of the monitor.
See Also:
notifyAllMessages, waitMessage, notifyMessage
 o 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
 o getProxy
 public final AgletProxy getProxy()
Gets the proxy of aglet.

Returns:
the proxy of aglet
 o getAgletContext
 public final AgletContext getAgletContext()
Gets the context in which the aglet is currently executing.

Returns:
the current execution context.
 o getMessageManager
 public final MessageManager getMessageManager()
Gets the message manager.

Returns:
the message manager.
 o getAgletID
 public final AgletID getAgletID()
Gets the id of this aglet.

Returns:
the AgletID object of this aglet
See Also:
AgletID
 o getCodeBase
 public final URL getCodeBase()
Gets the code base URL of this aglet

Returns:
the java.net.URL object of this aglet
See Also:
AgletID
 o getAgletInfo
 public final AgletInfo getAgletInfo()
Gets the info object of this aglet

Returns:
the aglet.AgletInfo object of this aglet
See Also:
AgletID
 o getText
 public final String getText()
Gets the message line of this Aglet.

Returns:
the String representing a message the aglet shows.
 o setText
 public final void setText(String text)
Sets the text of this Aglet. A way for the aglet to display messages on the viewer window.

Parameters:
message - the message.
 o subscribeMessage
 public final void subscribeMessage(String name)
Subscribes to a named message.

Parameters:
name - the message kind.
 o 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.
 o unsubscribeAllMessages
 public final void unsubscribeAllMessages()
Unsubscribes from all message kinds.

 o getImage
 public final Image getImage(URL url) throws IOException
Gets an image

 o getImage
 public final Image getImage(URL url,
                             String name) throws IOException
Gets an image

 o getAudioData
 public final AudioClip getAudioData(URL url) throws IOException
Gets an audio data

 o 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