Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Added public void send(Message reply, boolean is_exception) to Resp…

  • Loading branch information...
commit 85bc4783c9b742ea247fef9168b372c170b97fe4 1 parent 40d43db
@belaban authored
View
12 src/org/jgroups/blocks/RequestCorrelator.java
@@ -501,13 +501,16 @@ protected void sendReply(final Message req, final long req_id, Object reply, boo
}
Message rsp=req.makeReply().setFlag(req.getFlags()).clearFlag(Message.Flag.RSVP, Message.Flag.SCOPED);
- prepareResponse(rsp);
-
if(rsp_buf instanceof Buffer)
rsp.setBuffer((Buffer)rsp_buf);
else if(rsp_buf instanceof byte[])
rsp.setBuffer((byte[])rsp_buf);
+ sendResponse(rsp, req_id, is_exception);
+ }
+
+ protected void sendResponse(Message rsp, long req_id, boolean is_exception) {
+ prepareResponse(rsp);
Header rsp_hdr=new Header(is_exception? Header.EXC_RSP : Header.RSP, req_id, false, id);
rsp.putHeader(id, rsp_hdr);
if(log.isTraceEnabled())
@@ -516,6 +519,7 @@ else if(rsp_buf instanceof byte[])
transport.down(new Event(Event.MSG, rsp));
}
+
protected void prepareResponse(Message rsp) {
;
}
@@ -535,6 +539,10 @@ public ResponseImpl(Message req, long req_id) {
public void send(Object reply, boolean is_exception) {
sendReply(req, req_id, reply, is_exception);
}
+
+ public void send(Message reply, boolean is_exception) {
+ sendResponse(reply, req_id, is_exception);
+ }
}
View
13 src/org/jgroups/blocks/Response.java
@@ -1,5 +1,7 @@
package org.jgroups.blocks;
+import org.jgroups.Message;
+
/**
* A handback object shipped as a parameter to {@link AsyncRequestHandler#handle(org.jgroups.Message,Response)}.
* Encapsulates information needed to send a response, e.g. the request ID, the sender etc.
@@ -18,4 +20,15 @@
* object, is_exception is false
*/
void send(Object reply, boolean is_exception);
+
+
+ /**
+ * Similar to {@link #send(Object,boolean)}, but passes a message instead of an object. The message needs to contain
+ * the marshalled response, so message creation, setting of flags and marshalling is the responsibility of the caller.
+ * <p/>The reason for this additional method is to give the caller more control over the response message.<p/>
+ * This method may be removed, should we find that it's not really needed
+ * @param reply The reply message
+ * @param is_exception Whether the payload of this message is an exception or a real reply object
+ */
+ void send(Message reply, boolean is_exception);
}
Please sign in to comment.
Something went wrong with that request. Please try again.