2 * Copyright (c) 2010-2024 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
36 * @author Dan Cunningham - Extended notification enhancements
39 @Component(service = ModuleHandlerFactory.class)
40 public class NotificationModuleHandlerFactory extends BaseModuleHandlerFactory {
42 private static final Collection<String> TYPES = List.of(SendNotificationActionHandler.TYPE_ID,
43 SendNotificationActionHandler.EXTENDED_TYPE_ID, SendNotificationActionHandler.EXTENDED2_TYPE_ID,
44 SendBroadcastNotificationActionHandler.TYPE_ID, SendBroadcastNotificationActionHandler.EXTENDED_TYPE_ID,
45 SendBroadcastNotificationActionHandler.EXTENDED2_TYPE_ID, SendLogNotificationActionHandler.TYPE_ID,
46 SendLogNotificationActionHandler.EXTENDED_TYPE_ID);
47 private final CloudService cloudService;
50 public NotificationModuleHandlerFactory(final @Reference CloudService cloudService) {
51 this.cloudService = cloudService;
56 protected void deactivate() {
61 public Collection<String> getTypes() {
66 protected @Nullable ModuleHandler internalCreate(Module module, String ruleUID) {
67 if (module instanceof Action action) {
68 switch (module.getTypeUID()) {
69 case SendNotificationActionHandler.TYPE_ID:
70 case SendNotificationActionHandler.EXTENDED_TYPE_ID:
71 case SendNotificationActionHandler.EXTENDED2_TYPE_ID:
72 return new SendNotificationActionHandler(action, cloudService);
73 case SendBroadcastNotificationActionHandler.TYPE_ID:
74 case SendBroadcastNotificationActionHandler.EXTENDED_TYPE_ID:
75 case SendBroadcastNotificationActionHandler.EXTENDED2_TYPE_ID:
76 return new SendBroadcastNotificationActionHandler(action, cloudService);
77 case SendLogNotificationActionHandler.TYPE_ID:
78 case SendLogNotificationActionHandler.EXTENDED_TYPE_ID:
79 return new SendLogNotificationActionHandler(action, cloudService);