Fix a race PingPongTransactionChain
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / sal / binding / api / AbstractBindingAwareProvider.java
1 /*
2  * Copyright (c) 2013 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.sal.binding.api;
9
10 import java.util.Collection;
11 import java.util.Collections;
12
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
15 import org.opendaylight.yangtools.yang.binding.RpcService;
16 import org.osgi.framework.BundleContext;
17
18 @Deprecated
19 public abstract class AbstractBindingAwareProvider extends AbstractBrokerAwareActivator implements BindingAwareProvider {
20
21     @Override
22     protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) {
23         ProviderContext ctx = broker.registerProvider(this, context);
24         registerRpcImplementations(ctx);
25         registerFunctionality(ctx);
26     }
27
28     private void registerFunctionality(ProviderContext ctx) {
29         Collection<? extends ProviderFunctionality> functionality = this.getFunctionality();
30         if (functionality == null || functionality.isEmpty()) {
31             return;
32         }
33         for (ProviderFunctionality providerFunctionality : functionality) {
34             ctx.registerFunctionality(providerFunctionality);
35         }
36
37     }
38
39     private void registerRpcImplementations(ProviderContext ctx) {
40         Collection<? extends RpcService> rpcs = this.getImplementations();
41         if (rpcs == null || rpcs.isEmpty()) {
42             return;
43         }
44         for (RpcService rpcService : rpcs) {
45             // ctx.addRpcImplementation(type, implementation);
46         }
47
48     }
49
50     @Override
51     public Collection<? extends ProviderFunctionality> getFunctionality() {
52         return Collections.emptySet();
53     }
54
55     @Override
56     public Collection<? extends RpcService> getImplementations() {
57         return Collections.emptySet();
58     }
59
60     /**
61      * Initialization of consumer context.
62      *
63      * {@link ProviderContext} is replacement of {@link ConsumerContext}
64      * so this method is not needed in case of Provider.
65      *
66      */
67     @Deprecated
68     @Override
69     public final void onSessionInitialized(ConsumerContext session) {
70         // NOOP
71     }
72 }