Java Code Examples for com.caucho.hessian.io.Hessian2Input#startMessage()

The following examples show how to use com.caucho.hessian.io.Hessian2Input#startMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HessianExample.java    From pragmatic-java-engineer with GNU General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    //序列化
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    Hessian2Output out = new Hessian2Output(os);
    out.startMessage();
    TestUser user = new TestUser();
    out.writeObject(user);
    out.completeMessage();
    out.flush();
    byte[] bytes = os.toByteArray();
    out.close();
    os.close();

    //反序列化
    ByteArrayInputStream ins = new ByteArrayInputStream(bytes);
    Hessian2Input input = new Hessian2Input(ins);
    input.startMessage();
    user = (TestUser) input.readObject();
    input.completeMessage();
    input.close();
    ins.close();
}
 
Example 2
Source File: HessianSerialize.java    From Lottor with MIT License 5 votes vote down vote up
@Override
public Object deserialize(InputStream input) {
    Object result = null;
    try {
        Hessian2Input hi = new Hessian2Input(input);
        hi.startMessage();
        result = hi.readObject();
        hi.completeMessage();
        hi.close();
        input.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}
 
Example 3
Source File: HessianSerialize.java    From Raincat with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object deserialize(final InputStream input) {
    Object result = null;
    try {
        Hessian2Input hi = new Hessian2Input(input);
        hi.startMessage();
        result = hi.readObject();
        hi.completeMessage();
        hi.close();
        input.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}
 
Example 4
Source File: Hessian2Serializable.java    From light-task-scheduler with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
   public <T> T deserialize(byte[] data, Class<T> clazz) throws Exception {

       UnsafeByteArrayInputStream bin = new UnsafeByteArrayInputStream(data);
       Hessian2Input in = new Hessian2Input(bin);
       in.startMessage();
       Object obj = in.readObject(clazz);
       in.completeMessage();
       in.close();
       return (T) obj;
   }