Merge "Devices dashlet show port total numbers, modal shows collapsible list Replaced...
[controller.git] / opendaylight / sal / yang-prototype / sal / sal-binding-broker-impl / src / main / java / org / opendaylight / controller / sal / binding / impl / OsgiProviderContext.xtend
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.binding.impl;
9
10 import java.util.HashMap;
11 import java.util.Hashtable;
12 import java.util.Map;
13
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
15 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcServiceRegistration;
16 import org.opendaylight.yangtools.yang.binding.RpcService;
17 import org.osgi.framework.BundleContext;
18
19 import static extension org.opendaylight.controller.sal.binding.impl.utils.PropertiesUtils.*;
20
21 class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext {
22
23     @Property
24     val Map<Class<? extends RpcService>, RpcServiceRegistrationImpl<? extends RpcService>> registeredServices
25
26     new(BundleContext ctx, BindingAwareBrokerImpl broker) {
27         super(ctx, broker);
28         _registeredServices = new HashMap();
29     }
30
31     override def <T extends RpcService> RpcServiceRegistration<T> addRpcImplementation(Class<T> type, T implementation) {
32
33         // TODO Auto-generated method stub
34         val properties = new Hashtable<String, String>();
35         properties.salServiceType = Constants.SAL_SERVICE_TYPE_PROVIDER
36
37         // Fill requirements
38         val salReg = broker.registerRpcImplementation(type, implementation, this, properties)
39         registeredServices.put(type, salReg)
40         return salReg;
41     }
42 }