List of usage examples for com.google.gwt.user.server.rpc.impl ServerSerializationStreamWriter setFlags
public final void setFlags(int flags)
From source file:com.brightedu.server.util.MyRPC.java
License:Apache License
/** * Returns a string that encodes the results of an RPC call. Private * overload that takes a flag signaling the preamble of the response * payload./*from ww w.j ava 2 s. co m*/ * * @param object * the object that we wish to send back to the client * @param wasThrown * if true, the object being returned was an exception thrown by * the service method; if false, it was the result of the service * method's invocation * @return a string that encodes the response from a service method * @throws SerializationException * if the object cannot be serialized */ public static String encodeResponse(Class<?> responseClass, Object object, boolean wasThrown, int flags, SerializationPolicy serializationPolicy) throws SerializationException { ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(serializationPolicy); stream.setFlags(flags); stream.prepareToWrite(); if (responseClass != void.class) { stream.serializeValue(object, responseClass); } String bufferStr = (wasThrown ? "//EX" : "//OK") + stream.toString(); return bufferStr; }
From source file:com.guit.server.guice.GuiceGwtServlet.java
License:Apache License
protected String encodeResponse(Class<?> responseClass, Object object, boolean wasThrown, int flags, SerializationPolicy serializationPolicy) throws SerializationException { ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(serializationPolicy); stream.setFlags(flags); stream.prepareToWrite();//from ww w . j a v a2 s . c o m stream.serializeValue(object, responseClass); return (wasThrown ? "//EX" : "//OK") + stream.toString(); }
From source file:com.seanchenxi.gwt.storage.server.ServerStorageSerializer.java
License:Apache License
public <T> String serialize(Class<? super T> clazz, T instance, SerializationPolicy serializationPolicy) throws SerializationException { if (instance == null) { return null; } else if (String.class.equals(clazz)) { return (String) instance; }/* w ww . j a v a 2 s . com*/ if (serializationPolicy == null) { throw new IllegalArgumentException( "SerializationPolicy is null, please call StorageUtils.PolicyLoader.load(...) before"); } ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(serializationPolicy); stream.setFlags(AbstractSerializationStream.DEFAULT_FLAGS); stream.prepareToWrite(); if (clazz != void.class) { stream.serializeValue(instance, clazz); } return stream.toString(); }
From source file:de.novanic.eventservice.service.connection.strategy.connector.streaming.StreamingServerConnector.java
License:Open Source License
/** * Transforms an event to a String to make it streamable. * @param anEvent event to serialize//from w ww . j a v a 2s . c om * @return serialized event (the event as a String) * @throws EventServiceException */ private String serialize(DomainEvent anEvent) throws EventServiceException { try { ServerSerializationStreamWriter theServerSerializationStreamWriter = new ServerSerializationStreamWriter( mySerializationPolicy); theServerSerializationStreamWriter.setFlags(0); theServerSerializationStreamWriter.prepareToWrite(); theServerSerializationStreamWriter.serializeValue(anEvent, DomainEvent.class); return theServerSerializationStreamWriter.toString(); } catch (SerializationException e) { throw new EventServiceException("Error on serializing the event \"" + anEvent + "\" for domain \"" + anEvent.getDomain() + "\"!", e); } }