Example usage for com.google.gwt.user.rebind.rpc CachedRpcTypeInformation CachedRpcTypeInformation

List of usage examples for com.google.gwt.user.rebind.rpc CachedRpcTypeInformation CachedRpcTypeInformation

Introduction

In this page you can find the example usage for com.google.gwt.user.rebind.rpc CachedRpcTypeInformation CachedRpcTypeInformation.

Prototype

public CachedRpcTypeInformation(SerializableTypeOracle typesFromBrowser, SerializableTypeOracle typesToBrowser,
            Set<JType> customSerializersUsed, Set<JType> typesNotUsingCustomSerializers) 

Source Link

Usage

From source file:com.seanchenxi.gwt.storage.rebind.StorageTypeSerializerGenerator.java

License:Apache License

@Override
public RebindResult generateIncrementally(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    TypeOracle typeOracle = context.getTypeOracle();

    JClassType serializerType = typeOracle.findType(typeName);
    if (serializerType == null || serializerType.isInterface() == null)
        throw new UnableToCompleteException();

    final Set<JType> serializables = StorageTypeFinder.getInstance(context, logger).findStorageTypes();

    String typeSerializerClassName = serializerType.getQualifiedSourceName() + TYPE_SERIALIZER_SUFFIX;
    String typeSerializerSimpleName = serializerType.getSimpleSourceName() + TYPE_SERIALIZER_SUFFIX;
    JClassType typeSerializer = typeOracle.findType(typeSerializerClassName);

    SerializableTypeOracle serializationOracle = buildSerializableTypeOracle(logger, context, serializables);

    if (typeSerializer != null && typeSerializer.isClass() != null
            && isNothingChanged(logger, context, serializables, serializationOracle)) {
        return new RebindResult(RebindMode.USE_EXISTING, typeSerializerClassName);
    }/* w w w .j  av a 2  s.  com*/

    TypeSerializerCreator tsc = new TypeSerializerCreator(logger, serializationOracle, serializationOracle,
            context, typeSerializerClassName, typeSerializerSimpleName);
    tsc.realize(logger);

    if (context.isGeneratorResultCachingEnabled()) {
        RebindResult result = new RebindResult(RebindMode.USE_PARTIAL_CACHED, typeSerializerClassName);
        CachedRpcTypeInformation cti = new CachedRpcTypeInformation(serializationOracle, serializationOracle,
                serializables, new HashSet<JType>());
        result.putClientData(ProxyCreator.CACHED_TYPE_INFO_KEY, cti);
        return result;
    } else {
        return new RebindResult(RebindMode.USE_ALL_NEW_WITH_NO_CACHING, typeSerializerClassName);
    }
}