Example usage for com.google.gwt.rpc.server RPC streamResponseForSuccess

List of usage examples for com.google.gwt.rpc.server RPC streamResponseForSuccess

Introduction

In this page you can find the example usage for com.google.gwt.rpc.server RPC streamResponseForSuccess.

Prototype

public static void streamResponseForSuccess(ClientOracle clientOracle, OutputStream out, Object payload)
            throws SerializationException 

Source Link

Usage

From source file:net.zschech.gwt.comet.server.impl.CometServletResponseImpl.java

License:Apache License

protected String serialize(Serializable message) throws NotSerializableException, UnsupportedEncodingException {
    try {//from w w w  .j  av a 2 s .  c om
        if (clientOracle == null) {
            ServerSerializationStreamWriter streamWriter = new ServerSerializationStreamWriter(
                    serializationPolicy);
            streamWriter.prepareToWrite();
            streamWriter.writeObject(message);
            return streamWriter.toString();
        } else {
            ByteArrayOutputStream result = new ByteArrayOutputStream();
            RPC.streamResponseForSuccess(clientOracle, result, message);
            return new String(result.toByteArray(), "UTF-8");
        }
    } catch (SerializationException e) {
        throw new NotSerializableException("Unable to serialize object, message: " + e.getMessage());
    }
}