Search in sources :

Example 1 with AsyncRequest

use of com.dexels.navajo.script.api.AsyncRequest in project navajo by Dexels.

the class TmlStandardServlet method doPost.

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    final LocalClient lc = (LocalClient) getServletContext().getAttribute("localClient");
    if (lc == null) {
        resp.sendError(500, "No local client registered in servlet context");
        return;
    }
    Object certObject = req.getAttribute("javax.servlet.request.X509Certificate");
    String recvEncoding = req.getHeader("Content-Encoding");
    String sendEncoding = req.getHeader("Accept-Encoding");
    AsyncRequest request = new BaseRequestImpl(req, resp, sendEncoding, recvEncoding, certObject, "default");
    TmlStandardRunner tr = new TmlStandardRunner(request, lc);
    getTmlScheduler().run(tr);
// TODO broken? fix
// getTmlScheduler().run(request.instantiateRunnable());
}
Also used : BaseRequestImpl(com.dexels.navajo.server.listener.http.impl.BaseRequestImpl) AsyncRequest(com.dexels.navajo.script.api.AsyncRequest) LocalClient(com.dexels.navajo.script.api.LocalClient)

Example 2 with AsyncRequest

use of com.dexels.navajo.script.api.AsyncRequest in project navajo by Dexels.

the class TmlRunnableBuilder method constructRequest.

private static AsyncRequest constructRequest(final HttpServletRequest req, HttpServletResponse resp, String instance) throws IOException {
    Object certObject = req.getAttribute("javax.servlet.request.X509Certificate");
    String contentEncoding = req.getHeader("Content-Encoding");
    String acceptEncoding = req.getHeader("Accept-Encoding");
    AsyncRequest request = null;
    if ("POST".equals(req.getMethod())) {
        request = new BaseRequestImpl(req, resp, acceptEncoding, contentEncoding, certObject, instance);
    } else {
        Navajo in = TmlHttpServlet.constructFromRequest(req);
        request = new BaseRequestImpl(in, req, resp, instance);
    }
    return request;
}
Also used : BaseRequestImpl(com.dexels.navajo.server.listener.http.impl.BaseRequestImpl) AsyncRequest(com.dexels.navajo.script.api.AsyncRequest) Navajo(com.dexels.navajo.document.Navajo)

Example 3 with AsyncRequest

use of com.dexels.navajo.script.api.AsyncRequest in project navajo by Dexels.

the class TmlRunnableBuilder method prepareRunnable.

public static TmlRunnable prepareRunnable(final HttpServletRequest req, HttpServletResponse resp, LocalClient localClient, String instance, long timeout) throws IOException {
    // Prevent the double creation of an asynchronous request handler for this request.
    TmlContinuationRunner tmlRunner = (TmlContinuationRunner) req.getAttribute("tmlRunner");
    if (tmlRunner != null) {
        return null;
    }
    AsyncRequest request = constructRequest(req, resp, instance);
    TmlContinuationRunner runner = new TmlContinuationRunner(request, localClient, timeout);
    if (runner.isAborted()) {
        return null;
    }
    req.setAttribute("tmlRunner", runner);
    runner.setAttribute("tester", req.getHeader("X-Navajo-Tester") != null);
    runner.suspendContinuation(resp);
    return runner;
}
Also used : AsyncRequest(com.dexels.navajo.script.api.AsyncRequest)

Aggregations

AsyncRequest (com.dexels.navajo.script.api.AsyncRequest)3 BaseRequestImpl (com.dexels.navajo.server.listener.http.impl.BaseRequestImpl)2 Navajo (com.dexels.navajo.document.Navajo)1 LocalClient (com.dexels.navajo.script.api.LocalClient)1