/** * Returns a string that encodes the results of an RPC call. Private overload * that takes a flag signaling the preamble of the response payload. * * @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 */ private static String encodeResponse(Class<?> responseClass, Object object, boolean wasThrown, int flags, SerializationPolicy serializationPolicy) throws SerializationException { ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(serializationPolicy, getRpcVersion()); stream.setFlags(flags); stream.prepareToWrite(); if (responseClass != void.class) { stream.serializeValue(object, responseClass); } String bufferStr = (wasThrown ? "//EX" : "//OK") + stream.toString(); return bufferStr; }
/** * Returns a string that encodes the results of an RPC call. Private overload * that takes a flag signaling the preamble of the response payload. * * @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 */ private static String encodeResponse(Class<?> responseClass, Object object, boolean wasThrown, int flags, SerializationPolicy serializationPolicy) throws SerializationException { ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(serializationPolicy, getRpcVersion()); stream.setFlags(flags); stream.prepareToWrite(); if (responseClass != void.class) { stream.serializeValue(object, responseClass); } String bufferStr = (wasThrown ? "//EX" : "//OK") + stream.toString(); return bufferStr; }
/** * Returns a string that encodes the results of an RPC call. Private overload * that takes a flag signaling the preamble of the response payload. * * @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 */ private static String encodeResponse(Class<?> responseClass, Object object, boolean wasThrown, int flags, SerializationPolicy serializationPolicy) throws SerializationException { ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(serializationPolicy, getRpcVersion()); stream.setFlags(flags); stream.prepareToWrite(); if (responseClass != void.class) { stream.serializeValue(object, responseClass); } String bufferStr = (wasThrown ? "//EX" : "//OK") + stream.toString(); return bufferStr; }