2 * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.md.sal.binding.compat;
10 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
11 import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
14 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
15 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
16 import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
17 import org.opendaylight.yangtools.concepts.ListenerRegistration;
18 import org.opendaylight.yangtools.concepts.ObjectRegistration;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.opendaylight.yangtools.yang.binding.RpcService;
22 public class HeliumRpcProviderRegistry implements RpcProviderRegistry {
24 private final RpcConsumerRegistry consumerRegistry;
25 private final BindingDOMRpcProviderServiceAdapter providerAdapter;
27 public HeliumRpcProviderRegistry(final RpcConsumerRegistry consumerRegistry,
28 final BindingDOMRpcProviderServiceAdapter providerAdapter) {
29 this.consumerRegistry = consumerRegistry;
30 this.providerAdapter = providerAdapter;
34 public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type, final T impl)
35 throws IllegalStateException {
36 return new CompositeRoutedRpcRegistration<>(type,impl,providerAdapter);
40 public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T impl)
41 throws IllegalStateException {
42 final ObjectRegistration<T> reg = providerAdapter.registerRpcImplementation(type, impl);
43 return new DelegatedRootRpcRegistration<>(type,reg);
47 public <T extends RpcService> T getRpcService(final Class<T> type) {
48 return consumerRegistry.getRpcService(type);
52 public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
54 // FIXME: Implement this only if necessary