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.
-
activateAglet(AgletID)
- Activates an aglet.
-
addContextListener(ContextListener)
- Adds the specified context listener to receive context events
from this context.
-
createAglet(URL, String, Object)
- Creates an instance of the specified aglet class.
-
getAgletProxies()
- Gets an enumeration of all aglets in the current context including
deactivated aglets.
-
getAgletProxies(int)
- Gets an array of aglet proxies in the current context.
-
getAgletProxy(AgletID)
- Gets a proxy for an aglet in the current context.
-
getAgletProxy(URL, AgletID)
- Gets a proxy for an aglet in a remote context.
-
getAudioClip(URL)
- Gets an audio clip
-
getHostingURL()
- Returns the URL of the daemon serving this context.
-
getImage(ImageData)
- Gets an image.
-
getImage(URL)
- Gets an image
-
getImageData(URL)
- Gets an image data.
-
getName()
- Gets the name of the context
-
getProperty(String)
- Gets the context property indicated by the key.
-
getProperty(String, Object)
- Gets the context property indicated by the key and default value.
-
multicastMessage(Message)
- Sends a multicast message to the subscribers in the context
-
removeContextListener(ContextListener)
- Removes the specified context listener.
-
retractAglet(URL)
- Retracts the aglet specified by its url:
atp://host-domain-name/#aglet-identity.
-
retractAglet(URL, AgletID)
- Retracts the aglet specified by its url and id
-
setProperty(String, Object)
- Sets the context property indicated by the key and value.
-
showDocument(URL)
- Shows a new document.
-
shutdown()
- Shutdown the context.
-
shutdown(Message)
- Shutdown the context with the specific message object.
-
start()
- Starts the context.
getName
public abstract String getName()
- Gets the name of the context
- Returns:
- a name of aglet context
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.
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
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.
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.
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:
- 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 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 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
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.
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.
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.
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
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.
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
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.
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.
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.
getImage
public abstract Image getImage(URL image)
- Gets an image
getAudioClip
public abstract AudioClip getAudioClip(URL audio)
- Gets an audio clip
getImageData
public abstract ImageData getImageData(URL image)
- Gets an image data. This is a tempolary solution.
getImage
public abstract Image getImage(ImageData image)
- Gets an image. This is a tempolary solution.
addContextListener
public abstract void addContextListener(ContextListener listener)
- Adds the specified context listener to receive context events
from this context.
- Parameters:
- listener - the context listener
removeContextListener
public abstract void removeContextListener(ContextListener listener)
- Removes the specified context listener.
- Parameters:
- listener - the context listener
start
public abstract void start()
- Starts the context. This is ignored if the context is already runnig.
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
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