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.pidcontroller.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.pidcontroller.internal.handler.PIDControllerTriggerHandler;
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.events.EventPublisher;
27 import org.openhab.core.items.ItemRegistry;
28 import org.osgi.framework.BundleContext;
29 import org.osgi.service.component.annotations.Activate;
30 import org.osgi.service.component.annotations.Component;
31 import org.osgi.service.component.annotations.Reference;
35 * @author Hilbrand Bouwkamp - Initial Contribution
37 @Component(service = ModuleHandlerFactory.class, configurationPid = "action.pidcontroller")
39 public class PIDControllerModuleHandlerFactory extends BaseModuleHandlerFactory {
40 private static final Collection<String> TYPES = Set.of(PIDControllerTriggerHandler.MODULE_TYPE_ID);
41 private ItemRegistry itemRegistry;
42 private EventPublisher eventPublisher;
43 private BundleContext bundleContext;
46 public PIDControllerModuleHandlerFactory(@Reference ItemRegistry itemRegistry,
47 @Reference EventPublisher eventPublisher, BundleContext bundleContext) {
48 this.itemRegistry = itemRegistry;
49 this.eventPublisher = eventPublisher;
50 this.bundleContext = bundleContext;
54 public Collection<String> getTypes() {
59 protected @Nullable ModuleHandler internalCreate(Module module, String ruleUID) {
60 switch (module.getTypeUID()) {
61 case PIDControllerTriggerHandler.MODULE_TYPE_ID:
62 return new PIDControllerTriggerHandler((Trigger) module, itemRegistry, eventPublisher, bundleContext);