Merge "Change fields in ShardStats to non-volatile"
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / compat / HeliumRpcProviderRegistry.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.md.sal.binding.compat;
9
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;
21
22 public class HeliumRpcProviderRegistry implements RpcProviderRegistry {
23
24     private final RpcConsumerRegistry consumerRegistry;
25     private final BindingDOMRpcProviderServiceAdapter providerAdapter;
26
27     public HeliumRpcProviderRegistry(final RpcConsumerRegistry consumerRegistry,
28             final BindingDOMRpcProviderServiceAdapter providerAdapter) {
29         this.consumerRegistry = consumerRegistry;
30         this.providerAdapter = providerAdapter;
31     }
32
33     @Override
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);
37     }
38
39     @Override
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);
44     }
45
46     @Override
47     public <T extends RpcService> T getRpcService(final Class<T> type) {
48         return consumerRegistry.getRpcService(type);
49     }
50
51     @Override
52     public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
53             final L arg0) {
54         // FIXME: Implement this only if necessary
55         return null;
56     }
57
58 }