Example usage for com.google.gwt.core.ext RebindResult putClientData

List of usage examples for com.google.gwt.core.ext RebindResult putClientData

Introduction

In this page you can find the example usage for com.google.gwt.core.ext RebindResult putClientData.

Prototype

public void putClientData(String key, Serializable data) 

Source Link

Document

Adds keyed, serializable data to a rebind result.

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);
    }/*  www. ja  v  a  2  s .c o m*/

    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);
    }
}