public class Feature extends Module
A Feature represents an optional part of an application that adds new features and services.
A Feature only depends on Kernel code. A Feature is considered as unreliable code from Kernel point of view.
Instances of this class are owned by the Kernel.
Modifier and Type | Class and Description |
---|---|
static class |
Feature.State
A Feature state.
|
Modifier and Type | Field and Description |
---|---|
static int |
MAX_CRITICALITY
The maximum criticality that a feature can have.
|
static int |
MIN_CRITICALITY
The minimum criticality that a feature can have.
|
static int |
NORM_CRITICALITY
The default criticality that is assigned to a feature.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Thread[] |
getAllAliveThreads()
Gets a snapshot of all alive threads owned by this Feature (some threads included in the returned array may have
been terminated when this method returns, some new threads may have been created when this method returns).
|
int |
getCriticality()
Returns the criticality of this feature.
|
Feature.State |
getState()
Returns the current Feature state.
|
void |
setCriticality(int criticality)
Sets the criticality of this feature.
|
void |
start()
Causes this Feature to start.
|
void |
stop()
Causes this Feature to stop.
|
getExecutionCounter, getExecutionQuota, getName, getProvider, getUID, getVersion, setExecutionQuota
public static final int MIN_CRITICALITY
getCriticality()
,
Constant Field Valuespublic static final int NORM_CRITICALITY
getCriticality()
,
Constant Field Valuespublic static final int MAX_CRITICALITY
getCriticality()
,
Constant Field Valuespublic java.lang.Thread[] getAllAliveThreads()
java.lang.IllegalStateException
- if the Feature is not in the Feature.State.STARTED
statepublic Feature.State getState()
Feature.State
public void start()
Feature.State.STARTED
state and this method returns. Next steps are executed asynchronously within the new
thread context:
FeatureEntryPoint.start()
is calledjava.lang.IllegalStateException
- if the Feature state is not in Feature.State.INSTALLED
statepublic void stop()
FeatureEntryPoint.stop()
is executed.ej.lang.Resource.reclaim()
is called for each resource that remains open by the Feature.DeadFeatureException
is thrown in threads that are running Feature code or in threads that want to
call Feature code.Feature.State.STOPPED
.Feature.State.INSTALLED
.
When the new Feature state is Feature.State.INSTALLED
, the Feature runtime has been fully reclaimed (threads and
objects). Otherwise, the new Feature state is Feature.State.STOPPED
and there are some remaining Feature objects
references from Kernel.
This method can be called multiple times by the Kernel to reclaim objects again and thus to try to switch the
Feature in the Feature.State.INSTALLED
state.
When Feature state is set to Feature.State.STOPPED
, Kernel application shall remove all its references to objects
owned by this Feature, through the calls of FeatureStateListener.stateChanged(ej.kf.Feature, ej.kf.Feature.State)
.
java.lang.IllegalStateException
- if the Feature is in the Feature.State.INSTALLED
or Feature.State.UNINSTALLED
statepublic int getCriticality()
The criticality is used by the system to determine which feature to kill when there is memory pressure. The
features with the lowest criticality will be killed first. The features with a criticality set to
MAX_CRITICALITY
are not killed automatically by the system when there is memory pressure.
The default criticality of a feature is NORM_CRITICALITY
.
If this feature is in Feature.State.UNINSTALLED
state, this method returns NORM_CRITICALITY
.
java.lang.IllegalStateException
- if this feature is in Feature.State.UNINSTALLED
state.public void setCriticality(int criticality)
criticality
- the new criticality of this feature.java.lang.IllegalArgumentException
- If the criticality is not in the range MIN_CRITICALITY
to MAX_CRITICALITY
.getCriticality()