2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.dom.adapter;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import javax.inject.Inject;
14 import javax.inject.Singleton;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.opendaylight.mdsal.binding.api.ActionProviderService;
17 import org.opendaylight.mdsal.binding.api.ActionService;
18 import org.opendaylight.mdsal.binding.api.DataBroker;
19 import org.opendaylight.mdsal.binding.api.DataTreeService;
20 import org.opendaylight.mdsal.binding.api.MountPointService;
21 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
22 import org.opendaylight.mdsal.binding.api.NotificationService;
23 import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
24 import org.opendaylight.mdsal.binding.api.RpcProviderService;
25 import org.opendaylight.mdsal.binding.dom.adapter.spi.AdapterFactory;
26 import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
27 import org.opendaylight.mdsal.dom.api.DOMActionService;
28 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
29 import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
30 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
31 import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
32 import org.opendaylight.mdsal.dom.api.DOMNotificationService;
33 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
34 import org.opendaylight.mdsal.dom.api.DOMRpcService;
35 import org.opendaylight.yangtools.concepts.Immutable;
38 * Implementation of AdapterFactory.
40 * @author Robert Varga
45 public final class BindingAdapterFactory implements AdapterFactory, Immutable {
46 private final BindingToNormalizedNodeCodec codec;
49 public BindingAdapterFactory(final BindingToNormalizedNodeCodec codec) {
50 this.codec = requireNonNull(codec);
54 * Create a {@link DataBroker} backed by a {@link DOMDataBroker}.
56 * @param domService Backing DOMDataBroker
57 * @return A DataBroker
58 * @throws NullPointerException if {@code domService} is null
61 public DataBroker createDataBroker(final DOMDataBroker domService) {
62 return new BindingDOMDataBrokerAdapter(domService, codec);
66 * Create a {@link DataTreeService} backed by a {@link DOMDataTreeService}.
68 * @param domService Backing DOMDataTreeService
69 * @return A DataTreeService
70 * @throws NullPointerException if {@code domService} is null
73 public DataTreeService createDataTreeService(final DOMDataTreeService domService) {
74 return BindingDOMDataTreeServiceAdapter.create(domService, codec);
78 * Create a {@link MountPointService} backed by a {@link DOMMountPointService}.
80 * @param domService Backing DOMMountPointService
81 * @return A MountPointService
82 * @throws NullPointerException if {@code domService} is null
85 public MountPointService createMountPointService(final DOMMountPointService domService) {
86 return new BindingDOMMountPointServiceAdapter(domService, codec);
90 * Create a {@link DataBroker} backed by a {@link DOMDataBroker}.
92 * @param domService Backing DOMDataBroker
93 * @return A DataBroker
94 * @throws NullPointerException if {@code domService} is null
97 public NotificationService createNotificationService(final DOMNotificationService domService) {
98 return new BindingDOMNotificationServiceAdapter(domService, codec);
102 * Create a {@link NotificationPublishService} backed by a {@link DOMNotificationPublishService}.
104 * @param domService Backing DOMNotificationPublishService
105 * @return A NotificationPublishService
106 * @throws NullPointerException if {@code domService} is null
109 public NotificationPublishService createNotificationPublishService(final DOMNotificationPublishService domService) {
110 return new BindingDOMNotificationPublishServiceAdapter(domService, codec);
114 * Create a {@link RpcConsumerRegistry} backed by a {@link DOMRpcService}.
116 * @param domService Backing DOMRpcService
117 * @return A RpcConsumerRegistry
118 * @throws NullPointerException if {@code domService} is null
121 public RpcConsumerRegistry createRpcConsumerRegistry(final DOMRpcService domService) {
122 return new BindingDOMRpcServiceAdapter(domService, codec);
126 * Create a {@link RpcProviderService} backed by a {@link DOMRpcProviderService}.
128 * @param domService Backing DOMRpcProviderService
129 * @return A RpcProviderService
130 * @throws NullPointerException if {@code domService} is null
133 public RpcProviderService createRpcProviderService(final DOMRpcProviderService domService) {
134 return new BindingDOMRpcProviderServiceAdapter(domService, codec);
138 public ActionService createActionService(final DOMActionService domService) {
139 return new ActionServiceAdapter(codec, domService);
143 public ActionProviderService createActionProviderService(final DOMActionProviderService domService) {
144 return new ActionProviderServiceAdapter(codec, domService);