List of usage examples for com.google.gwt.user.server.rpc.impl ServerSerializationStreamWriter writeObject
@SuppressWarnings("unchecked") public void writeObject(Object instance) throws SerializationException
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 a v a 2s .co m*/ 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()); } }
From source file:rocket.remoting.server.comet.CometServerServlet.java
License:Apache License
/** * Uses the GWT serialization sub-system to convert the given object into a * String. This same object will be deserialized on the client using the GWT * deserialization sub-system./*from www . jav a 2s . c o m*/ * * @param command * The command to send. * @param object * Its okay to push null objects. * @return The serialized form of both the command and object. */ protected String serialize(final int command, final Object object) { try { ServerSerializationStreamWriter streamWriter = new ServerSerializationStreamWriter( this.createSerializationPolicy()); streamWriter.prepareToWrite(); streamWriter.writeInt(command); streamWriter.writeObject(object); return streamWriter.toString(); } catch (final SerializationException serializationException) { throw new RuntimeException( "Unable to serialize object, message: " + serializationException.getMessage()); } }