77046d6a9431bb420d3ff05d50130e39f5fbd699
[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 @Deprecated
23 public class HeliumRpcProviderRegistry implements RpcProviderRegistry {
24
25     private final RpcConsumerRegistry consumerRegistry;
26     private final BindingDOMRpcProviderServiceAdapter providerAdapter;
27
28     public HeliumRpcProviderRegistry(final RpcConsumerRegistry consumerRegistry,
29             final BindingDOMRpcProviderServiceAdapter providerAdapter) {
30         this.consumerRegistry = consumerRegistry;
31         this.providerAdapter = providerAdapter;
32     }
33
34     @Override
35     public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type, final T impl)
36             throws IllegalStateException {
37         return new CompositeRoutedRpcRegistration<>(type,impl,providerAdapter);
38     }
39
40     @Override
41     public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T impl)
42             throws IllegalStateException {
43         final ObjectRegistration<T> reg = providerAdapter.registerRpcImplementation(type, impl);
44         return new DelegatedRootRpcRegistration<>(type,reg);
45     }
46
47     @Override
48     public <T extends RpcService> T getRpcService(final Class<T> type) {
49         return consumerRegistry.getRpcService(type);
50     }
51
52     @Override
53     public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
54             registerRouteChangeListener(final L listener) {
55         // FIXME: Implement this only if necessary
56         return null;
57     }
58 }