Package io.openems.edge.core.appmanager
Class AppManagerImpl
java.lang.Object
io.openems.edge.common.component.AbstractOpenemsComponent
io.openems.edge.core.appmanager.AppManagerImpl
- All Implemented Interfaces:
OpenemsComponent
,JsonApi
,AppManager
public class AppManagerImpl
extends AbstractOpenemsComponent
implements AppManager, OpenemsComponent, JsonApi
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.openems.edge.core.appmanager.AppManager
AppManager.ChannelId
Nested classes/interfaces inherited from interface io.openems.edge.common.component.OpenemsComponent
OpenemsComponent.ChannelId
-
Field Summary
Modifier and TypeFieldDescriptionprotected List
<OpenemsApp> protected AppCenterBackendUtil
protected ComponentManager
protected ComponentUtil
protected final List
<OpenemsAppInstance> protected final Lock
protected Validator
protected boolean
protected final Condition
Fields inherited from interface io.openems.edge.core.appmanager.AppManager
SINGLETON_COMPONENT_ID, SINGLETON_SERVICE_PID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
_setAppsNotSyncedWithBackend
(boolean value) Internal method to set the 'nextValue' onAppManager.ChannelId.APPS_NOT_SYNCED_WITH_BACKEND
Channel.protected void
activate
(org.osgi.service.component.ComponentContext componentContext, io.openems.edge.core.appmanager.Config config) Gets anIterable
that loops thru every existing app instance and its configuration.appConfigs
(Predicate<? super OpenemsAppInstance> filter) Gets anIterable
that loops thru every existing app instance and its configuration.appConfigs
(List<OpenemsAppInstance> instances, Predicate<? super OpenemsAppInstance> filter) Gets anIterable
that loops thru every instance and its configuration.protected void
Handles @Deactivate of implementations.debugLog()
Gets some output that is suitable for a continuous Debug log.static Predicate
<? super OpenemsAppInstance> excludingInstanceIds
(UUID... excludingInstanceIds) Gets a filter for excluding instances.final Optional
<OpenemsApp> findAppById
(String id) Finds theOpenemsApp
with the given id.final OpenemsApp
Finds theOpenemsApp
with the given id.protected final Optional
<OpenemsAppInstance> findInstanceById
(UUID id) Finds theOpenemsAppInstance
with the givenUUID
.protected final OpenemsAppInstance
Finds theOpenemsAppInstance
with the givenUUID
.final List
<OpenemsAppInstance> Gets an unmodifiable list of the current instantiated apps.final List
<AppConfiguration> getOtherAppConfigurations
(UUID... ignoreIds) Gets allAppConfiguration
s from the existingOpenemsAppInstance
s.handleAddAppInstanceRequest
(User user, AddAppInstance.Request request) HandlesAddAppInstance
.handleAddAppInstanceRequest
(User user, AddAppInstance.Request request, boolean ignoreBackend) HandlesAddAppInstance
.CompletableFuture
<? extends JsonrpcResponseSuccess> handleDeleteAppInstanceRequest
(User user, DeleteAppInstance.Request request) Handles aDeleteAppInstance
.CompletableFuture
<? extends JsonrpcResponseSuccess> handleJsonrpcRequest
(User user, JsonrpcRequest request) Handles a JSON-RPC Request.handleUpdateAppInstanceRequest
(User user, UpdateAppInstance.Request request) HandlesUpdateAppInstance
.protected void
modified
(org.osgi.service.component.ComponentContext componentContext, io.openems.edge.core.appmanager.Config config) Methods inherited from class io.openems.edge.common.component.AbstractOpenemsComponent
_channel, activate, activate, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logDebug, logError, logInfo, logWarn, modified, removeChannel
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.openems.edge.core.appmanager.AppManager
_setDefectiveApp, _setWrongAppConfiguration, getAppsNotSyncedWithBackend, getAppsNotSyncedWithBackendChannel, getDefectiveApp, getDefectiveAppChannel, getWrongAppConfiguration, getWrongAppConfigurationChannel
Methods inherited from interface io.openems.edge.common.component.OpenemsComponent
_channel, _getChannelAs, alias, channel, channel, channels, getComponentContext, getState, getStateChannel, hasFaults, id, isEnabled, serviceFactoryPid, servicePid
-
Field Details
-
availableApps
-
componentManager
-
componentUtil
-
validator
-
backendUtil
-
instantiatedApps
-
lockModifyingApps
-
waitingForModifiedCondition
-
waitingForModified
protected volatile boolean waitingForModified
-
-
Constructor Details
-
AppManagerImpl
public AppManagerImpl()
-
-
Method Details
-
activate
protected void activate(org.osgi.service.component.ComponentContext componentContext, io.openems.edge.core.appmanager.Config config) -
modified
protected void modified(org.osgi.service.component.ComponentContext componentContext, io.openems.edge.core.appmanager.Config config) throws OpenemsError.OpenemsNamedException -
deactivate
protected void deactivate()Description copied from class:AbstractOpenemsComponent
Handles @Deactivate of implementations. Prints log output.- Overrides:
deactivate
in classAbstractOpenemsComponent
-
_setAppsNotSyncedWithBackend
public void _setAppsNotSyncedWithBackend(boolean value) Description copied from interface:AppManager
Internal method to set the 'nextValue' onAppManager.ChannelId.APPS_NOT_SYNCED_WITH_BACKEND
Channel.- Specified by:
_setAppsNotSyncedWithBackend
in interfaceAppManager
- Parameters:
value
- the next value
-
getInstantiatedApps
Gets an unmodifiable list of the current instantiated apps.- Returns:
- the list of instantiated apps
-
excludingInstanceIds
public static Predicate<? super OpenemsAppInstance> excludingInstanceIds(UUID... excludingInstanceIds) Gets a filter for excluding instances.- Parameters:
excludingInstanceIds
- the instances that should be excluded- Returns:
- the filter
-
appConfigs
Gets anIterable
that loops thru every existing app instance and its configuration.- Returns:
- the
Iterable
-
appConfigs
public Iterable<Map.Entry<OpenemsAppInstance,AppConfiguration>> appConfigs(Predicate<? super OpenemsAppInstance> filter) Gets anIterable
that loops thru every existing app instance and its configuration.- Parameters:
filter
- the filter that gets applied to the instances- Returns:
- the
Iterable
-
appConfigs
public Iterable<Map.Entry<OpenemsAppInstance,AppConfiguration>> appConfigs(List<OpenemsAppInstance> instances, Predicate<? super OpenemsAppInstance> filter) Gets anIterable
that loops thru every instance and its configuration.- Parameters:
instances
- the instancesfilter
- the filter that gets applied to the instances- Returns:
- the
Iterable
-
debugLog
Description copied from interface:OpenemsComponent
Gets some output that is suitable for a continuous Debug log. Returns 'null' by default which causes no output.- Specified by:
debugLog
in interfaceOpenemsComponent
- Returns:
- the debug log output
-
findAppById
Finds theOpenemsApp
with the given id.- Parameters:
id
- theOpenemsApp.getAppId()
of the app.- Returns:
- a
Optional
of the app
-
findAppByIdOrError
Finds theOpenemsApp
with the given id.- Parameters:
id
- theOpenemsApp.getAppId()
of the app.- Returns:
- the app
- Throws:
OpenemsError.OpenemsNamedException
- if the app was not found
-
findInstanceById
Finds theOpenemsAppInstance
with the givenUUID
.- Parameters:
id
- the id of the instance- Returns:
- a
Optional
of the instance
-
findInstanceByIdOrError
protected final OpenemsAppInstance findInstanceByIdOrError(UUID id) throws OpenemsError.OpenemsNamedException Finds theOpenemsAppInstance
with the givenUUID
.- Parameters:
id
- theUUID
of the instance- Returns:
- the instance
- Throws:
OpenemsError.OpenemsNamedException
- if not found
-
getOtherAppConfigurations
Gets allAppConfiguration
s from the existingOpenemsAppInstance
s.- Parameters:
ignoreIds
- the id's of the instances that should be ignored- Returns:
- the
AppConfiguration
s
-
handleAddAppInstanceRequest
public CompletableFuture<AddAppInstance.Response> handleAddAppInstanceRequest(User user, AddAppInstance.Request request, boolean ignoreBackend) throws OpenemsError.OpenemsNamedException HandlesAddAppInstance
.- Parameters:
user
- the Userrequest
- theAddAppInstance
RequestignoreBackend
- should only be used internally- Returns:
- the Future JSON-RPC Response
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
handleAddAppInstanceRequest
public CompletableFuture<AddAppInstance.Response> handleAddAppInstanceRequest(User user, AddAppInstance.Request request) throws OpenemsError.OpenemsNamedException HandlesAddAppInstance
.- Parameters:
user
- the Userrequest
- theAddAppInstance
Request- Returns:
- the Future JSON-RPC Response
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
handleDeleteAppInstanceRequest
public CompletableFuture<? extends JsonrpcResponseSuccess> handleDeleteAppInstanceRequest(User user, DeleteAppInstance.Request request) throws OpenemsError.OpenemsNamedException Handles aDeleteAppInstance
.- Parameters:
user
- the userrequest
- theDeleteAppInstance
- Returns:
- the request id
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
handleJsonrpcRequest
public CompletableFuture<? extends JsonrpcResponseSuccess> handleJsonrpcRequest(User user, JsonrpcRequest request) throws OpenemsError.OpenemsNamedException Description copied from interface:JsonApi
Handles a JSON-RPC Request.- Specified by:
handleJsonrpcRequest
in interfaceJsonApi
- Parameters:
user
- the authenticatedUser
request
- the JSON-RPC Request- Returns:
- a Future JSON-RPC Success Response; null response results in a OpenemsError.JSONRPC_UNHANDLED_METHOD
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
handleUpdateAppInstanceRequest
public CompletableFuture<UpdateAppInstance.Response> handleUpdateAppInstanceRequest(User user, UpdateAppInstance.Request request) throws OpenemsError.OpenemsNamedException HandlesUpdateAppInstance
.- Parameters:
user
- the Userrequest
- theUpdateAppInstance
Request- Returns:
- the Future JSON-RPC Response
- Throws:
OpenemsError.OpenemsNamedException
- on error
-