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.automation.pwm.internal.factory;
15 import java.util.Collection;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.automation.pwm.internal.handler.PWMTriggerHandler;
21 import org.openhab.core.automation.Module;
22 import org.openhab.core.automation.Trigger;
23 import org.openhab.core.automation.handler.BaseModuleHandlerFactory;
24 import org.openhab.core.automation.handler.ModuleHandler;
25 import org.openhab.core.automation.handler.ModuleHandlerFactory;
26 import org.openhab.core.items.ItemRegistry;
27 import org.osgi.framework.BundleContext;
28 import org.osgi.service.component.annotations.Activate;
29 import org.osgi.service.component.annotations.Component;
30 import org.osgi.service.component.annotations.Reference;
33 * Factory for the PWM automation module.
35 * @author Fabian Wolter - Initial Contribution
38 @Component(service = ModuleHandlerFactory.class, configurationPid = "automation.pwm")
39 public class PWMModuleHandlerFactory extends BaseModuleHandlerFactory {
40 private static final Collection<String> TYPES = Set.of(PWMTriggerHandler.MODULE_TYPE_ID);
41 private ItemRegistry itemRegistry;
42 private BundleContext bundleContext;
45 public PWMModuleHandlerFactory(@Reference ItemRegistry itemRegistry, BundleContext bundleContext) {
46 this.itemRegistry = itemRegistry;
47 this.bundleContext = bundleContext;
51 public Collection<String> getTypes() {
56 protected @Nullable ModuleHandler internalCreate(Module module, String ruleUID) {
57 switch (module.getTypeUID()) {
58 case PWMTriggerHandler.MODULE_TYPE_ID:
59 return new PWMTriggerHandler((Trigger) module, itemRegistry, bundleContext, ruleUID);