Search in sources :

Example 6 with ModuleInformation

use of org.eclipse.smarthome.automation.module.core.provider.ModuleInformation in project smarthome by eclipse.

the class AnnotatedActionModuleTypeProvider method addActionProvider.

@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
public void addActionProvider(AnnotatedActions actionProvider, Map<String, Object> properties) {
    Collection<ModuleInformation> moduleInformations = helper.parseAnnotations(actionProvider);
    String configName = getConfigNameFromService(properties);
    for (ModuleInformation mi : moduleInformations) {
        mi.setConfigName(configName);
        ModuleType oldType = null;
        if (this.moduleInformation.containsKey(mi.getUID())) {
            oldType = helper.buildModuleType(mi.getUID(), this.moduleInformation);
            Set<ModuleInformation> availableModuleConfigs = this.moduleInformation.get(mi.getUID());
            availableModuleConfigs.add(mi);
        } else {
            Set<ModuleInformation> configs = ConcurrentHashMap.newKeySet();
            configs.add(mi);
            this.moduleInformation.put(mi.getUID(), configs);
        }
        ModuleType mt = helper.buildModuleType(mi.getUID(), this.moduleInformation);
        if (mt != null) {
            for (ProviderChangeListener<ModuleType> l : changeListeners) {
                if (oldType != null) {
                    l.updated(this, oldType, mt);
                } else {
                    l.added(this, mt);
                }
            }
        }
    }
}
Also used : ModuleType(org.eclipse.smarthome.automation.type.ModuleType) ModuleInformation(org.eclipse.smarthome.automation.module.core.provider.ModuleInformation) Reference(org.osgi.service.component.annotations.Reference)

Aggregations

ModuleInformation (org.eclipse.smarthome.automation.module.core.provider.ModuleInformation)6 ModuleType (org.eclipse.smarthome.automation.type.ModuleType)6 Bundle (org.osgi.framework.Bundle)2 Reference (org.osgi.service.component.annotations.Reference)2 ThingActionsScope (org.eclipse.smarthome.core.thing.binding.ThingActionsScope)1