RemoteServiceAsyncValidator.logValidAsyncInterfaceDeclaration(logger, serviceIntf);
throw new UnableToCompleteException();
}
if (checkAlreadyGenerated(typeOracle, serviceIntf)) {
return new RebindResult(RebindMode.USE_EXISTING, getProxyQualifiedName());
}
// Make sure that the async and synchronous versions of the RemoteService
// agree with one another
//
RemoteServiceAsyncValidator rsav = new RemoteServiceAsyncValidator(logger, typeOracle);
Map<JMethod, JMethod> syncMethToAsyncMethMap = rsav.validate(logger, serviceIntf, serviceAsync);
final PropertyOracle propertyOracle = context.getPropertyOracle();
// Load the blacklist/whitelist
TypeFilter blacklistTypeFilter = new BlacklistTypeFilter(logger, propertyOracle);
// Determine the set of serializable types
Event event = SpeedTracerLogger.start(CompilerEventType.GENERATOR_RPC_STOB);
SerializableTypeOracle typesSentFromBrowser;
SerializableTypeOracle typesSentToBrowser;
String rpcLog = null;
try {
SerializableTypeOracleBuilder typesSentFromBrowserBuilder =
new SerializableTypeOracleBuilder(logger, propertyOracle, context);
typesSentFromBrowserBuilder.setTypeFilter(blacklistTypeFilter);
SerializableTypeOracleBuilder typesSentToBrowserBuilder =
new SerializableTypeOracleBuilder(logger, propertyOracle, context);
typesSentToBrowserBuilder.setTypeFilter(blacklistTypeFilter);
addRoots(logger, typeOracle, typesSentFromBrowserBuilder, typesSentToBrowserBuilder);
// Decide what types to send in each direction.
{
if (logger.isLoggable(TreeLogger.Type.DEBUG)) {
// Log the decisions to a string that will be written later in this method
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
typesSentFromBrowserBuilder.setLogOutputWriter(writer);
typesSentToBrowserBuilder.setLogOutputWriter(writer);
writer.write("====================================\n");
writer.write("Types potentially sent from browser:\n");
writer.write("====================================\n\n");
writer.flush();
typesSentFromBrowser = typesSentFromBrowserBuilder.build(logger);
writer.write("===================================\n");
writer.write("Types potentially sent from server:\n");
writer.write("===================================\n\n");
writer.flush();
typesSentToBrowser = typesSentToBrowserBuilder.build(logger);
writer.close();
rpcLog = stringWriter.toString();
} else {
typesSentFromBrowser = typesSentFromBrowserBuilder.build(logger);
typesSentToBrowser = typesSentToBrowserBuilder.build(logger);
}
}
} finally {
event.end();
}
// Check previous cached result, to see if we can return now
if (checkCachedGeneratorResultValid(logger, context, typesSentFromBrowser, typesSentToBrowser)) {
logger.log(TreeLogger.TRACE, "Reusing all cached artifacts for " + getProxyQualifiedName());
return new RebindResult(RebindMode.USE_ALL_CACHED, getProxyQualifiedName());
}
try {
ConfigurationProperty prop =
context.getPropertyOracle().getConfigurationProperty(
TypeSerializerCreator.GWT_ELIDE_TYPE_NAMES_FROM_RPC);
elideTypeNames = Boolean.parseBoolean(prop.getValues().get(0));
} catch (BadPropertyValueException e) {
logger.log(TreeLogger.ERROR, "Configuration property "
+ TypeSerializerCreator.GWT_ELIDE_TYPE_NAMES_FROM_RPC
+ " is not defined. Is RemoteService.gwt.xml inherited?");
throw new UnableToCompleteException();
}
SourceWriter srcWriter = getSourceWriter(logger, context, serviceAsync);
if (srcWriter == null) {
// don't expect this to occur, but could happen if an instance was
// recently generated but not yet committed
return new RebindResult(RebindMode.USE_EXISTING, getProxyQualifiedName());
}
generateTypeHandlers(logger, context, typesSentFromBrowser, typesSentToBrowser);
String serializationPolicyStrongName =
writeSerializationPolicyFile(logger, context, typesSentFromBrowser, typesSentToBrowser);
String remoteServiceInterfaceName =
elideTypeNames ? TypeNameObfuscator.SERVICE_INTERFACE_ID : SerializationUtils
.getRpcTypeName(serviceIntf);
generateProxyFields(srcWriter, typesSentFromBrowser, serializationPolicyStrongName,
remoteServiceInterfaceName);
generateProxyContructor(srcWriter);
generateProxyMethods(srcWriter, typesSentFromBrowser, typeOracle, syncMethToAsyncMethMap);
generateStreamWriterOverride(srcWriter);
generateCheckRpcTokenTypeOverride(srcWriter, typeOracle, typesSentFromBrowser);
srcWriter.commit(logger);
if (rpcLog != null) {
// Create an artifact explaining STOB's decisions. It will be emitted by
// RpcLogLinker
context.commitArtifact(logger, new RpcLogArtifact(serviceIntf.getQualifiedSourceName(),
serializationPolicyStrongName, rpcLog));
}
if (checkGeneratorResultCacheability(context)) {
/*
* Create a new cacheable result. The mode is set to
* RebindMode.USE_PARTIAL_CACHED, since we are allowing reuse of cached
* results for field serializers, when available, but all other types have
* been newly generated.
*/
RebindResult result =
new RebindResult(RebindMode.USE_PARTIAL_CACHED, getProxyQualifiedName());
// Remember the type info that we care about for cache reuse testing.
CachedRpcTypeInformation cti =
new CachedRpcTypeInformation(typesSentFromBrowser, typesSentToBrowser,
customSerializersUsed, typesNotUsingCustomSerializers);
CachedPropertyInformation cpi =
new CachedPropertyInformation(logger, context.getPropertyOracle(), selectionPropsToCheck,
configPropsToCheck);
result.putClientData(CACHED_TYPE_INFO_KEY, cti);
result.putClientData(CACHED_PROPERTY_INFO_KEY, cpi);
return result;
} else {
return new RebindResult(RebindMode.USE_ALL_NEW_WITH_NO_CACHING, getProxyQualifiedName());
}
}