1 package org.opendaylight.controller.sal.binding.api;
3 import java.util.Collection;
5 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
6 import org.opendaylight.yangtools.yang.binding.RpcService;
7 import org.osgi.framework.BundleActivator;
8 import org.osgi.framework.BundleContext;
9 import org.osgi.framework.ServiceReference;
11 public abstract class AbstractBindingAwareProvider implements BindingAwareProvider, BundleActivator {
14 public final void start(BundleContext context) throws Exception {
15 ServiceReference<BindingAwareBroker> brokerRef = context.getServiceReference(BindingAwareBroker.class);
16 BindingAwareBroker broker = context.getService(brokerRef);
18 ProviderContext ctx = broker.registerProvider(this, context);
19 registerRpcImplementations(ctx);
20 registerFunctionality(ctx);
25 private void registerFunctionality(ProviderContext ctx) {
26 Collection<? extends ProviderFunctionality> functionality = this.getFunctionality();
27 if(functionality == null || functionality.isEmpty()) {
30 for (ProviderFunctionality providerFunctionality : functionality) {
31 ctx.registerFunctionality(providerFunctionality);
36 private void registerRpcImplementations(ProviderContext ctx) {
37 Collection<? extends RpcService> rpcs = this.getImplementations();
38 if(rpcs == null || rpcs.isEmpty()) {
41 for (RpcService rpcService : rpcs) {
42 //ctx.addRpcImplementation(type, implementation);
47 protected void startImpl(BundleContext context) {
52 public final void stop(BundleContext context) throws Exception {
58 public Collection<? extends ProviderFunctionality> getFunctionality() {
63 public Collection<? extends RpcService> getImplementations() {