@Override protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { createTransportChannel(request, response); }
@SuppressWarnings("unchecked") @Override public void init() throws ServletException { super.init(); listener = (TransportAcceptListener)getServletContext().getAttribute("acceptListener"); if (listener == null) { throw new ServletException("No such attribute 'acceptListener' available in the ServletContext"); } transportFactory = (HttpTransportFactory)getServletContext().getAttribute("transportFactory"); if (transportFactory == null) { throw new ServletException("No such attribute 'transportFactory' available in the ServletContext"); } transportOptions = (HashMap<String, Object>)getServletContext().getAttribute("transportOptions"); wireFormat = (TextWireFormat)getServletContext().getAttribute("wireFormat"); if (wireFormat == null) { wireFormat = createWireFormat(); } }
@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); } }
protected void doStart() throws Exception { server = new Server(); if (connector == null) { connector = socketConnectorFactory.createConnector(); } URI bind = getBindLocation(); bind(); ServletContextHandler contextHandler = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY); ServletHolder holder = new ServletHolder(); holder.setServlet(new HttpTunnelServlet()); contextHandler.addServlet(holder, "/"); contextHandler.setAttribute("acceptListener", getAcceptListener()); contextHandler.setAttribute("wireFormat", getWireFormat()); contextHandler.setAttribute("transportFactory", transportFactory); contextHandler.setAttribute("transportOptions", transportOptions); GzipHandler gzipHandler = new GzipHandler(); contextHandler.setHandler(gzipHandler); server.start(); }
@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); } }
public synchronized void init() throws ServletException { // lets initialize the ActiveMQ broker try { if (broker == null) { broker = createBroker(); // Add the servlet connector String url = getConnectorURL(); HttpTransportFactory factory = new HttpTransportFactory(); transportConnector = (HttpTransportServer) factory.doBind(new URI(url)); broker.addConnector(transportConnector); String brokerURL = getServletContext().getInitParameter("org.apache.activemq.brokerURL"); if (brokerURL != null) { log("Listening for internal communication on: " + brokerURL); } } broker.start(); } catch (Exception e) { throw new ServletException("Failed to start embedded broker: " + e, e); } // now lets register the listener TransportAcceptListener listener = transportConnector.getAcceptListener(); getServletContext().setAttribute("transportChannelListener", listener); super.init(); }
@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); } }
holder.setServlet(new HttpTunnelServlet()); contextHandler.addServlet(holder, "/");
@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); } }
public synchronized void init() throws ServletException { // lets initialize the ActiveMQ broker try { if (broker == null) { broker = createBroker(); // Add the servlet connector String url = getConnectorURL(); HttpTransportFactory factory = new HttpTransportFactory(); transportConnector = (HttpTransportServer) factory.doBind(new URI(url)); broker.addConnector(transportConnector); String brokerURL = getServletContext().getInitParameter("org.apache.activemq.brokerURL"); if (brokerURL != null) { log("Listening for internal communication on: " + brokerURL); } } broker.start(); } catch (Exception e) { throw new ServletException("Failed to start embedded broker: " + e, e); } // now lets register the listener TransportAcceptListener listener = transportConnector.getAcceptListener(); getServletContext().setAttribute("transportChannelListener", listener); super.init(); }
@SuppressWarnings("unchecked") @Override public void init() throws ServletException { super.init(); listener = (TransportAcceptListener)getServletContext().getAttribute("acceptListener"); if (listener == null) { throw new ServletException("No such attribute 'acceptListener' available in the ServletContext"); } transportFactory = (HttpTransportFactory)getServletContext().getAttribute("transportFactory"); if (transportFactory == null) { throw new ServletException("No such attribute 'transportFactory' available in the ServletContext"); } transportOptions = (HashMap<String, Object>)getServletContext().getAttribute("transportOptions"); wireFormat = (TextWireFormat)getServletContext().getAttribute("wireFormat"); if (wireFormat == null) { wireFormat = createWireFormat(); } }
@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); } }
@Override protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { createTransportChannel(request, response); }
holder.setServlet(new HttpTunnelServlet()); contextHandler.addServlet(holder, "/");
@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); } }
public synchronized void init() throws ServletException { // lets initialize the ActiveMQ broker try { if (broker == null) { broker = createBroker(); // Add the servlet connector String url = getConnectorURL(); HttpTransportFactory factory = new HttpTransportFactory(); transportConnector = (HttpTransportServer) factory.doBind(new URI(url)); broker.addConnector(transportConnector); String brokerURL = getServletContext().getInitParameter("org.apache.activemq.brokerURL"); if (brokerURL != null) { log("Listening for internal communication on: " + brokerURL); } } broker.start(); } catch (Exception e) { throw new ServletException("Failed to start embedded broker: " + e, e); } // now lets register the listener TransportAcceptListener listener = transportConnector.getAcceptListener(); getServletContext().setAttribute("transportChannelListener", listener); super.init(); }
@SuppressWarnings("unchecked") @Override public void init() throws ServletException { super.init(); listener = (TransportAcceptListener)getServletContext().getAttribute("acceptListener"); if (listener == null) { throw new ServletException("No such attribute 'acceptListener' available in the ServletContext"); } transportFactory = (HttpTransportFactory)getServletContext().getAttribute("transportFactory"); if (transportFactory == null) { throw new ServletException("No such attribute 'transportFactory' available in the ServletContext"); } transportOptions = (HashMap<String, Object>)getServletContext().getAttribute("transportOptions"); wireFormat = (TextWireFormat)getServletContext().getAttribute("wireFormat"); if (wireFormat == null) { wireFormat = createWireFormat(); } }
@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); } }
@Override protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { createTransportChannel(request, response); }
holder.setServlet(new HttpTunnelServlet()); contextHandler.addServlet(holder, "/");