|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavacardx.facilities.TaskRegistry
@TransactionType(value=NOT_SUPPORTED) public final class TaskRegistry
The TaskRegistry class allows for applications to register tasks which will be executed in their own separate thread and which will be automatically restarted in a new thread when the platform is reset.
Tasks are Runnable
objects created by an application. These
objects remains bound to the application's context while registered.
The registry ensures that task objects are persistent across card session. Therefore applications do not have to hold on to references on these objects to ensure their persistence. Additionally, the registry provides facilities to retrieve and manage registered tasks.
Tasks are automatically restarted in a new thread at each platform reset until the task is removed from the registry by the application that registered it or when that application is deleted.
Tasks are restarted after the application containers have been restarted but before any request or command get dispatched to applications.
The task registry operates in the Java Card runtime environment context: it is a permanent Java Card runtime environment Entry Point Object.
Task registry operations are subject to permission checks.
See Runtime Environment Specification for the Java Card Platform, Connected Edition , chapter 2 for details regarding the task registry.
TaskRegistryPermission
Method Summary | |
---|---|
static TaskRegistry |
getTaskRegistry()
Retrieves the restartable task registry. |
Enumeration<Runnable> |
list()
Lists all the tasks registered by the current application. |
void |
register(Runnable task)
Registers the given task for restartable execution. |
void |
register(Runnable task,
boolean eager)
Registers the given task for restartable execution. |
void |
unregister(Runnable task)
Unregisters the given task previously registered by the current application, without interrupting the task's thread if the task is currently being executed. |
void |
unregister(Runnable task,
boolean eager)
Unregisters the given task previously registered by the current application. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final TaskRegistry getTaskRegistry()
public void register(Runnable task)
The task will be restarted after each platform reset.
If the same task object is already registered, this results in the currently executing task's thread (if any) to be interrupted.
Calling this method is equivalent to calling
register(Runnable, boolean)
with the eager
parameter set to false
.
task
- the task to register.
SecurityException
- NullPointerException
- if task
is null.public void register(Runnable task, boolean eager)
eager
equals true, the task will be started immediately.
The task will be restarted after each platform reset.
If the same task object is already registered then the current execution
state of the task may get affected depending on the value of the eager
parameter:
eager
parameter equals false (the task
is only to be started after the next platform reset) and if the task is
currently being executed then the task's thread is interrupted (by
a call to Thread.interrupt()
),eager
parameter equals true (the task
is to be started immediately) and if the task is not
currently being executed then the task is started,
task
- the task to register.eager
- indicates that the task is to be started immediately.
SecurityException
- NullPointerException
- if task
is null.public Enumeration<Runnable> list()
public void unregister(Runnable task)
Calling this method is equivalent to calling
unregister(Runnable, boolean)
with the eager
parameter set to false
.
task
- the task to be unregistered.
SecurityException
- NullPointerException
- if task
is null.public void unregister(Runnable task, boolean eager)
eager
equals true and if the task is
currently being executed, the thread's interrupt
method is
first called.
task
- the task to be unregistered.eager
- indicates that the task is to be interrupted first.
SecurityException
- NullPointerException
- if task
is null.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |