public ThreadBlockingRequestResponse(HttpServletRequest request, HttpServletResponse response) throws Exception { super(request, response); semaphore = new Semaphore(1); // Acquire semaphore hoping to have it released by a call to respondWith() method. semaphore.acquire(); }
private void sendViaNewChannel( final MessageContext context, final MessageContext receivingContext, final OutMessage message, final String uri) throws XFireException { try { Channel channel; PipedInputStream stream = new PipedInputStream(); PipedOutputStream outStream = new PipedOutputStream(stream); try { channel = getTransport().createChannel(uri); } catch (Exception e) { throw new XFireException("Couldn't create channel.", e); } Semaphore s = new Semaphore(2); try { getWorkManager().scheduleWork(new WriterWorker(outStream, message, context, s)); getWorkManager() .scheduleWork(new ReaderWorker(stream, message, channel, uri, receivingContext, s)); } catch (WorkException e) { throw new XFireException("Couldn't schedule worker threads. " + e.getMessage(), e); } try { s.acquire(); } catch (InterruptedException e) { // ignore is ok } } catch (IOException e) { throw new XFireRuntimeException("Couldn't create stream.", e); } }