2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.io.openhabcloud.internal.actions;
15 import java.util.Collection;
16 import java.util.List;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.core.automation.Action;
21 import org.openhab.core.automation.Module;
22 import org.openhab.core.automation.handler.BaseModuleHandlerFactory;
23 import org.openhab.core.automation.handler.ModuleHandler;
24 import org.openhab.core.automation.handler.ModuleHandlerFactory;
25 import org.openhab.io.openhabcloud.internal.CloudService;
26 import org.osgi.service.component.annotations.Activate;
27 import org.osgi.service.component.annotations.Component;
28 import org.osgi.service.component.annotations.Deactivate;
29 import org.osgi.service.component.annotations.Reference;
32 * This class provides a {@link ModuleHandlerFactory} implementation to provide actions to send notifications via
35 * @author Christoph Weitkamp - Initial contribution
38 @Component(service = ModuleHandlerFactory.class)
39 public class NotificationModuleHandlerFactory extends BaseModuleHandlerFactory {
41 private static final Collection<String> TYPES = List.of(SendNotificationActionHandler.TYPE_ID,
42 SendNotificationActionHandler.EXTENDED_TYPE_ID, SendBroadcastNotificationActionHandler.TYPE_ID,
43 SendBroadcastNotificationActionHandler.EXTENDED_TYPE_ID, SendLogNotificationActionHandler.TYPE_ID,
44 SendLogNotificationActionHandler.EXTENDED_TYPE_ID);
45 private final CloudService cloudService;
48 public NotificationModuleHandlerFactory(final @Reference CloudService cloudService) {
49 this.cloudService = cloudService;
54 protected void deactivate() {
59 public Collection<String> getTypes() {
64 protected @Nullable ModuleHandler internalCreate(Module module, String ruleUID) {
65 if (module instanceof Action) {
66 switch (module.getTypeUID()) {
67 case SendNotificationActionHandler.TYPE_ID:
68 case SendNotificationActionHandler.EXTENDED_TYPE_ID:
69 return new SendNotificationActionHandler((Action) module, cloudService);
70 case SendBroadcastNotificationActionHandler.TYPE_ID:
71 case SendBroadcastNotificationActionHandler.EXTENDED_TYPE_ID:
72 return new SendBroadcastNotificationActionHandler((Action) module, cloudService);
73 case SendLogNotificationActionHandler.TYPE_ID:
74 case SendLogNotificationActionHandler.EXTENDED_TYPE_ID:
75 return new SendLogNotificationActionHandler((Action) module, cloudService);