com.ibm.aglet.system
Class AgletRuntime

java.lang.Object
  |
  +--com.ibm.aglet.system.AgletRuntime

public abstract class AgletRuntime
extends java.lang.Object

AgletRuntime class provides the way to access the information of the local or remote context. Neither of an application nor aglet can create its own instance of this runtime class.

See Also:
getAgletRuntime()

Constructor Summary
AgletRuntime()
           
 
Method Summary
abstract  java.security.Identity authenticate(java.lang.String username, java.lang.String password)
          Authenticate an user with password.
abstract  AgletContext createAgletContext(java.lang.String name)
          Creates an DefaultAgletContext object given by the Framework implementation with specified name.
abstract  AgletContext getAgletContext(java.lang.String name)
          Returns the AgletContext which has the specified name.
abstract  AgletContext[] getAgletContexts()
          Gets the contexts in the environment.
static AgletRuntime getAgletRuntime()
          Gets the AgletRuntime object associated with the current Java application.
abstract  java.lang.String getAgletsProperty(java.lang.String key)
          Returns aglets property of the user who owns the runtime.
abstract  java.lang.String getAgletsProperty(java.lang.String key, java.lang.String def)
          Returns aglets property of the user who owns the runtime.
abstract  java.security.Identity getOwnerIdentity()
          Returns identity of the user who owns the runtime.
abstract  java.lang.String getOwnerName()
          Returns name of the user who owns the runtime.
abstract  java.lang.String getProperty(java.lang.String prop, java.lang.String key)
          Returns property of the user who owns the runtime.
abstract  java.lang.String getProperty(java.lang.String prop, java.lang.String key, java.lang.String def)
          Returns property of the user who owns the runtime.
abstract  java.lang.String getServerAddress()
          Gets an address of the server
static AgletRuntime init(java.lang.String[] args)
          Create and initialize a runtime environment with a string array
static AgletRuntime init(java.lang.String[] args, java.lang.ClassLoader loader)
          Create and initialize a runtime environment with a string array
 boolean isSecure()
          Returns security.
abstract  void killAglet(AgletProxy proxy)
          Kill the specified aglet.
abstract  void removeAgletContext(AgletContext cxt)
          Removes the specified aglet context from the runtime environment.
abstract  void setAgletsProperty(java.lang.String key, java.lang.String value)
          Sets aglets property of the user who owns the runtime.
abstract  void setProperty(java.lang.String prop, java.lang.String key, java.lang.String value)
          Save property of the user who owns the runtime.
abstract  void shutdown()
          Shutdown all contexts in the runtime
abstract  void shutdown(Message msg)
          Shutdown all contexts in the current runtime with the specific message object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgletRuntime

public AgletRuntime()
Method Detail

init

public static AgletRuntime init(java.lang.String[] args,
                                java.lang.ClassLoader loader)
Create and initialize a runtime environment with a string array
Parameters:
a - string array which is typically given as a argument to main(String args[]) function.
loader - a classloader used to load a class of the implementation.

init

public static AgletRuntime init(java.lang.String[] args)
Create and initialize a runtime environment with a string array
Parameters:
a - string array which is typically given as a argument to main(String args[]) function.

getAgletRuntime

public static AgletRuntime getAgletRuntime()
Gets the AgletRuntime object associated with the current Java application.

authenticate

public abstract java.security.Identity authenticate(java.lang.String username,
                                                    java.lang.String password)
Authenticate an user with password. When the password is correct, the user owns the runtime and returns the owner's identity.
Parameters:
username - username of the user who will own the runtime
password - password of the user
Returns:
the owner's identity when authentication of the user succeeds

getOwnerIdentity

public abstract java.security.Identity getOwnerIdentity()
Returns identity of the user who owns the runtime.
Returns:
identity of the user who owns the runtime

getOwnerName

public abstract java.lang.String getOwnerName()
Returns name of the user who owns the runtime.
Returns:
name of the user who owns the runtime

getAgletsProperty

public abstract java.lang.String getAgletsProperty(java.lang.String key)
Returns aglets property of the user who owns the runtime. It needs PropertyPermission for the key of aglets property.
Parameters:
key - key of aglets property
Returns:
aglets property of the user who owns the runtime. If the property for the key does not exist, return null.
Throws:
java.lang.SecurityException - if PropertyPermission for the key is not give.

getAgletsProperty

public abstract java.lang.String getAgletsProperty(java.lang.String key,
                                                   java.lang.String def)
Returns aglets property of the user who owns the runtime. It needs PropertyPermission for the key of aglets property.
Parameters:
key - key of aglets property
def - default value of aglets property
Returns:
aglets property of the user who owns the runtime. If the property for the key does not exist, return def.
Throws:
java.lang.SecurityException - if PropertyPermission for the key is not given.

getProperty

public abstract java.lang.String getProperty(java.lang.String prop,
                                             java.lang.String key)
Returns property of the user who owns the runtime. It needs PropertyPermission for the key of specified property, and FilePermission for the property file.
Parameters:
prop - name of properties
key - key of property
Returns:
property of the user who owns the runtime. If the property for the key does not exist, return null.
Throws:
java.lang.SecurityException - if PropertyPermission for the key is not given.

getProperty

public abstract java.lang.String getProperty(java.lang.String prop,
                                             java.lang.String key,
                                             java.lang.String def)
Returns property of the user who owns the runtime. It needs PropertyPermission for the key of specified property, and FilePermission for the property file.
Parameters:
prop - name of properties
key - key of property
def - default value of property
Returns:
property of the user who owns the runtime. If the property for the key does not exist, return def.
Throws:
java.lang.SecurityException - if PropertyPermission for the key is not given.

setAgletsProperty

public abstract void setAgletsProperty(java.lang.String key,
                                       java.lang.String value)
Sets aglets property of the user who owns the runtime. It needs PropertyPermission for the key of aglets property, and FilePermission for the aglets property file.
Parameters:
key - key of aglets property
value - value of specified aglets property
Throws:
java.lang.SecurityException - if permissions for the key are not given.

setProperty

public abstract void setProperty(java.lang.String prop,
                                 java.lang.String key,
                                 java.lang.String value)
Save property of the user who owns the runtime. It needs PropertyPermission for the key of property, and FilePermission for the property file.
Parameters:
prop - name of properties
key - key of property
value - value of specified property
Throws:
java.lang.SecurityException - if permissions for the key are not given.

isSecure

public boolean isSecure()
Returns security.
Returns:
True if the runtime is working with security

createAgletContext

public abstract AgletContext createAgletContext(java.lang.String name)
Creates an DefaultAgletContext object given by the Framework implementation with specified name. Hosting multiple contexts is not supported in alpha5 release.
Throws:
java.lang.SecurityException - if the current execution is not allowed to create an AgletContext.

getAgletContext

public abstract AgletContext getAgletContext(java.lang.String name)
Returns the AgletContext which has the specified name.
Parameters:
name - the name of the context
Throws:
java.lang.SecurityException - if the current execution is not allowed to acccess the AgletContext.

removeAgletContext

public abstract void removeAgletContext(AgletContext cxt)
Removes the specified aglet context from the runtime environment. It is also removed from export list if it's exported.
Parameters:
cxt - the context to remove

getAgletContexts

public abstract AgletContext[] getAgletContexts()
Gets the contexts in the environment.

getServerAddress

public abstract java.lang.String getServerAddress()
Gets an address of the server
Returns:
the address of the server

shutdown

public abstract void shutdown()
Shutdown all contexts in the runtime

shutdown

public abstract void shutdown(Message msg)
Shutdown all contexts in the current runtime with the specific message object. This messag object is delivered to all aglets in all contexts before all aglets are killed.

killAglet

public abstract void killAglet(AgletProxy proxy)
                        throws InvalidAgletException
Kill the specified aglet. This aglet have to be a local aglet in this runtime.
Parameters:
proxy - the aglet proxy object to kill.