Exposed binding-rpc-registry to config subsystem. 90/3390/1
authorTony Tkacik <ttkacik@cisco.com>
Tue, 3 Dec 2013 09:26:38 +0000 (10:26 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Tue, 3 Dec 2013 09:26:38 +0000 (10:26 +0100)
Change-Id: I68920fd7547bab5dd868140322db03366e0d15a3
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend
opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang

index 1762aac..9381a5a 100644 (file)
@@ -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<? extends DataObject> root = InstanceIdentifier.builder().toInstance();
@@ -188,22 +189,30 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable {
      * Registers RPC Implementation
      * 
      */
-    def <T extends RpcService> registerRpcImplementation(Class<T> type, T service, OsgiProviderContext context,
-        Hashtable<String, String> properties) {
+    override <T extends RpcService> addRpcImplementation(Class<T> 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<T>(type, service, osgiReg, this);
+        return new RpcServiceRegistrationImpl<T>(type, service, this);
     }
 
-    def <T extends RpcService> RoutedRpcRegistration<T> registerRoutedRpcImplementation(Class<T> type, T service,
-        OsgiProviderContext context) {
+    override <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> 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<T>(service, router, this)
     }
+    
+    override <T extends RpcService> getRpcService(Class<T> service) {
+        checkNotNull(service, "Service should not be null");
+        return getManagedDirectProxy(service) as T;
+    }
 
     private def <T extends RpcService> RpcRouter<T> resolveRpcRouter(Class<T> type) {
 
@@ -357,16 +366,14 @@ class RoutedRpcRegistrationImpl<T extends RpcService> extends AbstractObjectRegi
 
 class RpcServiceRegistrationImpl<T extends RpcService> extends AbstractObjectRegistration<T> implements RpcRegistration<T> {
 
-    val ServiceRegistration<T> osgiRegistration;
     private var BindingAwareBrokerImpl broker;
 
     @Property
     val Class<T> serviceType;
 
-    public new(Class<T> type, T service, ServiceRegistration<T> osgiReg, BindingAwareBrokerImpl broker) {
+    public new(Class<T> type, T service, BindingAwareBrokerImpl broker) {
         super(service);
         this._serviceType = type;
-        this.osgiRegistration = osgiReg;
         this.broker = broker;
     }
 
index 7fd3fd2..d1ec351 100644 (file)
@@ -33,22 +33,13 @@ class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext
     }
 
     override <T extends RpcService> addRpcImplementation(Class<T> type, T implementation) {
-
-        // TODO Auto-generated method stub
-        val properties = new Hashtable<String, String>();
-        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 <T extends RpcService> addRoutedRpcImplementation(Class<T> 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;
     }
index 38770c1..9da073f 100644 (file)
@@ -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;
     }