import org.opendaylight.yangtools.yang.binding.annotations.QName
import org.opendaylight.yangtools.yang.binding.DataContainer
import org.opendaylight.yangtools.yang.binding.RpcImplementation
-import org.opendaylight.controller.sal.binding.codegen.util.JavassistUtils
-import org.opendaylight.controller.sal.binding.impl.util.ClassLoaderUtils
+import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils
+import org.opendaylight.yangtools.sal.binding.generator.util.ClassLoaderUtils
import javassist.LoaderClassPath
class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator, NotificationInvokerFactory {
body = '''
{
if(«DELEGATE_FIELD» == null) {
- throw new java.lang.IllegalStateException("No provider is processing supplied message");
+ throw new java.lang.IllegalStateException("No default provider is available");
}
return ($r) «DELEGATE_FIELD».«it.name»($$);
}
return instance;
}
- override <T extends RpcService> getRouterFor(Class<T> iface) {
+ override <T extends RpcService> getRouterFor(Class<T> iface,String routerInstanceName) {
val metadata = withClassLoader(iface.classLoader) [|
val supertype = iface.asCtClass
return supertype.rpcMetadata;
]
-
+
val instance = <T>withClassLoaderAndLock(iface.classLoader,lock) [ |
val supertype = iface.asCtClass
val routerName = iface.routerName;
if(potentialClass != null) {
return potentialClass.newInstance as T;
}
-
+
val targetCls = createClass(iface.routerName, supertype) [
-
-
+
+
field(DELEGATE_FIELD, iface)
//field(REMOTE_INVOKER_FIELD,iface);
implementsType(RpcImplementation.asCtClass)
-
+
for (ctx : metadata.contexts) {
field(ctx.routingTableField, Map)
}
instance = «DELEGATE_FIELD»;
}
if(instance == null) {
- throw new java.lang.IllegalStateException("No provider is processing supplied message");
+ throw new java.lang.IllegalStateException("No routable provider is processing routed message for " + String.valueOf(identifier));
}
return ($r) instance.«it.name»($$);
}'''
]
]
return targetCls.toClass(iface.classLoader,iface.protectionDomain).newInstance as T
-
+
];
- return new RpcRouterCodegenInstance(iface, instance, metadata.contexts,metadata.supportedInputs);
+ return new RpcRouterCodegenInstance(routerInstanceName,iface, instance, metadata.contexts,metadata.supportedInputs);
}
private def RpcServiceMetadata getRpcMetadata(CtClass iface) {
val metadata = new RpcServiceMetadata;
-
+
iface.methods.filter[declaringClass == iface && parameterTypes.size === 1].forEach [ method |
val routingPair = method.rpcMetadata;
if (routingPair !== null) {
}
private def getRpcMetadata(CtMethod method) {
- val inputClass = method.parameterTypes.get(0);
+ val inputClass = method.parameterTypes.get(0);
return inputClass.rpcMethodMetadata(inputClass,method.name);
}
finalClass as Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener<?>>);
}
-
+
val newInvoker = generateListenerInvoker(class1);
invokerClasses.put(class1, newInvoker);
return newInvoker
-
+
]
}
}
@Property
val rpcMethods = new HashMap<String, RpcMetadata>();
-
+
@Property
val rpcInputs = new HashMap<Class<? extends DataContainer>, RpcMetadata>();
-
-
+
+
@Property
val supportedInputs = new HashSet<Class<? extends DataContainer>>();
}
@Property
val boolean routeEncapsulated;
-
+
@Property
val CtClass inputType;
}