protected BlockingQueueTransport createTransportChannel() { return new BlockingQueueTransport(new LinkedBlockingQueue<Object>()); }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // lets return the next response Command packet = null; int count = 0; try { BlockingQueueTransport transportChannel = getTransportChannel(request, response); if (transportChannel == null) { return; } packet = (Command)transportChannel.getQueue().poll(requestTimeout, TimeUnit.MILLISECONDS); DataOutputStream stream = new DataOutputStream(response.getOutputStream()); wireFormat.marshal(packet, stream); count++; } catch (InterruptedException ignore) { } if (count == 0) { response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT); } }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { InputStream stream = request.getInputStream(); String contentType = request.getContentType(); if (contentType != null && contentType.equals("application/x-gzip")) { stream = new GZIPInputStream(stream); } // Read the command directly from the reader, assuming UTF8 encoding Command command = (Command) wireFormat.unmarshalText(new InputStreamReader(stream, "UTF-8")); if (command instanceof WireFormatInfo) { WireFormatInfo info = (WireFormatInfo) command; if (!canProcessWireFormatVersion(info.getVersion())) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot process wire format of version: " + info.getVersion()); } } else { BlockingQueueTransport transport = getTransportChannel(request, response); if (transport == null) { return; } transport.doConsume(command); } }
answer.addServiceListener(new ServiceListener() { public void started(Service service) {
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // lets return the next response Command packet = null; int count = 0; try { BlockingQueueTransport transportChannel = getTransportChannel(request, response); if (transportChannel == null) { return; } packet = (Command)transportChannel.getQueue().poll(requestTimeout, TimeUnit.MILLISECONDS); DataOutputStream stream = new DataOutputStream(response.getOutputStream()); wireFormat.marshal(packet, stream); count++; } catch (InterruptedException ignore) { } if (count == 0) { response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT); } }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { InputStream stream = request.getInputStream(); String contentType = request.getContentType(); if (contentType != null && contentType.equals("application/x-gzip")) { stream = new GZIPInputStream(stream); } // Read the command directly from the reader, assuming UTF8 encoding Command command = (Command) wireFormat.unmarshalText(new InputStreamReader(stream, "UTF-8")); if (command instanceof WireFormatInfo) { WireFormatInfo info = (WireFormatInfo) command; if (!canProcessWireFormatVersion(info.getVersion())) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot process wire format of version: " + info.getVersion()); } } else { BlockingQueueTransport transport = getTransportChannel(request, response); if (transport == null) { return; } if (command instanceof ConnectionInfo) { ((ConnectionInfo) command).setTransportContext(request.getAttribute("javax.servlet.request.X509Certificate")); } transport.doConsume(command); } }
answer.addServiceListener(new ServiceListener() { public void started(Service service) {
protected BlockingQueueTransport createTransportChannel() { return new BlockingQueueTransport(new LinkedBlockingQueue<Object>()); }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // lets return the next response Command packet = null; int count = 0; try { BlockingQueueTransport transportChannel = getTransportChannel(request, response); if (transportChannel == null) { return; } packet = (Command)transportChannel.getQueue().poll(requestTimeout, TimeUnit.MILLISECONDS); DataOutputStream stream = new DataOutputStream(response.getOutputStream()); wireFormat.marshal(packet, stream); count++; } catch (InterruptedException ignore) { } if (count == 0) { response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT); } }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { InputStream stream = request.getInputStream(); String contentType = request.getContentType(); if (contentType != null && contentType.equals("application/x-gzip")) { stream = new GZIPInputStream(stream); } // Read the command directly from the reader, assuming UTF8 encoding Command command = (Command) wireFormat.unmarshalText(new InputStreamReader(stream, "UTF-8")); if (command instanceof WireFormatInfo) { WireFormatInfo info = (WireFormatInfo) command; if (!canProcessWireFormatVersion(info.getVersion())) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot process wire format of version: " + info.getVersion()); } } else { BlockingQueueTransport transport = getTransportChannel(request, response); if (transport == null) { return; } if (command instanceof ConnectionInfo) { ((ConnectionInfo) command).setTransportContext(request.getAttribute("javax.servlet.request.X509Certificate")); } transport.doConsume(command); } }
answer.addServiceListener(new ServiceListener() { public void started(Service service) {
protected BlockingQueueTransport createTransportChannel() { return new BlockingQueueTransport(new LinkedBlockingQueue<Object>()); }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // lets return the next response Command packet = null; int count = 0; try { BlockingQueueTransport transportChannel = getTransportChannel(request, response); if (transportChannel == null) { return; } packet = (Command)transportChannel.getQueue().poll(requestTimeout, TimeUnit.MILLISECONDS); DataOutputStream stream = new DataOutputStream(response.getOutputStream()); wireFormat.marshal(packet, stream); count++; } catch (InterruptedException ignore) { } if (count == 0) { response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT); } }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { InputStream stream = request.getInputStream(); String contentType = request.getContentType(); if (contentType != null && contentType.equals("application/x-gzip")) { stream = new GZIPInputStream(stream); } // Read the command directly from the reader, assuming UTF8 encoding Command command = (Command) wireFormat.unmarshalText(new InputStreamReader(stream, "UTF-8")); if (command instanceof WireFormatInfo) { WireFormatInfo info = (WireFormatInfo) command; if (!canProcessWireFormatVersion(info.getVersion())) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot process wire format of version: " + info.getVersion()); } } else { BlockingQueueTransport transport = getTransportChannel(request, response); if (transport == null) { return; } if (command instanceof ConnectionInfo) { ((ConnectionInfo) command).setTransportContext(request.getAttribute("javax.servlet.request.X509Certificate")); } transport.doConsume(command); } }
answer.addServiceListener(new ServiceListener() { public void started(Service service) {
protected BlockingQueueTransport createTransportChannel() { return new BlockingQueueTransport(new LinkedBlockingQueue<Object>()); }