Search in sources :

Example 1 with StandardHttpServletResponseEx

use of org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx in project incubator-servicecomb-java-chassis by apache.

the class ServletRestDispatcher method service.

public void service(HttpServletRequest request, HttpServletResponse response) {
    if (transport == null) {
        transport = CseContext.getInstance().getTransportManager().findTransport(Const.RESTFUL);
    }
    // 异步场景
    final AsyncContext asyncCtx = request.startAsync();
    asyncCtx.addListener(restAsyncListener);
    asyncCtx.setTimeout(ServletConfig.getServerTimeout());
    HttpServletRequestEx requestEx = new StandardHttpServletRequestEx(request);
    HttpServletResponseEx responseEx = new StandardHttpServletResponseEx(response);
    RestServletProducerInvocation restProducerInvocation = new RestServletProducerInvocation();
    restProducerInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
}
Also used : HttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx) StandardHttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx) StandardHttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx) AsyncContext(javax.servlet.AsyncContext) StandardHttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx) HttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx) StandardHttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx)

Example 2 with StandardHttpServletResponseEx

use of org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx in project java-chassis by ServiceComb.

the class ServletRestDispatcher method service.

public void service(HttpServletRequest request, HttpServletResponse response) {
    if (transport == null) {
        transport = SCBEngine.getInstance().getTransportManager().findTransport(Const.RESTFUL);
        microserviceMeta = SCBEngine.getInstance().getProducerMicroserviceMeta();
    }
    // 异步场景
    AsyncContext asyncCtx = request.startAsync();
    asyncCtx.addListener(restAsyncListener);
    asyncCtx.setTimeout(ServletConfig.getAsyncServletTimeout());
    HttpServletRequestEx requestEx = new StandardHttpServletRequestEx(request);
    HttpServletResponseEx responseEx = new StandardHttpServletResponseEx(response);
    if (SCBEngine.getInstance().isFilterChainEnabled()) {
        ((StandardHttpServletRequestEx) requestEx).setCacheRequest(true);
        InvocationCreator creator = new RestServletProducerInvocationCreator(microserviceMeta, transport.getEndpoint(), requestEx, responseEx);
        new RestProducerInvocationFlow(creator, requestEx, responseEx).run();
        return;
    }
    RestServletProducerInvocation restProducerInvocation = new RestServletProducerInvocation();
    restProducerInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
}
Also used : RestProducerInvocationFlow(org.apache.servicecomb.common.rest.RestProducerInvocationFlow) HttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx) StandardHttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx) StandardHttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx) InvocationCreator(org.apache.servicecomb.core.invocation.InvocationCreator) AsyncContext(javax.servlet.AsyncContext) StandardHttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx) HttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx) StandardHttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx)

Example 3 with StandardHttpServletResponseEx

use of org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx in project java-chassis by ServiceComb.

the class TestAbstractRestInvocation method setup.

@Before
public void setup() {
    ConfigUtil.installDynamicConfig();
    scbEngine = SCBBootstrap.createSCBEngineForTest().addProducerMeta("sid1", new TestPathSchema()).run();
    operationMeta = scbEngine.getProducerMicroserviceMeta().operationMetas().get("test.sid1.dynamicId");
    restOperation = RestMetaUtils.getRestOperationMeta(operationMeta);
    new MockUp<System>() {

        @Mock
        long nanoTime() {
            return nanoTime;
        }
    };
    if (responseEx == null) {
        responseEx = new StandardHttpServletResponseEx(servletResponse);
    }
    invocation = new Invocation(endpoint, operationMeta, operationMeta.buildBaseConsumerRuntimeType(), arguments);
    initRestInvocation();
    List<HttpServerFilter> httpServerFilters = SPIServiceUtils.getSortedService(HttpServerFilter.class);
    restInvocation.setHttpServerFilters(httpServerFilters);
}
Also used : HttpServerFilter(org.apache.servicecomb.common.rest.filter.HttpServerFilter) Invocation(org.apache.servicecomb.core.Invocation) TestPathSchema(org.apache.servicecomb.common.rest.locator.TestPathSchema) StandardHttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx) MockUp(mockit.MockUp) Before(org.junit.Before)

Aggregations

StandardHttpServletResponseEx (org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx)3 AsyncContext (javax.servlet.AsyncContext)2 HttpServletRequestEx (org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx)2 HttpServletResponseEx (org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx)2 StandardHttpServletRequestEx (org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx)2 MockUp (mockit.MockUp)1 RestProducerInvocationFlow (org.apache.servicecomb.common.rest.RestProducerInvocationFlow)1 HttpServerFilter (org.apache.servicecomb.common.rest.filter.HttpServerFilter)1 TestPathSchema (org.apache.servicecomb.common.rest.locator.TestPathSchema)1 Invocation (org.apache.servicecomb.core.Invocation)1 InvocationCreator (org.apache.servicecomb.core.invocation.InvocationCreator)1 Before (org.junit.Before)1