]> git.basschouten.com Git - openhab-addons.git/blob
36deefc58b58b4eb613074215a258d53ff633e3b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.dsmr.internal.discovery;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.i18n.LocaleProvider;
18 import org.openhab.core.i18n.TranslationProvider;
19 import org.openhab.core.thing.binding.ThingHandlerService;
20 import org.osgi.service.component.annotations.Activate;
21 import org.osgi.service.component.annotations.Component;
22 import org.osgi.service.component.annotations.Deactivate;
23 import org.osgi.service.component.annotations.Reference;
24
25 /**
26  * Tracks the i18n provider dependencies of the {@link DSMRMeterDiscoveryService}. The {@link DSMRMeterDiscoveryService}
27  * is a {@link ThingHandlerService} so its i18n dependencies cannot be injected using service component annotations.
28  *
29  * @author Wouter Born - Initial contribution
30  */
31 @Component
32 @NonNullByDefault
33 public class DSMRI18nProviderTracker {
34
35     static @Nullable TranslationProvider i18nProvider;
36     static @Nullable LocaleProvider localeProvider;
37
38     @Activate
39     public DSMRI18nProviderTracker(final @Reference TranslationProvider i18nProvider,
40             final @Reference LocaleProvider localeProvider) {
41         DSMRI18nProviderTracker.i18nProvider = i18nProvider;
42         DSMRI18nProviderTracker.localeProvider = localeProvider;
43     }
44
45     @Deactivate
46     public void deactivate() {
47         i18nProvider = null;
48         localeProvider = null;
49     }
50 }