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.BundleContext;
19 public abstract class AbstractBindingAwareProvider extends AbstractBrokerAwareActivator implements BindingAwareProvider {
22 protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) {
23 ProviderContext ctx = broker.registerProvider(this, context);
24 registerRpcImplementations(ctx);
25 registerFunctionality(ctx);
28 private void registerFunctionality(ProviderContext ctx) {
29 Collection<? extends ProviderFunctionality> functionality = this.getFunctionality();
30 if (functionality == null || functionality.isEmpty()) {
33 for (ProviderFunctionality providerFunctionality : functionality) {
34 ctx.registerFunctionality(providerFunctionality);
39 private void registerRpcImplementations(ProviderContext ctx) {
40 Collection<? extends RpcService> rpcs = this.getImplementations();
41 if (rpcs == null || rpcs.isEmpty()) {
44 for (RpcService rpcService : rpcs) {
45 // ctx.addRpcImplementation(type, implementation);
51 public Collection<? extends ProviderFunctionality> getFunctionality() {
52 return Collections.emptySet();
56 public Collection<? extends RpcService> getImplementations() {
57 return Collections.emptySet();
61 * Initialization of consumer context.
63 * {@link ProviderContext} is replacement of {@link ConsumerContext}
64 * so this method is not needed in case of Provider.
69 public final void onSessionInitialized(ConsumerContext session) {