import javassist.CtClass
import javassist.CtMethod
import javassist.LoaderClassPath
-import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper
import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory
-import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker
-import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils
-import org.opendaylight.yangtools.yang.binding.BaseIdentity
import org.opendaylight.yangtools.yang.binding.DataContainer
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
import org.opendaylight.yangtools.yang.binding.Notification
import org.opendaylight.yangtools.yang.binding.NotificationListener
import org.opendaylight.yangtools.yang.binding.RpcImplementation
import org.opendaylight.yangtools.yang.binding.RpcService
-import org.opendaylight.yangtools.yang.binding.annotations.QName
import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext
+import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils
import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification.*
import static extension org.opendaylight.controller.sal.binding.codegen.YangtoolsMappingHelper.*
return inputClass.rpcMethodMetadata(inputClass,method.name);
}
- private def RpcMetadata rpcMethodMetadata(CtClass dataClass,CtClass inputClass,String rpcMethod) {
+ private def RpcMetadata rpcMethodMetadata(CtClass dataClass, CtClass inputClass, String rpcMethod) {
for (method : dataClass.methods) {
if (method.name.startsWith("get") && method.parameterTypes.size === 0) {
for (annotation : method.availableAnnotations) {
if (annotation instanceof RoutingContext) {
val encapsulated = !method.returnType.equals(InstanceIdentifier.asCtClass);
- return new RpcMetadata(null,rpcMethod,(annotation as RoutingContext).value, method, encapsulated,inputClass);
+ return new RpcMetadata(rpcMethod,(annotation as RoutingContext).value, method, encapsulated,inputClass);
}
}
}
val cls = instance.class
val prototype = resolveInvokerClass(cls);
- return new RuntimeGeneratedInvoker(instance, prototype)
+ return RuntimeGeneratedInvoker.create(instance, prototype)
}
protected def generateListenerInvoker(Class<? extends NotificationListener> iface) {
finalClass as Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener<?>>);
}
-
-
-
-
protected def resolveInvokerClass(Class<? extends NotificationListener> class1) {
return ClassLoaderUtils.<RuntimeGeneratedInvokerPrototype>withClassLoaderAndLock(class1.classLoader,lock) [|
val invoker = invokerClasses.get(class1);
val newInvoker = generateListenerInvoker(class1);
invokerClasses.put(class1, newInvoker);
return newInvoker
-
]
}
}
-
-@Data
-package class RuntimeGeneratedInvoker implements NotificationInvoker {
-
- @Property
- val NotificationListener delegate;
-
- @Property
- var org.opendaylight.controller.sal.binding.api.NotificationListener<Notification> invocationProxy;
-
- @Property
- var RuntimeGeneratedInvokerPrototype prototype;
-
- new(NotificationListener delegate, RuntimeGeneratedInvokerPrototype prototype) {
- _delegate = delegate;
- _prototype = prototype;
- _invocationProxy = prototype.protoClass.newInstance as org.opendaylight.controller.sal.binding.api.NotificationListener<Notification>;
- RuntimeCodeHelper.setDelegate(_invocationProxy, delegate);
- }
-
- override getSupportedNotifications() {
- prototype.supportedNotifications;
- }
-
- override close() {
- }
-}
-
-@Data
-package class RpcMetadata {
-
- @Property
- val QName qname;
-
- @Property
- val String methodName;
-
- @Property
- val Class<? extends BaseIdentity> context;
- @Property
- val CtMethod inputRouteGetter;
-
- @Property
- val boolean routeEncapsulated;
-
- @Property
- val CtClass inputType;
-}