use of org.ballerinalang.bre.bvm.CallableUnitCallback in project ballerina by ballerina-lang.
the class WriteCharacters method writeResponse.
/**
* Processors the response after reading characters.
*
* @param result the response returned after reading characters.
* @return the response returned from the event.
*/
private static EventResult writeResponse(EventResult<Integer, EventContext> result) {
BStruct errorStruct = null;
EventContext eventContext = result.getContext();
Integer numberOfCharactersWritten = result.getResponse();
Context context = eventContext.getContext();
CallableUnitCallback callback = eventContext.getCallback();
Throwable error = eventContext.getError();
if (null != error) {
errorStruct = IOUtils.createError(context, error.getMessage());
context.setReturnValues(errorStruct);
} else {
context.setReturnValues(new BInteger(numberOfCharactersWritten));
}
callback.notifySuccess();
return result;
}
use of org.ballerinalang.bre.bvm.CallableUnitCallback in project ballerina by ballerina-lang.
the class WriteTextRecord method writeResponse.
/**
* Callback response received after the bytes are written.
*
* @param result the response received.
* @return the result context.
*/
private static EventResult writeResponse(EventResult<Integer, EventContext> result) {
BStruct errorStruct = null;
EventContext eventContext = result.getContext();
Context context = eventContext.getContext();
CallableUnitCallback callback = eventContext.getCallback();
Throwable error = eventContext.getError();
if (null != error) {
errorStruct = IOUtils.createError(context, error.getMessage());
}
context.setReturnValues(errorStruct);
callback.notifySuccess();
return result;
}
use of org.ballerinalang.bre.bvm.CallableUnitCallback in project ballerina by ballerina-lang.
the class CloseCharacterChannel method closeResponse.
private static EventResult closeResponse(EventResult<Boolean, EventContext> result) {
BStruct errorStruct = null;
EventContext eventContext = result.getContext();
Context context = eventContext.getContext();
CallableUnitCallback callback = eventContext.getCallback();
Throwable error = eventContext.getError();
if (null != error) {
errorStruct = IOUtils.createError(context, error.getMessage());
}
context.setReturnValues(errorStruct);
callback.notifySuccess();
return result;
}
use of org.ballerinalang.bre.bvm.CallableUnitCallback in project ballerina by ballerina-lang.
the class ServerStreamingListener method invoke.
@Override
public void invoke(Message request, StreamObserver<Message> responseObserver) {
List<ParamDetail> paramDetails = resource.getParamDetails();
BValue[] signatureParams = new BValue[paramDetails.size()];
signatureParams[0] = getConnectionParameter(resource, responseObserver);
BValue requestParam = getRequestParameter(resource, request);
if (requestParam != null) {
signatureParams[1] = requestParam;
}
CallableUnitCallback callback = new GrpcCallableUnitCallBack(responseObserver, isEmptyResponse());
Executor.submit(resource, callback, null, null, signatureParams);
}
use of org.ballerinalang.bre.bvm.CallableUnitCallback in project ballerina by ballerina-lang.
the class UnaryMethodListener method invoke.
@Override
public void invoke(Message request, StreamObserver<Message> responseObserver) {
List<ParamDetail> paramDetails = resource.getParamDetails();
BValue[] signatureParams = new BValue[paramDetails.size()];
signatureParams[0] = getConnectionParameter(resource, responseObserver);
BValue requestParam = getRequestParameter(resource, request);
if (requestParam != null) {
signatureParams[1] = requestParam;
}
CallableUnitCallback callback = new GrpcCallableUnitCallBack(responseObserver, isEmptyResponse());
Executor.submit(resource, callback, null, null, signatureParams);
}
Aggregations