1 package org.opendaylight.controller.sal.dom.broker
3 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession
4 import org.opendaylight.controller.sal.core.api.Provider
5 import org.opendaylight.yangtools.yang.common.QName
6 import org.opendaylight.controller.sal.core.api.RpcImplementation
7 import org.osgi.framework.BundleContext
8 import static java.util.Collections.*
9 import java.util.Collections
10 import java.util.HashMap
12 class ProviderContextImpl extends ConsumerContextImpl implements ProviderSession {
15 private val Provider provider;
17 private val rpcImpls = Collections.synchronizedMap(new HashMap<QName, RpcImplementation>());
19 new(Provider provider, BundleContext ctx) {
21 this._provider = provider;
24 override addRpcImplementation(QName rpcType, RpcImplementation implementation) throws IllegalArgumentException {
26 throw new IllegalArgumentException("rpcType must not be null");
28 if(implementation == null) {
29 throw new IllegalArgumentException("Implementation must not be null");
31 broker.addRpcImplementation(rpcType, implementation);
32 rpcImpls.put(rpcType, implementation);
35 override removeRpcImplementation(QName rpcType, RpcImplementation implToRemove) throws IllegalArgumentException {
36 val localImpl = rpcImpls.get(rpcType);
37 if(localImpl != implToRemove) {
38 throw new IllegalStateException(
39 "Implementation was not registered in this session");
42 broker.removeRpcImplementation(rpcType, implToRemove);
43 rpcImpls.remove(rpcType);