com.ibm.aglet.system
Class AgletRuntime

java.lang.Object
  |
  +--com.ibm.aglet.system.AgletRuntime
Direct Known Subclasses:
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.

Version:
1.10 $Date: 2002/01/19 22:10:43 $
Author:
Mitsuru Oshima
See Also:
getAgletRuntime()

Constructor Summary
AgletRuntime()
           
 
Method Summary
abstract  java.security.cert.Certificate authenticateOwner(java.lang.String username, java.lang.String password)
          Authenticate an user with password.
protected abstract  AgletProxy createAglet(java.lang.String contextAddress, java.net.URL codebase, java.lang.String name, java.lang.Object init)
          Creates an aglet remotely within the specified context.
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.
protected abstract  AgletProxy[] getAgletProxies(java.lang.String contextAddress)
          Returns the proxies in the context specified by the contextAddress.
protected abstract  AgletProxy getAgletProxy(java.lang.String contextAddress, AgletID id)
          Obtains the remote proxy for the aglet specified by the context and id.
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.cert.Certificate getOwnerCertificate()
          Returns certificate 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
protected abstract  void initialize(java.lang.String[] args)
          Initializes an AgletRuntime object with the given array of string.
 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.
protected  void setSecure(boolean secure)
          Sets secure.
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgletRuntime

public AgletRuntime()
Method Detail

authenticateOwner

public abstract java.security.cert.Certificate authenticateOwner(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 certificate.
Parameters:
username - username of the user who will own the runtime
password - password of the user
Returns:
the owner's certificate when authentication of the user succeeds

createAglet

protected abstract AgletProxy createAglet(java.lang.String contextAddress,
                                          java.net.URL codebase,
                                          java.lang.String name,
                                          java.lang.Object init)
                                   throws java.io.IOException
Creates an aglet remotely within the specified context.
Parameters:
contextAddress - an address of context.
codebase - an codebase for the aglet.
name - name of aglets' class.
init - an object passed as an initialize argument.
See Also:
Aglet.onCreation(java.lang.Object), AgletContext.createAglet(java.net.URL, java.lang.String, java.lang.Object)

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.

getAgletContexts

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

getAgletProxies

protected abstract AgletProxy[] getAgletProxies(java.lang.String contextAddress)
                                         throws java.io.IOException
Returns the proxies in the context specified by the contextAddress.
Parameters:
contextAddress - specify context URL with a string.

getAgletProxy

protected abstract AgletProxy getAgletProxy(java.lang.String contextAddress,
                                            AgletID id)
                                     throws java.io.IOException
Obtains the remote proxy for the aglet specified by the context and id.
Parameters:
contextAddress - specify context URL with a string.
id - target aglet identifyer.

getAgletRuntime

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

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.

getOwnerCertificate

public abstract java.security.cert.Certificate getOwnerCertificate()
Returns certificate of the user who owns the runtime.
Returns:
Certificate 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

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.

getServerAddress

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

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.

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.

initialize

protected abstract void initialize(java.lang.String[] args)
Initializes an AgletRuntime object with the given array of string. This is typically an argument of main(String args[]) function.
Parameters:
args - arguments used to initialize
Throws:
java.lang.IllegalAccessException - if the instance has been already initialized.

isSecure

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

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.

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

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.

setSecure

protected void setSecure(boolean secure)
Sets secure.
Parameters:
secure - true if the runtime is working with security

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.