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