From 78e42e4bd1e55392fff88976b3867b7f40492236 Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Tue, 3 Dec 2013 10:26:38 +0100 Subject: [PATCH] Exposed binding-rpc-registry to config subsystem. Change-Id: I68920fd7547bab5dd868140322db03366e0d15a3 Signed-off-by: Tony Tkacik --- .../binding/impl/BindingAwareBrokerImpl.xtend | 27 ++++++++++++------- .../binding/impl/OsgiProviderContext.xtend | 13 ++------- .../opendaylight-binding-broker-impl.yang | 1 + 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend index 1762aac090..9381a5a070 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend @@ -48,8 +48,9 @@ import java.util.concurrent.locks.ReentrantLock import java.util.concurrent.Callable import java.util.WeakHashMap import javax.annotation.concurrent.GuardedBy +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry -class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable { +class BindingAwareBrokerImpl implements BindingAwareBroker, RpcProviderRegistry, AutoCloseable { private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl) private InstanceIdentifier root = InstanceIdentifier.builder().toInstance(); @@ -188,22 +189,30 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable { * Registers RPC Implementation * */ - def registerRpcImplementation(Class type, T service, OsgiProviderContext context, - Hashtable properties) { + override addRpcImplementation(Class type, T service) { + checkNotNull(type, "Service type should not be null") + checkNotNull(service, "Service type should not be null") + val proxy = getManagedDirectProxy(type) checkState(proxy.delegate === null, "The Service for type %s is already registered", type) - val osgiReg = context.bundleContext.registerService(type, service, properties); proxy.delegate = service; - return new RpcServiceRegistrationImpl(type, service, osgiReg, this); + return new RpcServiceRegistrationImpl(type, service, this); } - def RoutedRpcRegistration registerRoutedRpcImplementation(Class type, T service, - OsgiProviderContext context) { + override RoutedRpcRegistration addRoutedRpcImplementation(Class type, T service) { + checkNotNull(type, "Service type should not be null") + checkNotNull(service, "Service type should not be null") + val router = resolveRpcRouter(type); checkState(router !== null) return new RoutedRpcRegistrationImpl(service, router, this) } + + override getRpcService(Class service) { + checkNotNull(service, "Service should not be null"); + return getManagedDirectProxy(service) as T; + } private def RpcRouter resolveRpcRouter(Class type) { @@ -357,16 +366,14 @@ class RoutedRpcRegistrationImpl extends AbstractObjectRegi class RpcServiceRegistrationImpl extends AbstractObjectRegistration implements RpcRegistration { - val ServiceRegistration osgiRegistration; private var BindingAwareBrokerImpl broker; @Property val Class serviceType; - public new(Class type, T service, ServiceRegistration osgiReg, BindingAwareBrokerImpl broker) { + public new(Class type, T service, BindingAwareBrokerImpl broker) { super(service); this._serviceType = type; - this.osgiRegistration = osgiReg; this.broker = broker; } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend index 7fd3fd24d8..d1ec35157f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend @@ -33,22 +33,13 @@ class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext } override addRpcImplementation(Class type, T implementation) { - - // TODO Auto-generated method stub - val properties = new Hashtable(); - properties.salServiceType = SAL_SERVICE_TYPE_PROVIDER - - // Fill requirements - val salReg = broker.registerRpcImplementation(type, implementation, this, properties) + val salReg = broker.addRpcImplementation(type, implementation) registeredServices.put(type, salReg) return salReg; } override addRoutedRpcImplementation(Class type, T implementation) throws IllegalStateException { - checkNotNull(type, "Service type should not be null") - checkNotNull(implementation, "Service type should not be null") - - val salReg = broker.registerRoutedRpcImplementation(type, implementation, this) + val salReg = broker.addRoutedRpcImplementation(type, implementation) registeredServices.put(type, salReg) return salReg; } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang b/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang index 38770c193c..9da073f71b 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang +++ b/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang @@ -25,6 +25,7 @@ module opendaylight-sal-binding-broker-impl { identity binding-broker-impl { base config:module-type; config:provided-service sal:binding-broker-osgi-registry; + config:provided-service sal:binding-rpc-registry; config:java-name-prefix BindingBrokerImpl; } -- 2.36.6