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.impl;
10 import java.util.HashMap;
11 import java.util.Hashtable;
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 import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*;
19 import static extension org.opendaylight.controller.sal.binding.impl.osgi.PropertiesUtils.*;
20 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
22 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality
23 import static com.google.common.base.Preconditions.*
25 class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext {
28 val Map<Class<? extends RpcService>, RpcRegistration<? extends RpcService>> registeredServices
30 new(BundleContext ctx, BindingAwareBrokerImpl broker) {
32 _registeredServices = new HashMap();
35 override <T extends RpcService> addRpcImplementation(Class<T> type, T implementation) {
37 // TODO Auto-generated method stub
38 val properties = new Hashtable<String, String>();
39 properties.salServiceType = SAL_SERVICE_TYPE_PROVIDER
42 val salReg = broker.registerRpcImplementation(type, implementation, this, properties)
43 registeredServices.put(type, salReg)
47 override <T extends RpcService> addRoutedRpcImplementation(Class<T> type, T implementation) throws IllegalStateException {
48 checkNotNull(type, "Service type should not be null")
49 checkNotNull(implementation, "Service type should not be null")
51 val salReg = broker.registerRoutedRpcImplementation(type, implementation, this)
52 registeredServices.put(type, salReg)
56 override registerFunctionality(ProviderFunctionality functionality) {
60 override unregisterFunctionality(ProviderFunctionality functionality) {