Change-Id: I68920fd7547bab5dd868140322db03366e0d15a3
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
import java.util.concurrent.Callable
import java.util.WeakHashMap
import javax.annotation.concurrent.GuardedBy
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();
private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl)
private InstanceIdentifier<? extends DataObject> root = InstanceIdentifier.builder().toInstance();
* Registers RPC Implementation
*
*/
* 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 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;
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)
}
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) {
private def <T extends RpcService> RpcRouter<T> resolveRpcRouter(Class<T> type) {
class RpcServiceRegistrationImpl<T extends RpcService> extends AbstractObjectRegistration<T> implements RpcRegistration<T> {
class RpcServiceRegistrationImpl<T extends RpcService> extends AbstractObjectRegistration<T> implements RpcRegistration<T> {
- val ServiceRegistration<T> osgiRegistration;
private var BindingAwareBrokerImpl broker;
@Property
val Class<T> serviceType;
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;
super(service);
this._serviceType = type;
- this.osgiRegistration = osgiReg;
}
override <T extends RpcService> addRpcImplementation(Class<T> type, T implementation) {
}
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 {
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;
}
registeredServices.put(type, salReg)
return salReg;
}
identity binding-broker-impl {
base config:module-type;
config:provided-service sal:binding-broker-osgi-registry;
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;
}
config:java-name-prefix BindingBrokerImpl;
}