Package com.google.gwt.user.server.rpc.impl

Examples of com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter


    }

  protected String serialize(Serializable message) throws NotSerializableException, UnsupportedEncodingException {
    try {
      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");
View Full Code Here


        reader.prepareToRead(data);
        return reader.readObject();
    }

    public static String serialize(Object message) throws SerializationException {
        ServerSerializationStreamWriter streamWriter = new ServerSerializationStreamWriter(GwtRpcUtil.getSerializationPolicy());
        streamWriter.prepareToWrite();
        streamWriter.writeObject(message);
        return streamWriter.toString();
    }
View Full Code Here

  protected abstract void doTerminate() throws IOException;
 
  protected String serialize(Serializable message) throws NotSerializableException, UnsupportedEncodingException {
    try {
      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");
View Full Code Here

   * @throws SerializationException if the object cannot be serialized
   */
  private static String encodeResponse(Class responseClass, Object object,
      boolean wasThrown) throws SerializationException {

    ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(
        serializableTypeOracle);

    stream.prepareToWrite();
    if (responseClass != void.class) {
      stream.serializeValue(object, responseClass);
    }

    String bufferStr = (wasThrown ? "//EX" : "//OK") + stream.toString();
    return bufferStr;
  }
View Full Code Here

   */
  public static String encodeResponse(Class<?> responseClass, Object object,
      boolean wasThrown, SerializationPolicy serializationPolicy)
      throws SerializationException {

    ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(
        serializationPolicy);

    stream.prepareToWrite();
    if (responseClass != void.class) {
      stream.serializeValue(object, responseClass);
    }

    String bufferStr = (wasThrown ? "//EX" : "//OK") + stream.toString();
    return bufferStr;
  }
View Full Code Here

    @Override
    public String getText() {
        if ((this.object != null) && (super.getText() == null)) {
            try {
                ServerSerializationStreamWriter objectWriter = new ServerSerializationStreamWriter(
                        getSerializationPolicy());
                objectWriter.serializeValue(this.object, this.targetClass);
                setText("//OK" + objectWriter.toString());
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
View Full Code Here

     * @return A string representing the encoded form of the object; this is a javascript/json expression.
     * @throws SerializationException
     *             If there is a problem during serialization
     */
    public static String serializeObject(Object object, Class<?> clazz, boolean inScriptTag) throws SerializationException {
        ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(new SerializationPolicy() {
     
      @Override
      public void validateSerialize(Class<?> clazz) throws SerializationException {
      }
     
      @Override
      public void validateDeserialize(Class<?> clazz) throws SerializationException {
        throw new SerializationException("Should only be used for serialization!");
      }
     
      @Override
      public boolean shouldSerializeFields(Class<?> clazz) {
        return clazz.getSuperclass() != null; // We'll allow anything but java.lang.Object, I guess
      }
     
      @Override
      public boolean shouldDeserializeFields(Class<?> clazz) {
        return false;
      }
    });
        stream.prepareToWrite();
        stream.serializeValue(object, clazz);
        return stream.toString();
    }
View Full Code Here

   */
  private static String encodeResponse(Class<?> responseClass, Object object,
      boolean wasThrown, SerializationPolicy serializationPolicy)
      throws SerializationException {

    ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(
        serializationPolicy);

    stream.prepareToWrite();
    if (responseClass != void.class) {
      stream.serializeValue(object, responseClass);
    }

    String bufferStr = (wasThrown ? "//EX" : "//OK") + stream.toString();
    return bufferStr;
  }
View Full Code Here

     * @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);
    }
    }
View Full Code Here

   * @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);
    stream.setFlags(flags);

    stream.prepareToWrite();
    if (responseClass != void.class) {
      stream.serializeValue(object, responseClass);
    }

    String bufferStr = (wasThrown ? "//EX" : "//OK") + stream.toString();
    return bufferStr;
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.