Example usage for com.google.gwt.rpc.linker CastableTypeDataImpl CastableTypeDataImpl

List of usage examples for com.google.gwt.rpc.linker CastableTypeDataImpl CastableTypeDataImpl

Introduction

In this page you can find the example usage for com.google.gwt.rpc.linker CastableTypeDataImpl CastableTypeDataImpl.

Prototype

public CastableTypeDataImpl(String castableTypeMapJs) 

Source Link

Usage

From source file:com.didactilab.gwt.phprpc.linker.PhpClientOracleLinker.java

License:Apache License

@Override
public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean onePermutation)
        throws UnableToCompleteException {

    if (onePermutation) {
        artifacts = new ArtifactSet(artifacts);

        Map<String, List<String>> allSerializableFields = new HashMap<String, List<String>>();

        for (RpcDataArtifact data : artifacts.find(RpcDataArtifact.class)) {
            allSerializableFields.putAll(data.getOperableFields());
        }/*from w  w w.  j a va 2 s.  co  m*/

        for (CompilationResult result : artifacts.find(CompilationResult.class)) {
            PhpWebClientOracleBuilder builder = new PhpWebClientOracleBuilder();

            for (Map.Entry<String, List<String>> entry : allSerializableFields.entrySet()) {
                builder.setSerializableFields(entry.getKey(), entry.getValue());
            }

            for (SymbolData symbolData : result.getSymbolMap()) {

                String castableTypeMapString = (symbolData.getCastableTypeMap() == null) ? null
                        : symbolData.getCastableTypeMap().toJs();

                builder.add(symbolData.getSymbolName(), symbolData.getJsniIdent(), symbolData.getClassName(),
                        symbolData.getMemberName(), symbolData.getQueryId(),
                        new CastableTypeDataImpl(castableTypeMapString));
            }

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            try {
                builder.store(out);
            } catch (IOException e) {
                // Should generally not happen
                logger.log(TreeLogger.ERROR, "Unable to store deRPC data", e);
                throw new UnableToCompleteException();
            }

            SyntheticArtifact a = emitBytes(logger, out.toByteArray(), result.getStrongName() + SUFFIX);
            artifacts.add(a);
        }
    }
    return artifacts;
}