Deprecate ClassToInstance-taking methods
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / dom / adapter / osgi / AbstractAdaptedService.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.dom.adapter.osgi;
9
10 import static com.google.common.base.Verify.verifyNotNull;
11
12 import java.util.Map;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.mdsal.binding.api.BindingService;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 abstract class AbstractAdaptedService<B extends BindingService> {
19     private static final Logger LOG = LoggerFactory.getLogger(AbstractAdaptedService.class);
20     static final @NonNull String DELEGATE =
21             "org.opendaylight.mdsal.binding.dom.adapter.osgi.AbstractAdaptedService.DELEGATE";
22
23     private final String serviceName;
24     final @NonNull B delegate;
25
26     AbstractAdaptedService(final Class<B> bindingService, final Map<String, ?> properties) {
27         serviceName = bindingService.getSimpleName();
28         delegate = bindingService.cast(verifyNotNull(properties.get(DELEGATE)));
29         LOG.info("Binding/DOM adapter for {} activated", serviceName);
30     }
31
32     final void stop(final int reason) {
33         LOG.info("Binding/DOM adapter for {} deactivated (reason {})", serviceName, reason);
34     }
35 }