2 * Copyright (c) 2013 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.sal.binding.api;
10 import java.util.Collection;
11 import java.util.Collections;
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.BundleActivator;
17 import org.osgi.framework.BundleContext;
18 import org.osgi.framework.ServiceReference;
20 public abstract class AbstractBindingAwareProvider extends AbstractBrokerAwareActivator implements BindingAwareProvider {
23 protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) {
24 ProviderContext ctx = broker.registerProvider(this, context);
25 registerRpcImplementations(ctx);
26 registerFunctionality(ctx);
29 private void registerFunctionality(ProviderContext ctx) {
30 Collection<? extends ProviderFunctionality> functionality = this.getFunctionality();
31 if (functionality == null || functionality.isEmpty()) {
34 for (ProviderFunctionality providerFunctionality : functionality) {
35 ctx.registerFunctionality(providerFunctionality);
40 private void registerRpcImplementations(ProviderContext ctx) {
41 Collection<? extends RpcService> rpcs = this.getImplementations();
42 if (rpcs == null || rpcs.isEmpty()) {
45 for (RpcService rpcService : rpcs) {
46 // ctx.addRpcImplementation(type, implementation);
52 public Collection<? extends ProviderFunctionality> getFunctionality() {
53 return Collections.emptySet();
57 public Collection<? extends RpcService> getImplementations() {
58 return Collections.emptySet();
62 * Initialization of consumer context.
64 * {@link ProviderContext} is replacement of {@link ConsumerContext}
65 * so this method is not needed in case of Provider.
70 public final void onSessionInitialized(ConsumerContext session) {