Search in sources :

Example 1 with HessianSerializerOutput

use of com.caucho.hessian.io.HessianSerializerOutput in project httpx by servicex-sh.

the class SofaRpcInvocation method content.

public byte[] content() throws Exception {
    SofaRequest request = new SofaRequest();
    request.setTargetServiceUniqueName(this.targetServiceUniqueName);
    request.setMethodName(this.methodName);
    request.setMethodArgSigs(this.methodArgSigs);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Hessian2Output out = new HessianSerializerOutput(bos);
    out.writeObject(request);
    if (stubArguments != null) {
        for (Object argument : stubArguments) {
            out.writeObject(argument);
        }
    }
    out.flush();
    return bos.toByteArray();
}
Also used : HessianSerializerOutput(com.caucho.hessian.io.HessianSerializerOutput) Hessian2Output(com.caucho.hessian.io.Hessian2Output) SofaRequest(com.alipay.sofa.rpc.core.request.SofaRequest) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 2 with HessianSerializerOutput

use of com.caucho.hessian.io.HessianSerializerOutput in project httpx by servicex-sh.

the class DubboRpcInvocation method toBytes.

public byte[] toBytes() throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Hessian2Output out = new HessianSerializerOutput(bos);
    out.writeString("2.0.2");
    out.writeString(serviceName);
    out.writeString("0.0.0");
    out.writeString(methodStub);
    out.writeString(parameterTypesDesc);
    for (Object argument : stubArguments) {
        out.writeObject(argument);
    }
    out.writeObject(attachments);
    out.flush();
    return bos.toByteArray();
}
Also used : HessianSerializerOutput(com.caucho.hessian.io.HessianSerializerOutput) Hessian2Output(com.caucho.hessian.io.Hessian2Output) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 3 with HessianSerializerOutput

use of com.caucho.hessian.io.HessianSerializerOutput in project httpx by servicex-sh.

the class DubboRpcInvocationTest method testHessian.

@Test
public void testHessian() throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Hessian2Output out = new HessianSerializerOutput(bos);
    out.writeString("hi, Jackie");
    out.flush();
    byte[] bytes = bos.toByteArray();
    for (int i = 0; i < bytes.length; i++) {
        System.out.printf("%02X ", bytes[i]);
    }
}
Also used : HessianSerializerOutput(com.caucho.hessian.io.HessianSerializerOutput) Hessian2Output(com.caucho.hessian.io.Hessian2Output) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 4 with HessianSerializerOutput

use of com.caucho.hessian.io.HessianSerializerOutput in project alibaba-rsocket-broker by alibaba.

the class HessianTest method testEncode.

@Test
public void testEncode() throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    HessianSerializerOutput output = new HessianSerializerOutput(bos);
    output.writeObject(args);
    output.flush();
    content = bos.toByteArray();
    System.out.println(content.length);
}
Also used : HessianSerializerOutput(com.caucho.hessian.io.HessianSerializerOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 5 with HessianSerializerOutput

use of com.caucho.hessian.io.HessianSerializerOutput in project alibaba-rsocket-broker by alibaba.

the class HessianTest method testEncodeInteger.

@Test
public void testEncodeInteger() throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    HessianSerializerOutput output = new HessianSerializerOutput(bos);
    output.writeObject(1);
    output.flush();
    content = bos.toByteArray();
    Assertions.assertEquals(content[0], -111);
}
Also used : HessianSerializerOutput(com.caucho.hessian.io.HessianSerializerOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Aggregations

HessianSerializerOutput (com.caucho.hessian.io.HessianSerializerOutput)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 Hessian2Output (com.caucho.hessian.io.Hessian2Output)8 Test (org.junit.jupiter.api.Test)7 SofaRequest (com.alipay.sofa.rpc.core.request.SofaRequest)2 EncodingException (com.alibaba.rsocket.encoding.EncodingException)1 HessianSerializerInput (com.caucho.hessian.io.HessianSerializerInput)1 ByteBuf (io.netty.buffer.ByteBuf)1 ByteBufOutputStream (io.netty.buffer.ByteBufOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 DataBuffer (org.springframework.core.io.buffer.DataBuffer)1