public class ApplicationManagerKF extends Object implements ApplicationManager, FeatureStateListener
Constructor and Description |
---|
ApplicationManagerKF()
Creates an application manager KF with all the installed features.
|
ApplicationManagerKF(Feature[] features)
Creates an application manager KF with the given features.
|
Modifier and Type | Method and Description |
---|---|
Application |
addApplication(Feature feature)
Adds an application associated with a feature.
|
void |
addApplicationLifecycleListener(ApplicationLifecycleListener appLifecycleListener)
Adds an application lifecycle listener.
|
boolean |
contains(Feature feature)
Gets whether a feature is manager by the application manager or not.
|
protected FeatureApplication |
createApplication(Feature feature)
Creates an application from the given feature.
|
Application |
getApplication(Feature feature)
Gets the application associated with a feature.
|
Application |
getApplication(Module module)
Gets the application for a module.
|
Application[] |
getApplications()
Gets all available applications.
|
Feature |
getFeature(Application application)
Gets the feature associated with the application.
|
Feature[] |
getFeatures()
Gets all available features known by this manager.
|
Application |
removeApplication(Feature feature)
Removes the application associated with a feature.
|
void |
removeApplicationLifecycleListener(ApplicationLifecycleListener appLifecycleListener)
Removes an application lifecycle listener.
|
void |
stateChanged(Feature feature,
Feature.State previousState)
Called when the state of a Feature has changed.
|
public ApplicationManagerKF()
public ApplicationManagerKF(Feature[] features)
For each feature, an application will be created and available in getApplications()
.
features
- the feature to manage.public Application addApplication(Feature feature)
If the feature is already managed by the application manager, nothing changes.
feature
- the feature.public void addApplicationLifecycleListener(ApplicationLifecycleListener appLifecycleListener)
ApplicationManager
It will be notified for each application event: start, stop.
addApplicationLifecycleListener
in interface ApplicationManager
appLifecycleListener
- the listener to add.public boolean contains(Feature feature)
feature
- the feature.true
if the feature is managed by this application manager, false
otherwise.protected FeatureApplication createApplication(Feature feature)
feature
- the feature to manage@Nullable public Application getApplication(Feature feature)
feature
- the feature.null
if no application matches the given feature.@Nullable public Application getApplication(Module module)
If the given module is the kernel, the method returns null
.
module
- the module.null
.getApplication(Feature)
public Application[] getApplications()
ApplicationManager
If there is no application, this method returns an empty array.
getApplications
in interface ApplicationManager
@Nullable public Feature getFeature(Application application)
application
- the application.null
if no feature is associated to the given application.public Feature[] getFeatures()
If there is none, this method returns an empty array.
@Nullable public Application removeApplication(Feature feature)
If the feature is not managed by the application manager, nothing changes and null
is returned.
feature
- the feature.null
if not found.public void removeApplicationLifecycleListener(ApplicationLifecycleListener appLifecycleListener)
ApplicationManager
If the given listener is not registered, nothing is done.
removeApplicationLifecycleListener
in interface ApplicationManager
appLifecycleListener
- the listener to remove.public void stateChanged(@Nullable Feature feature, @Nullable Feature.State previousState)
FeatureStateListener
stateChanged
in interface FeatureStateListener
feature
- the Feature which state has changedpreviousState
- the previous state, null
if Feature state is Feature.State.INSTALLED