Class cornell.slk.jkernel.core.Task
java.lang.Object
|
+----cornell.slk.jkernel.core.Task
- public final class Task
- extends java.lang.Object
A J-Kernel Task is a collection of classes, objects, and
thread segments, clearly separated from other tasks.
Constructor Summary
|
Task(Resolver resolver)
This creates a new task, which is a subtask of the
current task.
The resolver maps class names to bytecode in cases where
the system loader cannot find a class with a given name.
When a task is first created, it contains no objects, no
classes, and and no threads.
|
Method Summary
|
static void
|
addResolver(Resolver resolver)
addResolver appends a resolver to the current task's
list of resolvers.
|
static Task
|
currentTask()
Returns the current task.
|
void
|
enableNativeCode()
Enable a new task to load native code.
|
static java.lang.Class
|
getClass(java.lang.String className)
Returns the Class object associated with a name in the
current task.
|
static java.io.PrintStream
|
getDebugStream()
For debugging purposes only.
|
static Repository
|
getRepository()
Return the system repository.
|
Capability
|
seed(java.lang.String className)
Creates an object in a new task, and returns a Capability
to that object.
When a task is first created, it contains no objects
and no threads.
|
static void
|
setErrorStream(java.io.PrintStream errStream)
Set the stream that errors generated by J-Kernel
get dumped to.
|
static void
|
setRepository(Repository r)
|
static SharedClass
|
shareClass(java.lang.String className)
Creates a SharedClass object for a class so that
other tasks can share the class.
|
void
|
terminate()
Shut down a task.
|
java.lang.String
|
toString()
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Task
public Task(Resolver resolver)
- This creates a new task, which is a subtask of the
current task.
The resolver maps class names to bytecode in cases where
the system loader cannot find a class with a given name.
When a task is first created, it contains no objects, no
classes, and and no threads. The task must be seeded with
an object in order for any objects to exist in the
task, and the seed object must be invoked in order
for control to pass into the task.
enableNativeCode
public void enableNativeCode() throws java.lang.SecurityException
- Enable a new task to load native code. This method
should be called immediately after a new task is
created, before the new task is seeded. This method
will only work if the current task also has the
right to load native code. Otherwise, a SecurityException
is thrown
seed
public Capability seed(java.lang.String className) throws RemoteException
- Creates an object in a new task, and returns a Capability
to that object.
When a task is first created, it contains no objects
and no threads. The new task must be seeded with
an object in order for any objects to exist in the
new task, and the seed object must be invoked in order
for control to pass into the new task.
The seed method creates a new object of the class
given by the fully qualified class name "className" in the new task
(this name is resolved in to a Class object in
the new task). This class must be public, it must implement
a remote interface, and it must have a public constructor
taking no arguments. The seed method creates a
capability for the new object and returns this
capability.
The seed method can only be called once for each task.
Any calls to seed after the first call will result
in a SecurityException.
currentTask
public static Task currentTask()
- Returns the current task.
terminate
public void terminate() throws java.lang.SecurityException
- Shut down a task. When a task is terminated, all of
its child tasks are revoked, all of its capabilities
are revoked, and all of its thread segments are killed.
getRepository
public static Repository getRepository()
- Return the system repository. The repository is shared
among all tasks, and is used to export capabilities from
one task to another.
The following are standard entries in the repository:
- /system/standardResolver - This is a Resolver
that loads bytecode from the classpath specified as
an argument to Main.main when the VM was started.
setRepository
public static void setRepository(Repository r) throws java.lang.SecurityException
getClass
public static java.lang.Class getClass(java.lang.String className) throws java.lang.ClassNotFoundException
- Returns the Class object associated with a name in the
current task. In each task, a class name can
be mapped to at most one Class object. If getClass
does not have a Class object for a certain name,
it will query the task's resolvers to find bytecode
for the name, or to find an existing shared class.
If it finds the bytecode, it will create
a new Class object based on the bytecode and return it.
If it finds a shared class, it will use the shared class.
Otherwise, getClass throws a ClassNotFoundException
"className" must be a fully qualified class name.
shareClass
public static SharedClass shareClass(java.lang.String className) throws java.lang.ClassNotFoundException
- Creates a SharedClass object for a class so that
other tasks can share the class. For any class
in the current task, calling shareClass with the
name of the class creates a SharedClass object that
can be passed to other tasks. Other tasks'
resolvers can use the SharedClass object to use
the class.
Shared class cannot have static
fields. In addition, any class referred to by a
shared class must also be shared.
Shared classes generally fall into one of two
categories:
- Small, simple, serializable or fast-copy classes whose objects
can be passed by copy in remote invocations.
- Remote interface classes that serve as front
ends for more complicated services.
"className" must be a fully qualified class name.
addResolver
public static void addResolver(Resolver resolver)
- addResolver appends a resolver to the current task's
list of resolvers. When a task is looking
for bytecode for a class name, it queries each
of its resolvers in its list of resolvers, in
order, until one of the resolvers returns
bytecode for the given name. addResolver puts
a new resolver at the end of this list, which means
the new resolver only gets a chance to resolve
a name if the previous resolvers could not find
bytecode for the name.
getDebugStream
public static java.io.PrintStream getDebugStream()
- For debugging purposes only. This method may be
eliminated eventually.
setErrorStream
public static void setErrorStream(java.io.PrintStream errStream)
- Set the stream that errors generated by J-Kernel
get dumped to. By default, this is set to
the system's System.out.
toString
public java.lang.String toString()
- Overrides:
- toString in class java.lang.Object