Java Code Examples for com.alipay.remoting.rpc.protocol.RpcResponseCommand#getResponseObject()

The following examples show how to use com.alipay.remoting.rpc.protocol.RpcResponseCommand#getResponseObject() . 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: ProtobufSerializer.java    From sofa-jraft with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends ResponseCommand> boolean serializeContent(T response) throws SerializationException {
    final RpcResponseCommand cmd = (RpcResponseCommand) response;
    final Message msg = (Message) cmd.getResponseObject();
    cmd.setContent(msg.toByteArray());
    return true;
}
 
Example 2
Source File: RpcResponseResolver.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
/**
 * Convert remoting response command to throwable if it is a throwable, otherwise return null.
 */
private static Throwable toThrowable(ResponseCommand responseCommand) throws CodecException {
    RpcResponseCommand resp = (RpcResponseCommand) responseCommand;
    resp.deserialize();
    Object ex = resp.getResponseObject();
    if (ex instanceof Throwable) {
        return (Throwable) ex;
    }
    return null;
}
 
Example 3
Source File: NormalStringCustomSerializer.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
/**
 * @see CustomSerializer#serializeContent(ResponseCommand)
 */
@Override
public <T extends ResponseCommand> boolean serializeContent(T response)
                                                                       throws SerializationException {
    serialFlag.set(true);
    RpcResponseCommand rpcResp = (RpcResponseCommand) response;
    String str = (String) rpcResp.getResponseObject();
    try {
        rpcResp.setContent(str.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    contentSerializer = response.getSerializer();
    return true;
}
 
Example 4
Source File: NormalStringCustomSerializer_InvokeContext.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
/**
 * @see CustomSerializer#serializeContent(ResponseCommand)
 */
@Override
public <T extends ResponseCommand> boolean serializeContent(T response)
                                                                       throws SerializationException {
    serialFlag.set(true);
    RpcResponseCommand rpcResp = (RpcResponseCommand) response;
    String str = (String) rpcResp.getResponseObject();
    try {
        rpcResp.setContent(str.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    return true;
}
 
Example 5
Source File: RpcResponseResolver.java    From sofa-bolt with Apache License 2.0 4 votes vote down vote up
/**
 * Convert remoting response command to application response object.
 */
private static Object toResponseObject(ResponseCommand responseCommand) throws CodecException {
    RpcResponseCommand response = (RpcResponseCommand) responseCommand;
    response.deserialize();
    return response.getResponseObject();
}