X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fimpl%2FBindingAwareBrokerImpl.xtend;h=b4bf3f5a83cbcaff144af392ee2f1141235aa753;hb=9212fed678702583f4a555641208cf1c7b45b829;hp=2bae9f515f40bfe4ed25e95ccd4426493c413a22;hpb=84d9bf62ad4291a3baba3a747cf77e81bb2d3aeb;p=controller.git 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 2bae9f515f..b4bf3f5a83 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 @@ -9,65 +9,41 @@ package org.opendaylight.controller.sal.binding.impl import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer import org.opendaylight.controller.sal.binding.api.BindingAwareProvider -import org.opendaylight.yangtools.yang.binding.RpcService -import javassist.ClassPool import org.osgi.framework.BundleContext -import java.util.Map -import java.util.HashMap -import javassist.LoaderClassPath import org.opendaylight.controller.sal.binding.api.BindingAwareBroker -import java.util.Hashtable -import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.* - import org.opendaylight.controller.sal.binding.api.NotificationProviderService -import org.osgi.framework.ServiceRegistration -import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.* -import static extension org.opendaylight.controller.sal.binding.impl.osgi.PropertiesUtils.* -import org.opendaylight.controller.sal.binding.api.NotificationService import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext - -import org.slf4j.LoggerFactory -import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator import org.opendaylight.yangtools.yang.binding.InstanceIdentifier -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration +import org.opendaylight.yangtools.yang.binding.DataObject +import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener +import org.opendaylight.controller.sal.binding.spi.RpcContextIdentifier import org.opendaylight.controller.sal.binding.api.data.DataProviderService -import org.opendaylight.controller.sal.binding.api.data.DataBrokerService +import org.slf4j.LoggerFactory -class BindingAwareBrokerImpl implements BindingAwareBroker { +class BindingAwareBrokerImpl extends RpcProviderRegistryImpl implements BindingAwareBroker, AutoCloseable { private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl) - private val clsPool = ClassPool.getDefault() - private var RuntimeCodeGenerator generator; - private Map, RpcProxyContext> managedProxies = new HashMap(); - private var NotificationBrokerImpl notifyBroker - private var DataBrokerImpl dataBroker - private var ServiceRegistration notifyBrokerRegistration + private InstanceIdentifier root = InstanceIdentifier.builder().toInstance(); + + @Property + private var NotificationProviderService notifyBroker + + @Property + private var DataProviderService dataBroker @Property var BundleContext brokerBundleContext - def start() { - initGenerator(); + public new(String name,BundleContext bundleContext) { + super(name); + _brokerBundleContext = bundleContext; + } - // Initialization of notificationBroker - notifyBroker = new NotificationBrokerImpl(null); - dataBroker = new DataBrokerImpl(); - val brokerProperties = newProperties(); - notifyBrokerRegistration = brokerBundleContext.registerService(NotificationProviderService, notifyBroker, - brokerProperties) - brokerBundleContext.registerService(NotificationService, notifyBroker, brokerProperties) - brokerBundleContext.registerService(DataProviderService,dataBroker,brokerProperties) - brokerBundleContext.registerService(DataBrokerService,dataBroker,brokerProperties) - + def start() { + log.info("Starting MD-SAL: Binding Aware Broker"); } - def initGenerator() { - // YANG Binding Class Loader - clsPool.appendClassPath(new LoaderClassPath(RpcService.classLoader)); - generator = new RuntimeCodeGenerator(clsPool); - } override registerConsumer(BindingAwareConsumer consumer, BundleContext bundleCtx) { val ctx = consumer.createContext(bundleCtx) @@ -90,57 +66,11 @@ class BindingAwareBrokerImpl implements BindingAwareBroker { new OsgiProviderContext(providerCtx, this) } - /** - * Returns a Managed Direct Proxy for supplied class - * - * Managed direct proxy is a generated proxy class conforming to the supplied interface - * which delegates all calls to the backing delegate. - * - * Proxy does not do any validation, null pointer checks or modifies data in any way, it - * is only use to avoid exposing direct references to backing implementation of service. - * - * If proxy class does not exist for supplied service class it will be generated automatically. - */ - def getManagedDirectProxy(Class service) { - - var RpcProxyContext existing = null - if((existing = managedProxies.get(service)) != null) { - return existing.proxy - } - val proxyClass = generator.generateDirectProxy(service) - val rpcProxyCtx = new RpcProxyContext(proxyClass) - val properties = new Hashtable() - rpcProxyCtx.proxy = proxyClass.newInstance as RpcService - - properties.salServiceType = SAL_SERVICE_TYPE_CONSUMER_PROXY - rpcProxyCtx.registration = brokerBundleContext.registerService(service, rpcProxyCtx.proxy as T, properties) - managedProxies.put(service, rpcProxyCtx) - return rpcProxyCtx.proxy - } - - /** - * Registers RPC Implementation - * - */ - def registerRpcImplementation(Class type, T service, OsgiProviderContext context, - Hashtable properties) { - val proxy = getManagedDirectProxy(type) - if(proxy.delegate != null) { - throw new IllegalStateException("Service " + type + "is already registered"); - } - val osgiReg = context.bundleContext.registerService(type, service, properties); - proxy.delegate = service; - return new RpcServiceRegistrationImpl(type, service, osgiReg); + override >> registerRouteChangeListener(L listener) { + super.registerRouteChangeListener(listener) } - - def RpcRegistration registerMountedRpcImplementation(Class tyoe, T service, InstanceIdentifier identifier, - OsgiProviderContext context, Hashtable properties) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - def RoutedRpcRegistration registerRoutedRpcImplementation(Class type, T service, OsgiProviderContext context, - Hashtable properties) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") + + override close() throws Exception { + } - -} +} \ No newline at end of file