- def <T extends RpcService> Class<? extends T> generateDirectProxy(Class<T> iface) {
- val supertype = iface.asCtClass
- val targetCls = createClass(iface.directProxyName, supertype) [
- field(DELEGATE_FIELD, iface);
- implementMethodsFrom(supertype) [
- body = '''return ($r) «DELEGATE_FIELD».«it.name»($$);'''
- ]
- ]
- return targetCls.toClass(iface.classLoader)
- }
-
- def <T extends RpcService> Class<? extends T> generateRouter(Class<T> iface) {
- val supertype = iface.asCtClass
- val targetCls = createClass(iface.routerName, supertype) [
- //field(ROUTING_TABLE_FIELD,Map)
- field(DELEGATE_FIELD, iface)
- val contexts = new HashMap<String, Class<? extends BaseIdentity>>();
- // We search for routing pairs and add fields
- supertype.methods.filter[declaringClass == supertype && parameterTypes.size === 1].forEach [ method |
- val routingPair = method.routingContextInput;
- if (routingPair !== null)
- contexts.put(routingPair.context.routingTableField, routingPair.context);
- ]
- for (ctx : contexts.entrySet) {
- field(ctx.key, Map)
+ override directProxySupplier(Class iface) {
+ return [|
+ val proxyName = iface.directProxyName;
+ val potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(proxyName)
+ if(potentialClass != null) {
+ return potentialClass.newInstance as RpcService;