public void blockUntilRespond() throws InterruptedException { // Block thread by trying to acquire the semaphore a second time. boolean acquired = semaphore.tryAcquire(TIMEOUT, TimeUnit.MINUTES); if (acquired) { // Release the semaphore previously acquired. semaphore.release(); } else { LOG.error( "No response sent to " + "request '" + request.getRequestURI() + "' " + "with ICEfaces ID '" + request.getParameter("ice.session") + "' " + "from " + request.getRemoteAddr() + " " + "in " + TIMEOUT + " minutes. " + "Unblocking " + "thread '" + Thread.currentThread().getName() + "'."); // Release the semaphore; most probably respondWith() method was not invoked. semaphore.release(); } }
public void respondWith(final ResponseHandler handler) throws Exception { try { super.respondWith(handler); } finally { semaphore.release(); } }
public void run() { try { final XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(stream, message.getEncoding(), context); message.getSerializer().writeMessage(message, writer, context); writer.close(); stream.close(); } catch (Exception e) { throw new XFireRuntimeException("Couldn't write stream.", e); } finally { semaphore.release(); } }
public void run() { try { final XMLStreamReader reader = STAXUtils.createXMLStreamReader(stream, message.getEncoding(), context); final InMessage inMessage = new InMessage(reader, uri); inMessage.setEncoding(message.getEncoding()); channel.receive(context, inMessage); reader.close(); stream.close(); } catch (Exception e) { throw new XFireRuntimeException("Couldn't read stream.", e); } finally { semaphore.release(); } }