Interface aglet.AgletContext
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface aglet.AgletContext

public interface AgletContext
extends Object
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.
 o addContextListener(ContextListener)
Adds the specified context listener to receive context events from this context.
 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.
 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.
 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.
 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
Returns:
a name of aglet context
 o getAgletProxies
  public abstract Enumeration getAgletProxies()
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 AgletProxy[] 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.
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 host,
                                           AgletID id)
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:
identity - the identity of the aglet.
Returns:
the proxy.
 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:

  1. 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.
  2. 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.
  3. init is an object passed on to the aglet's onCreation method.
Parameters:
codeBase - base URL of the aglet class file.
code - name of the aglet's compiled class file.
init - initialization argument.
Returns:
the proxy of the new aglet.
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
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: 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: 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
Activates an aglet. This is a forced activation of a deactivated aglet.
Parameters:
aid - aglet identifier.
Returns:
proxy of the activated aglet.
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
 o getAudioClip
  public abstract AudioClip getAudioClip(URL audio)
Gets an audio clip
 o getImageData
  public abstract ImageData getImageData(URL image)
Gets an image data. This is a tempolary solution.
 o getImage
  public abstract Image getImage(ImageData image)
Gets an image. This is a tempolary solution.
 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 shutdown
  public abstract void shutdown(Message msg)
Shutdown the context with the specific message object. This messag 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