use of org.directwebremoting.extend.Replies in project ma-core-public by infiniteautomation.
the class ParallelDefaultRemoter method execute.
/**
* Execute a set of remote calls in parallel and generate set of reply data
* for later conversion to whatever wire protocol we are using today.
* @param calls The set of calls to execute in parallel
* @return A set of reply data objects
*/
public Replies execute(Calls calls) {
Replies replies = new Replies(calls.getBatchId());
Future[] future = new Future[calls.getCallCount()];
if (calls.getCallCount() == 1) {
return super.execute(calls);
} else {
for (int callNum = 0; callNum < calls.getCallCount(); callNum++) {
Call call = calls.getCall(callNum);
future[callNum] = executorService.submit(new OneCall(call));
}
for (int callNum = 0; callNum < calls.getCallCount(); callNum++) {
try {
Reply reply = (Reply) future[callNum].get(this.timeout, TimeUnit.MILLISECONDS);
replies.addReply(reply);
} catch (InterruptedException ex) {
log.warn("Method execution failed: ", ex);
replies.addReply(new Reply(calls.getCall(callNum).getCallId(), null, ex));
} catch (ExecutionException ex) {
log.warn("Method execution failed: ", ex);
replies.addReply(new Reply(calls.getCall(callNum).getCallId(), null, ex));
} catch (TimeoutException ex) {
log.warn("Method execution failed: ", ex);
replies.addReply(new Reply(calls.getCall(callNum).getCallId(), null, ex));
}
}
return replies;
}
}
use of org.directwebremoting.extend.Replies in project ma-core-public by infiniteautomation.
the class DefaultRemoter method execute.
/* (non-Javadoc)
* @see org.directwebremoting.Remoter#execute(org.directwebremoting.Calls)
*/
public Replies execute(Calls calls) {
Replies replies = new Replies(calls.getBatchId());
int callCount = calls.getCallCount();
if (callCount > maxCallCount) {
log.error("Call count for batch exceeds maxCallCount. Add an init-param of maxCallCount to increase this limit");
throw new SecurityException("Call count for batch is too high");
}
for (int callNum = 0; callNum < callCount; callNum++) {
Call call = calls.getCall(callNum);
Reply reply = execute(call);
replies.addReply(reply);
}
return replies;
}
use of org.directwebremoting.extend.Replies in project ma-core-public by infiniteautomation.
the class HtmlCallHandler method handle.
/* (non-Javadoc)
* @see org.directwebremoting.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
Calls calls = null;
try {
calls = htmlCallMarshaller.marshallInbound(request, response);
} catch (Exception ex) {
htmlCallMarshaller.marshallException(request, response, ex);
return;
}
Replies replies = remoter.execute(calls);
htmlCallMarshaller.marshallOutbound(replies, request, response);
}
use of org.directwebremoting.extend.Replies in project ma-core-public by infiniteautomation.
the class PlainCallHandler method handle.
/* (non-Javadoc)
* @see org.directwebremoting.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
Calls calls = null;
try {
calls = plainCallMarshaller.marshallInbound(request, response);
} catch (Exception ex) {
plainCallMarshaller.marshallException(request, response, ex);
return;
}
Replies replies = remoter.execute(calls);
plainCallMarshaller.marshallOutbound(replies, request, response);
}
Aggregations