Example usage for com.google.gwt.user.client.rpc.impl AbstractSerializationStream FLAG_ELIDE_TYPE_NAMES

List of usage examples for com.google.gwt.user.client.rpc.impl AbstractSerializationStream FLAG_ELIDE_TYPE_NAMES

Introduction

In this page you can find the example usage for com.google.gwt.user.client.rpc.impl AbstractSerializationStream FLAG_ELIDE_TYPE_NAMES.

Prototype

int FLAG_ELIDE_TYPE_NAMES

To view the source code for com.google.gwt.user.client.rpc.impl AbstractSerializationStream FLAG_ELIDE_TYPE_NAMES.

Click Source Link

Document

Indicates that obfuscated type names should be used in the RPC payload.

Usage

From source file:com.brightedu.server.util.MyRPC.java

License:Apache License

/**
 * Given a type identifier in the stream, attempt to deobfuscate it. Retuns
 * the original identifier if deobfuscation is unnecessary or no mapping is
 * known./*from  w  w  w  .  ja  v a  2  s .  c o  m*/
 */
private static String maybeDeobfuscate(ServerSerializationStreamReader streamReader, String name)
        throws SerializationException {
    int index;
    if (streamReader.hasFlags(AbstractSerializationStream.FLAG_ELIDE_TYPE_NAMES)) {
        SerializationPolicy serializationPolicy = streamReader.getSerializationPolicy();
        if (!(serializationPolicy instanceof TypeNameObfuscator)) {
            throw new IncompatibleRemoteServiceException("RPC request was encoded with obfuscated type names, "
                    + "but the SerializationPolicy in use does not implement "
                    + TypeNameObfuscator.class.getName());
        }

        String maybe = ((TypeNameObfuscator) serializationPolicy).getClassNameForTypeId(name);
        if (maybe != null) {
            return maybe;
        }
    } else if ((index = name.indexOf('/')) != -1) {
        return name.substring(0, index);
    }
    return name;
}

From source file:org.slim3.gwt.server.rpc.GWTServiceServlet.java

License:Apache License

/**
 * Returns class name.//from   w ww.j a v a 2s. c o  m
 * 
 * @param streamReader
 *            the stream reader
 * @return class name
 * @throws SerializationException
 *             if {@link SerializationException} occurred
 */
protected String readClassName(ServerSerializationStreamReader streamReader) throws SerializationException {
    String name = streamReader.readString();
    int index;
    if (streamReader.hasFlags(AbstractSerializationStream.FLAG_ELIDE_TYPE_NAMES)) {
        SerializationPolicy serializationPolicy = streamReader.getSerializationPolicy();
        if (!(serializationPolicy instanceof TypeNameObfuscator)) {
            throw new IncompatibleRemoteServiceException("RPC request was encoded with obfuscated type names, "
                    + "but the SerializationPolicy in use does not implement "
                    + TypeNameObfuscator.class.getName());
        }
        String maybe = ((TypeNameObfuscator) serializationPolicy).getClassNameForTypeId(name);
        if (maybe != null) {
            return maybe;
        }
    } else if ((index = name.indexOf('/')) != -1) {
        return name.substring(0, index);
    }
    return name;
}