Merge "Leafref and identityref types to Json"
[controller.git] / opendaylight / md-sal / sal-binding-broker / 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.yangtools.yang.binding.RpcService;
16 import org.osgi.framework.BundleContext;
17
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.*
24
25 class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext {
26
27     @Property
28     val Map<Class<? extends RpcService>, RpcRegistration<? extends RpcService>> registeredServices
29
30     new(BundleContext ctx, BindingAwareBrokerImpl broker) {
31         super(ctx, broker);
32         _registeredServices = new HashMap();
33     }
34
35     override <T extends RpcService> addRpcImplementation(Class<T> type, T implementation) {
36         val salReg = broker.addRpcImplementation(type, implementation)
37         registeredServices.put(type, salReg)
38         return salReg;
39     }
40
41     override <T extends RpcService> addRoutedRpcImplementation(Class<T> type, T implementation) throws IllegalStateException {
42         val salReg = broker.addRoutedRpcImplementation(type, implementation)
43         registeredServices.put(type, salReg)
44         return salReg;
45     }
46
47     override registerFunctionality(ProviderFunctionality functionality) {
48         // NOOP for now
49     }
50
51     override unregisterFunctionality(ProviderFunctionality functionality) {
52         // NOOP for now
53     }
54 }