Package org.jrest4guice.rest.writer

Source Code of org.jrest4guice.rest.writer.JavaBeanResponseWriter

package org.jrest4guice.rest.writer;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.lang.reflect.Method;
import java.util.Map;

import org.jrest4guice.rest.annotations.MimeType;
import org.jrest4guice.rest.exception.Need2RedirectException;

/**
*
* @author <a href="mailto:zhangyouqun@gmail.com">cnoss (QQ:86895156)</a>
*
*/
public class JavaBeanResponseWriter implements ResponseWriter {
 
  /* (non-Javadoc)
   * @see org.jrest4guice.ResponseWriter#writeResult(javax.servlet.http.HttpServletResponse, java.lang.Object, java.lang.String)
   */
  public void writeResult(Method method,ByteArrayOutputStream out, Object result,String charset ,Map options) throws Need2RedirectException {
    try {
      ObjectOutputStream obj_out = new ObjectOutputStream(out);
      obj_out.writeObject(result);
      obj_out.flush();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  @Override
  public String getMimeType() {
    return MimeType.MIME_OF_JAVABEAN;
  }
}
TOP

Related Classes of org.jrest4guice.rest.writer.JavaBeanResponseWriter

TOP
Copyright © 2018 www.massapi.com. 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.