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%2Fcodegen%2Fimpl%2FRuntimeCodeGenerator.xtend;h=90fcbd99aaaad0a6f6448faf0428cbc46cc52b4d;hb=10ba5a102f9e15a24c3f5a355a44fafadbf2801f;hp=93c192c0af54222533da37727f4575520dea9259;hpb=81a6e2e3fc28063a043ef14aabdd68d7ccab85b2;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend index 93c192c0af..90fcbd99aa 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend @@ -11,7 +11,6 @@ import javassist.ClassPool import org.opendaylight.yangtools.yang.binding.RpcService import javassist.CtClass -import static com.google.common.base.Preconditions.* import javassist.CtMethod import org.opendaylight.yangtools.yang.binding.InstanceIdentifier import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext @@ -58,16 +57,21 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co val targetCls = createClass(iface.directProxyName, supertype) [ field(DELEGATE_FIELD, iface); implementMethodsFrom(supertype) [ - body = '''return ($r) «DELEGATE_FIELD».«it.name»($$);''' + body = ''' + { + if(«DELEGATE_FIELD» == null) { + throw new java.lang.IllegalStateException("No provider is processing supplied message"); + } + return ($r) «DELEGATE_FIELD».«it.name»($$); + } + ''' ] ] return targetCls.toClass(iface.classLoader).newInstance as T } override getRouterFor(Class iface) { - val contexts = new HashSet> - - val instance = >withClassLoader(iface.classLoader) [ | + val instance = >withClassLoaderAndLock(iface.classLoader,lock) [ | val supertype = iface.asCtClass val metadata = supertype.rpcMetadata; val targetCls = createClass(iface.routerName, supertype) [ @@ -210,7 +214,7 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co ] val finalClass = targetCls.toClass(iface.classLoader, iface.protectionDomain) return new RuntimeGeneratedInvokerPrototype(supportedNotification, - finalClass as Class); + finalClass as Class>); } @@ -218,13 +222,16 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co protected def resolveInvokerClass(Class class1) { - val invoker = invokerClasses.get(class1); - if (invoker !== null) { - return invoker; - } - val newInvoker = generateListenerInvoker(class1); - invokerClasses.put(class1, newInvoker); - return newInvoker + return withClassLoaderAndLock(class1.classLoader,lock) [| + val invoker = invokerClasses.get(class1); + if (invoker !== null) { + return invoker; + } + val newInvoker = generateListenerInvoker(class1); + invokerClasses.put(class1, newInvoker); + return newInvoker + + ] } } @@ -235,7 +242,7 @@ package class RuntimeGeneratedInvoker implements NotificationInvoker { val NotificationListener delegate; @Property - var org.opendaylight.controller.sal.binding.api.NotificationListener invocationProxy; + var org.opendaylight.controller.sal.binding.api.NotificationListener invocationProxy; @Property var RuntimeGeneratedInvokerPrototype prototype; @@ -243,7 +250,7 @@ package class RuntimeGeneratedInvoker implements NotificationInvoker { new(NotificationListener delegate, RuntimeGeneratedInvokerPrototype prototype) { _delegate = delegate; _prototype = prototype; - _invocationProxy = prototype.protoClass.newInstance; + _invocationProxy = prototype.protoClass.newInstance as org.opendaylight.controller.sal.binding.api.NotificationListener; RuntimeCodeHelper.setDelegate(_invocationProxy, delegate); } @@ -262,7 +269,7 @@ package class RuntimeGeneratedInvokerPrototype { val Set> supportedNotifications; @Property - val Class protoClass; + val Class> protoClass; } package class RpcServiceMetadata {