c769ca1ee38509fa3dbebd52948f81735fddf59c
[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 org.opendaylight.controller.sal.binding.impl.osgi.Constants.*;
20 import static extension org.opendaylight.controller.sal.binding.impl.osgi.PropertiesUtils.*;
21
22 class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext {
23
24     @Property
25     val Map<Class<? extends RpcService>, RpcServiceRegistrationImpl<? extends RpcService>> registeredServices
26
27     new(BundleContext ctx, BindingAwareBrokerImpl broker) {
28         super(ctx, broker);
29         _registeredServices = new HashMap();
30     }
31
32     override def <T extends RpcService> RpcServiceRegistration<T> addRpcImplementation(Class<T> type, T implementation) {
33
34         // TODO Auto-generated method stub
35         val properties = new Hashtable<String, String>();
36         properties.salServiceType = SAL_SERVICE_TYPE_PROVIDER
37
38         // Fill requirements
39         val salReg = broker.registerRpcImplementation(type, implementation, this, properties)
40         registeredServices.put(type, salReg)
41         return salReg;
42     }
43 }