- 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) {
- metadata.contexts.add(routingPair.context)
- metadata.rpcMethods.put(method.name,routingPair)
- val input = routingPair.inputType.javaClass as Class<? extends DataContainer>;
- metadata.supportedInputs.add(input);
- metadata.rpcInputs.put(input,routingPair);
- }
- ]
- return metadata;
- }
-
- private def getRpcMetadata(CtMethod method) {
- val inputClass = method.parameterTypes.get(0);
- return inputClass.rpcMethodMetadata(inputClass,method.name);
- }
-
- 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);
- }
- }
- }
- }
- for (iface : dataClass.interfaces) {
- val ret = rpcMethodMetadata(iface,inputClass,rpcMethod);
- if(ret != null) return ret;
- }
- return null;
- }
-
- private def getJavaClass(CtClass cls) {
- Thread.currentThread.contextClassLoader.loadClass(cls.name)
- }
-
- override getInvokerFactory() {
- return this;
- }
-
- override invokerFor(NotificationListener instance) {
- val cls = instance.class
- val prototype = resolveInvokerClass(cls);
-
- return new RuntimeGeneratedInvoker(instance, prototype)