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
,org.osgi.service.cm.ConfigurationListener
public class AppManagerImpl extends AbstractOpenemsComponent implements AppManager, OpenemsComponent, JsonApi, org.osgi.service.cm.ConfigurationListener
-
-
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
Fields Modifier and Type Field Description protected java.util.List<OpenemsApp>
availableApps
protected ComponentManager
componentManager
protected ComponentUtil
componentUtil
protected java.util.List<OpenemsAppInstance>
instantiatedApps
protected Validator
validator
-
Fields inherited from interface io.openems.edge.core.appmanager.AppManager
SINGLETON_COMPONENT_ID, SINGLETON_SERVICE_PID
-
-
Constructor Summary
Constructors Constructor Description AppManagerImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<java.util.Map.Entry<OpenemsAppInstance,AppConfiguration>>
appConfigs()
Gets anIterable
that loops thru every existing app instance and its configuration.java.lang.Iterable<java.util.Map.Entry<OpenemsAppInstance,AppConfiguration>>
appConfigs(java.util.function.Predicate<? super OpenemsAppInstance> filter)
Gets anIterable
that loops thru every existing app instance and its configuration.java.lang.Iterable<java.util.Map.Entry<OpenemsAppInstance,AppConfiguration>>
appConfigs(java.util.List<OpenemsAppInstance> instances, java.util.function.Predicate<? super OpenemsAppInstance> filter)
Gets anIterable
that loops thru every instance and its configuration.void
configurationEvent(org.osgi.service.cm.ConfigurationEvent event)
protected void
deactivate()
Handles @Deactivate of implementations.java.lang.String
debugLog()
Gets some output that is suitable for a continuous Debug log.static java.util.function.Predicate<? super OpenemsAppInstance>
excludingInstanceIds(java.util.UUID... excludingInstanceIds)
Gets a filter for excluding instances.protected OpenemsApp
findAppById(java.lang.String id)
finds the app with the matching id.protected OpenemsAppInstance
findInstanceById(java.util.UUID uuid)
Finds the app instance with the matching id.java.util.List<OpenemsAppInstance>
getInstantiatedApps()
Gets an unmodifiable list of the current instantiated apps.java.util.List<AppConfiguration>
getOtherAppConfigurations(java.util.UUID... ignoreIds)
Gets allAppConfiguration
s from the existingOpenemsAppInstance
s.java.util.concurrent.CompletableFuture<JsonrpcResponseSuccess>
handleAddAppInstanceRequest(User user, AddAppInstance.Request request)
HandlesAddAppInstance
.java.util.concurrent.CompletableFuture<? extends JsonrpcResponseSuccess>
handleDeleteAppInstanceRequest(User user, DeleteAppInstance.Request request)
Handles aDeleteAppInstance
.java.util.concurrent.CompletableFuture<? extends JsonrpcResponseSuccess>
handleJsonrpcRequest(User user, JsonrpcRequest request)
Handles a JSON-RPC Request.-
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, 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 Detail
-
availableApps
protected volatile java.util.List<OpenemsApp> availableApps
-
componentManager
protected ComponentManager componentManager
-
componentUtil
protected ComponentUtil componentUtil
-
validator
protected Validator validator
-
instantiatedApps
protected final java.util.List<OpenemsAppInstance> instantiatedApps
-
-
Method Detail
-
deactivate
protected void deactivate()
Description copied from class:AbstractOpenemsComponent
Handles @Deactivate of implementations. Prints log output.- Overrides:
deactivate
in classAbstractOpenemsComponent
-
getInstantiatedApps
public final java.util.List<OpenemsAppInstance> getInstantiatedApps()
Gets an unmodifiable list of the current instantiated apps.- Returns:
- the list of instantiated apps
-
configurationEvent
public void configurationEvent(org.osgi.service.cm.ConfigurationEvent event)
- Specified by:
configurationEvent
in interfaceorg.osgi.service.cm.ConfigurationListener
-
excludingInstanceIds
public static java.util.function.Predicate<? super OpenemsAppInstance> excludingInstanceIds(java.util.UUID... excludingInstanceIds)
Gets a filter for excluding instances.- Parameters:
excludingInstanceIds
- the instances that should be excluded- Returns:
- the filter
-
appConfigs
public java.lang.Iterable<java.util.Map.Entry<OpenemsAppInstance,AppConfiguration>> appConfigs()
Gets anIterable
that loops thru every existing app instance and its configuration.- Returns:
- the
Iterable
-
appConfigs
public java.lang.Iterable<java.util.Map.Entry<OpenemsAppInstance,AppConfiguration>> appConfigs(java.util.function.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 java.lang.Iterable<java.util.Map.Entry<OpenemsAppInstance,AppConfiguration>> appConfigs(java.util.List<OpenemsAppInstance> instances, java.util.function.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
public java.lang.String 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
protected final OpenemsApp findAppById(java.lang.String id) throws java.util.NoSuchElementException
finds the app with the matching id.- Parameters:
id
- of the app- Returns:
- the found app
- Throws:
java.util.NoSuchElementException
-
findInstanceById
protected final OpenemsAppInstance findInstanceById(java.util.UUID uuid) throws java.util.NoSuchElementException
Finds the app instance with the matching id.- Parameters:
uuid
- the id of the instance- Returns:
- s the instance
- Throws:
java.util.NoSuchElementException
- if no instance is present
-
getOtherAppConfigurations
public final java.util.List<AppConfiguration> getOtherAppConfigurations(java.util.UUID... ignoreIds)
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 java.util.concurrent.CompletableFuture<JsonrpcResponseSuccess> 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 java.util.concurrent.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 java.util.concurrent.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
-
-