/** * Adds a new messageID that is going to be sent by the client waiting for response. * @param messageId The messageID hat is going to be sent */ public void addClientMessage(String messageId) { WSCLogger.logger.tracev("AsynchronousRegistrationMapper addClientMessage {0}", messageId); this.responses.put(messageId, new FaultOrResponse()); }
public void assignFault(String messageId, Fault fault) { FaultOrResponse res = responses.get(messageId); if (res == null) { throw new IllegalStateException("The messageId " + messageId + " is not waiting for response"); } synchronized (res) { res.setFault(fault); WSCLogger.logger.tracev("AsynchronousRegistrationMapper assignFault {0}", messageId); res.notifyAll(); } }
public void assignResponse(String messageId, RegisterResponseType response) { FaultOrResponse res = responses.get(messageId); if (res == null) { throw new IllegalStateException("The messageId " + messageId + " is not waiting for response"); } synchronized (res) { res.setResponse(response); WSCLogger.logger.tracev("AsynchronousRegistrationMapper assignResponse {0}", messageId); res.notifyAll(); } }
if (res.isFault()) { String detail = res.getFault().getFaultstring(); if (res.getFault().getDetail()!= null && res.getFault().getDetail().getAny() != null && !res.getFault().getDetail().getAny().isEmpty()) { detail = res.getFault().getDetail().getAny().get(0).toString(); throwException(res.getFault().getFaultcode(), detail, null, res.getFault()); } else if (res.isEmpty()) { throw new InvalidStateException("No response assigned to messageID " + messageID); response = res.getResponse();
public FaultOrResponse waitForResponse(String messageId, long millis) { FaultOrResponse res = responses.get(messageId); if (res == null) { throw new IllegalStateException("The messageId " + messageId + " is not waiting for response"); } synchronized (res) { if (res.isEmpty()) { // wait for the response to arrive try { WSCLogger.logger.tracev("AsynchronousRegistrationMapper waitForResponse {0} {1}", messageId, millis); res.wait(millis); } catch (InterruptedException e) { WSCLogger.logger.warnv("AsynchronousRegistrationMapper waitForResponse: being interrupted and this should not happen!"); } } // remove the response cos it's filled responses.remove(messageId); } WSCLogger.logger.tracev("AsynchronousRegistrationMapper addClientMessage returning isResponse={0} isFault={1}", res.isResponse(), res.isFault()); return res; }