All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface com.ibm.aglet.AgletContext

public interface AgletContext
The AgletContext interface is used by an aglet to get information about its environment and to send messages to the environment and other aglets currently active in that environment. It provides means for maintaining and managing running aglets in an environment where the host system is secured against malicious aglets.


Method Index

 o activateAglet(AgletID)
Activates an aglet. Deprecated.
 o addContextListener(ContextListener)
Adds the specified context listener to receive context events from this context.
 o clearCache(URL)
Clears class cache in memory.
 o createAglet(URL, String, Object)
Creates an instance of the specified aglet class.
 o getAgletProxies()
Gets an enumeration of all aglets in the current context including deactivated aglets. Deprecated.
 o getAgletProxies(int)
Gets an array of aglet proxies in the current context.
 o getAgletProxy(AgletID)
Gets a proxy for an aglet in the current context.
 o getAgletProxy(URL, AgletID)
Gets a proxy for an aglet in a remote context. Deprecated.
 o getAudioClip(URL)
Gets an audio clip.
 o getHostingURL()
Returns the URL of the daemon serving this context.
 o getImage(ImageData)
Gets an image.
 o getImage(URL)
Gets an image.
 o getImageData(URL)
Gets an image data.
 o getName()
Gets the name of the context.
 o getProperty(String)
Gets the context property indicated by the key.
 o getProperty(String, Object)
Gets the context property indicated by the key and default value.
 o multicastMessage(Message)
Sends a multicast message to the subscribers in the context.
 o removeContextListener(ContextListener)
Removes the specified context listener.
 o retractAglet(URL)
Retracts the aglet specified by its url: atp://host-domain-name/#aglet-identity. Deprecated.
 o retractAglet(URL, AgletID)
Retracts the aglet specified by its url and id
 o setProperty(String, Object)
Sets the context property indicated by the key and value.
 o showDocument(URL)
Shows a new document.
 o shutdown()
Shutdown the context.
 o shutdown(Message)
Shutdown the context with the specific message object.
 o start()
Starts the context.

Methods

 o getName
 public abstract String getName()
Gets the name of the context. Each context running in the same server can be distinguished by the name. The example of an address for contexts is, "atp://host.com:434/name".

Returns:
a name of aglet context
 o getAgletProxies
 public abstract Enumeration getAgletProxies()
Note: getAgletProxies() is deprecated.

Gets an enumeration of all aglets in the current context including deactivated aglets. This will be changed so that it returns an array of proxies.

Returns:
a list of proxies.
 o getAgletProxies
 public abstract Enumeration getAgletProxies(int type)
Gets an array of aglet proxies in the current context.

Parameters:
type - the type of aglets. ACTIVE, INACTIVE or ACTIVE | INACTIVE,
Returns:
a list of proxies that matches the given state.
See Also:
ACTIVE, INACTIVE
 o getAgletProxy
 public abstract AgletProxy getAgletProxy(AgletID id)
Gets a proxy for an aglet in the current context. The selected aglet is specified by its identity.

Parameters:
id - the identity of the aglet.
Returns:
the proxy.
 o getAgletProxy
 public abstract AgletProxy getAgletProxy(URL contextAddress,
                                          AgletID id)
Note: getAgletProxy() is deprecated.

Gets a proxy for an aglet in a remote context. The remote context is identified by its URL, and the aglet is indicated by its identifier.

Parameters:
contextAddress - the address specifing a remote context.
id - the identity of the aglet.
Returns:
the proxy.
See Also:
getName
 o createAglet
 public abstract AgletProxy createAglet(URL codeBase,
                                        String code,
                                        Object init) throws IOException, AgletException, ClassNotFoundException, InstantiationException
Creates an instance of the specified aglet class. The aglet's class code file can be located on the local file system as well as on a remote server. If the codeBase is null, the context will search for the code in the local system's aglet search path (AGLET_PATH). The createAglet method takes three arguments: codeBase, code, and init:

Parameters:
codeBase - codeBase specifies the base URL of the aglet class file, in other words, the (possibly remote) directory that contains the aglet's code. If this argument is null, then the directories specified in the local host's aglet search path are searched. The aglet search path works in a similar way to Java's class path. It is typically an environment variable that specifies a list of directories to be searched for aglet code files.
code - code gives the name of the file that contains the aglet's compiled class code. This file is relative to the base URL of the aglet, and cannot be absolute.
init - init is an object passed on to the aglet's onCreation method.
Returns:
the proxy of the new aglet.
Throws: AgletException
if the aglets can not be created.
Throws: UnknownHostException
if the given host could not be found.
Throws: ServerNotFoundException
if the server could not be found.
Throws: InstantiationException
if the instantiation failed.
Throws: ClassNotFoundException
if the class not found.
See Also:
onCreation
 o retractAglet
 public abstract AgletProxy retractAglet(URL url) throws IOException, AgletException
Note: retractAglet() is deprecated.

Retracts the aglet specified by its url: atp://host-domain-name/#aglet-identity.

Parameters:
url - the location and aglet identity of the aglet to be retracted.
Returns:
the aglet proxy for the retracted aglet.
Throws: AgletException
when the method failed to retract the aglet.
Throws: UnknownHostException
if the specified HOST is not found.
Throws: ServerNotFoundException
if the aglet server specified in the URL is not available.
Throws: MalformedURLException
if the given url is not URI for an aglet.
Throws: RequestRefusedException
if the retraction refused.
Throws: AgletNotFoundException
if the aglet could not be found.
 o retractAglet
 public abstract AgletProxy retractAglet(URL url,
                                         AgletID aid) throws IOException, AgletException
Retracts the aglet specified by its url and id

Parameters:
url - the location of the aglet to be retracted.
id - the aglet identity of the aglet to be retracted.
Returns:
the aglet proxy for the retracted aglet.
Throws: AgletException
when the method failed to retract the aglet.
Throws: UnknownHostException
if the specified HOST is not found.
Throws: ServerNotFoundException
if the aglet server specified in the URL is not available.
Throws: MalformedURLException
if the given url is not URI for an aglet.
Throws: RequestRefusedException
if the retraction refused.
Throws: AgletNotFoundException
if the aglet could not be found.
 o activateAglet
 public abstract AgletProxy activateAglet(AgletID aid) throws IOException, AgletException
Note: activateAglet() is deprecated. This will be removed from API in the future release. replaced with AgletProxy.activate();

Activates an aglet. This is a forced activation of a deactivated aglet.

Parameters:
aid - aglet identifier.
Returns:
proxy of the activated aglet.
Throws: AgletException
if the aglet is not valid.
Throws: AgletNotFoundException
if the aglet could not be found.
 o multicastMessage
 public abstract ReplySet multicastMessage(Message msg)
Sends a multicast message to the subscribers in the context.

Parameters:
message - to send
Returns:
ReplySet containing FutureReplies
 o getHostingURL
 public abstract URL getHostingURL()
Returns the URL of the daemon serving this context.

Returns:
the URL of the daemon. null if the hosting information is not available.
 o showDocument
 public abstract void showDocument(URL url)
Shows a new document. This may be ignored by the aglet context.

Parameters:
url - an url to be shown
 o getProperty
 public abstract Object getProperty(String key)
Gets the context property indicated by the key.

Parameters:
key - the name of the context property.
Returns:
the value of the specified key.
 o getProperty
 public abstract Object getProperty(String key,
                                    Object def)
Gets the context property indicated by the key and default value.

Parameters:
key - the name of the context property.
def - the value to use if this property is not set.
Returns:
the value of the specified key.
 o setProperty
 public abstract void setProperty(String key,
                                  Object value)
Sets the context property indicated by the key and value.

Parameters:
key - the name of the context property.
value - the value to be stored.
Returns:
the value of the specified key.
 o getImage
 public abstract Image getImage(URL image)
Gets an image.

Parameters:
image - an absolute URL giving the location of the image file.
Returns:
the image object give by the URL.
 o getAudioClip
 public abstract AudioClip getAudioClip(URL audio)
Gets an audio clip.

Parameters:
audio - an absolute URL giving the location of the audio file.
Returns:
the Audio clip object give by the URL.
 o getImageData
 public abstract ImageData getImageData(URL image)
Gets an image data. This is a tempolary solution.

Parameters:
image - an absolute URL giving the location of the image file.
Returns:
the serializable image data.
 o getImage
 public abstract Image getImage(ImageData image)
Gets an image. This is a tempolary solution.

Parameters:
image - a serializable image data.
Returns:
the image object converted from the image data.
 o addContextListener
 public abstract void addContextListener(ContextListener listener)
Adds the specified context listener to receive context events from this context.

Parameters:
listener - the context listener
 o removeContextListener
 public abstract void removeContextListener(ContextListener listener)
Removes the specified context listener.

Parameters:
listener - the context listener
 o start
 public abstract void start()
Starts the context. This is ignored if the context is already runnig.

 o clearCache
 public abstract void clearCache(URL codebase)
Clears class cache in memory.

Parameters:
codebase - the codebase of the cache to clean up. if null, entire cache in this context is cleared.
 o shutdown
 public abstract void shutdown(Message msg)
Shutdown the context with the specific message object. This message object is delivered to all aglets in the context before all aglets are killed. This is ignored if the context is already stopped.

Throws: SecurityException
if the current execution context is not allowd to shutdown
See Also:
start
 o shutdown
 public abstract void shutdown()
Shutdown the context. This is ignored if the context is already stopped.

Throws: SecurityException
if the current execution context is not allowd to shutdown
See Also:
start

All Packages  Class Hierarchy  This Package  Previous  Next  Index