Example usage for com.google.gwt.user.server.rpc.impl SerializedInstanceReference getName

List of usage examples for com.google.gwt.user.server.rpc.impl SerializedInstanceReference getName

Introduction

In this page you can find the example usage for com.google.gwt.user.server.rpc.impl SerializedInstanceReference getName.

Prototype

String getName();

Source Link

Document

Returns the name of the type.

Usage

From source file:com.gdevelop.gwt.syncrpc.SyncClientSerializationStreamReader.java

License:Apache License

protected Object deserialize(String typeSignature) throws SerializationException {
    Object instance = null;/* w  ww .  jav  a 2  s  .com*/
    SerializedInstanceReference serializedInstRef = SerializabilityUtil
            .decodeSerializedInstanceReference(typeSignature);
    try {
        // Class<?> instanceClass =
        // Class.forName(serializedInstRef.getName(),
        // false, null);
        String cn = serializedInstRef.getName();
        Class<?> instanceClass = getClassCached(cn);
        assert (serializationPolicy != null);
        try {
            serializationPolicy.validateDeserialize(instanceClass);
        } catch (SerializationException e) {
            System.err.println("WARN: " + e.getMessage());
        }
        // TODO validateTypeVersions(instanceClass, serializedInstRef);
        Class<?> customSerializer = SerializabilityUtil.hasCustomFieldSerializer(instanceClass);
        int index = reserveDecodedObjectIndex();
        instance = instantiate(customSerializer, instanceClass);
        rememberDecodedObject(index, instance);
        Object replacement = deserializeImpl(customSerializer, instanceClass, instance);
        // It's possible that deserializing an object requires the original
        // proxy
        // object to be replaced.
        if (instance != replacement) {
            rememberDecodedObject(index, replacement);
            instance = replacement;
        }
        return instance;
    } catch (ClassNotFoundException e) {
        throw new SerializationException(e);
    } catch (InstantiationException e) {
        throw new SerializationException(e);
    } catch (IllegalAccessException e) {
        throw new SerializationException(e);
    } catch (IllegalArgumentException e) {
        throw new SerializationException(e);
    } catch (InvocationTargetException e) {
        throw new SerializationException(e);
    } catch (NoSuchMethodException e) {
        throw new SerializationException(e);
    }
}

From source file:org.gwtrpc4j.stream.JClientSerializationStreamReader.java

License:Apache License

@Override
protected Object deserialize(String typeSignature) throws SerializationException {
    Object instance = null;/*from w w  w .  jav  a  2  s  .com*/
    try {
        Class<?> instanceClass;
        if (hasFlags(FLAG_ELIDE_TYPE_NAMES)) {
            if (getSerializationPolicy() instanceof TypeNameObfuscator) {
                TypeNameObfuscator obfuscator = (TypeNameObfuscator) getSerializationPolicy();
                String instanceClassName = obfuscator.getClassNameForTypeId(typeSignature);
                instanceClass = Class.forName(instanceClassName, false, classLoader);
            } else {
                throw new SerializationException(
                        "The GWT module was compiled with RPC type name elision enabled, but "
                                + getSerializationPolicy().getClass().getName() + " does not implement "
                                + TypeNameObfuscator.class.getName());
            }
        } else {
            SerializedInstanceReference serializedInstRef = SerializabilityUtil
                    .decodeSerializedInstanceReference(typeSignature);
            instanceClass = Class.forName(serializedInstRef.getName(), false, classLoader);
            validateTypeVersions(instanceClass, serializedInstRef);
        }

        assert serializationPolicy != null;

        // TODO active the validateDeserialize Policy : read file from the
        // server
        // serializationPolicy.validateDeserialize(instanceClass);

        Class<?> customSerializer = SerializabilityUtil.hasCustomFieldSerializer(instanceClass);

        int index = reserveDecodedObjectIndex();

        instance = instantiate(customSerializer, instanceClass);

        rememberDecodedObject(index, instance);

        Object replacement = deserializeImpl(customSerializer, instanceClass, instance);

        // It's possible that deserializing an object requires the original
        // proxy
        // object to be replaced.
        if (instance != replacement) {
            rememberDecodedObject(index, replacement);
            instance = replacement;
        }

        return instance;

    } catch (ClassNotFoundException e) {
        throw new SerializationException(e);
    } catch (InstantiationException e) {
        throw new SerializationException(e);
    } catch (IllegalAccessException e) {
        throw new SerializationException(e);
    } catch (IllegalArgumentException e) {
        throw new SerializationException(e);
    } catch (InvocationTargetException e) {
        throw new SerializationException(e.getTargetException());
    } catch (NoSuchMethodException e) {
        throw new SerializationException(e);
    }
}