use of fi.laverca.util.SynchHandler.SynchHandlerException in project laverca by laverca.
the class ClientBase method send.
/**
* Sends a request and waits for the response.
*
* <p>Usage example:
* <pre>
* try {
* Response resp = client.send(req);
* // Handle response
* } catch (IOException ioe) {
* // Handle error
* }
* </pre>
*
* @param req The request object to send
* @return The request object being sent. This can be used to cancel the polling.
*
* @throws IOException if an HTTP communication error occurs or if the service returns a SOAP Fault
*/
public Resp send(final Req req) throws IOException {
LavercaContext _context = new LavercaContext();
MSSSignatureResp _sigResp = null;
log.debug("Sending sigReq");
_sigResp = this.mssClient.send(req.sigReq, _context);
log.debug("Got resp");
if (req.isSynchronous()) {
return this.createResp(req.sigReq, _sigResp, null);
} else {
req.sigResp = _sigResp;
req.context = _context;
// Init the task and add it to the Req object
try {
req.ft = this.initializeTask(req, _sigResp, new SynchHandler<Req, Resp>());
} catch (SynchHandlerException e) {
if (e.getCause() instanceof IOException)
throw e;
else
throw new IOException(e.getCause());
}
log.debug("Starting calling");
this.threadExecutor.execute(req.ft);
try {
return req.waitForResponse();
} catch (InterruptedException | ExecutionException e) {
throw new IOException(e);
}
}
}
Aggregations