1 16 package com.google.gwt.user.rebind.rpc; 17 18 import com.google.gwt.core.ext.Generator; 19 import com.google.gwt.core.ext.GeneratorContext; 20 import com.google.gwt.core.ext.TreeLogger; 21 import com.google.gwt.core.ext.UnableToCompleteException; 22 import com.google.gwt.core.ext.typeinfo.JClassType; 23 import com.google.gwt.core.ext.typeinfo.TypeOracle; 24 25 29 public class ServiceInterfaceProxyGenerator extends Generator { 30 31 public String generate(TreeLogger logger, GeneratorContext ctx, 32 String requestedClass) throws UnableToCompleteException { 33 34 TypeOracle typeOracle = ctx.getTypeOracle(); 35 assert (typeOracle != null); 36 37 JClassType remoteService = typeOracle.findType(requestedClass); 38 if (remoteService == null) { 39 logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" 40 + requestedClass + "'", null); 41 throw new UnableToCompleteException(); 42 } 43 44 if (remoteService.isInterface() == null) { 45 logger.log(TreeLogger.ERROR, remoteService.getQualifiedSourceName() 46 + " is not an interface", null); 47 throw new UnableToCompleteException(); 48 } 49 50 ProxyCreator proxyCreator = new ProxyCreator(remoteService); 51 52 TreeLogger proxyLogger = logger.branch(TreeLogger.DEBUG, 53 "Generating client proxy for remote service interface '" 54 + remoteService.getQualifiedSourceName() + "'", null); 55 56 return proxyCreator.create(proxyLogger, ctx); 57 } 58 } 59 | Popular Tags |