X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fsal%2Fsal-binding-broker-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fimpl%2FBindingAwareBrokerImpl.xtend;fp=opendaylight%2Fsal%2Fyang-prototype%2Fsal%2Fsal-binding-broker-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fimpl%2FBindingAwareBrokerImpl.xtend;h=4f7d41a12c7e86bf5d1696cc9a7d5a26d8ee245f;hb=3a4033c1c3589c009aa724d7e27c2ac4e312971a;hp=74ef87ae5afd4713f135a8feb05d2a4e306f58a5;hpb=8c9a1cf398348546e6e5ba74a2012ed942a2fddb;p=controller.git diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend index 74ef87ae5a..4f7d41a12c 100644 --- a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend +++ b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend @@ -38,7 +38,8 @@ class BindingAwareBrokerImpl implements BindingAwareBroker { private Map, RpcProxyContext> managedProxies = new HashMap(); private var NotificationBrokerImpl notifyBroker private var ServiceRegistration notifyBrokerRegistration - + private var DataBrokerImpl dataBroker + @Property var BundleContext brokerBundleContext @@ -80,6 +81,17 @@ 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 @@ -115,6 +127,10 @@ class BindingAwareBrokerImpl implements BindingAwareBroker { return proxyCls.toClass(delegate.classLoader) } + /** + * Registers RPC Implementation + * + */ def registerRpcImplementation(Class type, T service, OsgiProviderContext context, Hashtable properties) { val proxy = getManagedDirectProxy(type) @@ -126,12 +142,26 @@ class BindingAwareBrokerImpl implements BindingAwareBroker { return new RpcServiceRegistrationImpl(type, service, osgiReg); } + /** + * Helper method to return delegate from ManagedDirectedProxy with use of reflection. + * + * Note: This method uses reflection, but access to delegate field should be + * avoided and called only if neccessary. + * + */ def getDelegate(RpcService proxy) { val field = proxy.class.getField(DELEGATE_FIELD) if(field == null) throw new UnsupportedOperationException("Unable to get delegate from proxy"); return field.get(proxy) as T } + /** + * Helper method to set delegate to ManagedDirectedProxy with use of reflection. + * + * Note: This method uses reflection, but setting delegate field should not occur too much + * to introduce any significant performance hits. + * + */ def void setDelegate(RpcService proxy, RpcService delegate) { val field = proxy.class.getField(DELEGATE_FIELD) if(field == null) throw new UnsupportedOperationException("Unable to set delegate to proxy");