Search in sources :

Example 1 with InvocationCreator

use of org.apache.servicecomb.core.invocation.InvocationCreator in project incubator-servicecomb-java-chassis by apache.

the class DefaultEdgeDispatcher method requestByFilter.

protected void requestByFilter(RoutingContext context, String microserviceName, String versionRule, String path) {
    HttpServletRequestEx requestEx = new VertxServerRequestToHttpServletRequest(context);
    HttpServletResponseEx responseEx = new VertxServerResponseToHttpServletResponse(context.response());
    InvocationCreator creator = new EdgeInvocationCreator(context, requestEx, responseEx, microserviceName, versionRule, path);
    new RestProducerInvocationFlow(creator, requestEx, responseEx).run();
}
Also used : RestProducerInvocationFlow(org.apache.servicecomb.common.rest.RestProducerInvocationFlow) VertxServerResponseToHttpServletResponse(org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse) HttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx) InvocationCreator(org.apache.servicecomb.core.invocation.InvocationCreator) HttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx) VertxServerRequestToHttpServletRequest(org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest)

Example 2 with InvocationCreator

use of org.apache.servicecomb.core.invocation.InvocationCreator in project incubator-servicecomb-java-chassis by apache.

the class VertxRestDispatcher method onRequest.

protected void onRequest(RoutingContext context) {
    if (transport == null) {
        transport = SCBEngine.getInstance().getTransportManager().findTransport(Const.RESTFUL);
        microserviceMeta = SCBEngine.getInstance().getProducerMicroserviceMeta();
    }
    HttpServletRequestEx requestEx = new VertxServerRequestToHttpServletRequest(context);
    HttpServletResponseEx responseEx = new VertxServerResponseToHttpServletResponse(context.response());
    if (SCBEngine.getInstance().isFilterChainEnabled()) {
        InvocationCreator creator = new RestVertxProducerInvocationCreator(context, microserviceMeta, transport.getEndpoint(), requestEx, responseEx);
        new RestProducerInvocationFlow(creator, requestEx, responseEx).run();
        return;
    }
    VertxRestInvocation vertxRestInvocation = new VertxRestInvocation();
    context.put(RestConst.REST_PRODUCER_INVOCATION, vertxRestInvocation);
    vertxRestInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
}
Also used : RestProducerInvocationFlow(org.apache.servicecomb.common.rest.RestProducerInvocationFlow) VertxServerResponseToHttpServletResponse(org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse) HttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx) RestVertxProducerInvocationCreator(org.apache.servicecomb.common.rest.RestVertxProducerInvocationCreator) InvocationCreator(org.apache.servicecomb.core.invocation.InvocationCreator) VertxRestInvocation(org.apache.servicecomb.common.rest.VertxRestInvocation) HttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx) VertxServerRequestToHttpServletRequest(org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest) RestVertxProducerInvocationCreator(org.apache.servicecomb.common.rest.RestVertxProducerInvocationCreator)

Example 3 with InvocationCreator

use of org.apache.servicecomb.core.invocation.InvocationCreator in project incubator-servicecomb-java-chassis by apache.

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 4 with InvocationCreator

use of org.apache.servicecomb.core.invocation.InvocationCreator 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 5 with InvocationCreator

use of org.apache.servicecomb.core.invocation.InvocationCreator in project java-chassis by ServiceComb.

the class VertxRestDispatcher method onRequest.

protected void onRequest(RoutingContext context) {
    if (transport == null) {
        transport = SCBEngine.getInstance().getTransportManager().findTransport(Const.RESTFUL);
        microserviceMeta = SCBEngine.getInstance().getProducerMicroserviceMeta();
    }
    HttpServletRequestEx requestEx = new VertxServerRequestToHttpServletRequest(context);
    HttpServletResponseEx responseEx = new VertxServerResponseToHttpServletResponse(context.response());
    if (SCBEngine.getInstance().isFilterChainEnabled()) {
        InvocationCreator creator = new RestVertxProducerInvocationCreator(context, microserviceMeta, transport.getEndpoint(), requestEx, responseEx);
        new RestProducerInvocationFlow(creator, requestEx, responseEx).run();
        return;
    }
    VertxRestInvocation vertxRestInvocation = new VertxRestInvocation();
    context.put(RestConst.REST_PRODUCER_INVOCATION, vertxRestInvocation);
    vertxRestInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
}
Also used : RestProducerInvocationFlow(org.apache.servicecomb.common.rest.RestProducerInvocationFlow) VertxServerResponseToHttpServletResponse(org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse) HttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx) RestVertxProducerInvocationCreator(org.apache.servicecomb.common.rest.RestVertxProducerInvocationCreator) InvocationCreator(org.apache.servicecomb.core.invocation.InvocationCreator) VertxRestInvocation(org.apache.servicecomb.common.rest.VertxRestInvocation) HttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx) VertxServerRequestToHttpServletRequest(org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest) RestVertxProducerInvocationCreator(org.apache.servicecomb.common.rest.RestVertxProducerInvocationCreator)

Aggregations

InvocationCreator (org.apache.servicecomb.core.invocation.InvocationCreator)8 RestProducerInvocationFlow (org.apache.servicecomb.common.rest.RestProducerInvocationFlow)6 HttpServletRequestEx (org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx)6 HttpServletResponseEx (org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx)6 VertxServerRequestToHttpServletRequest (org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest)4 VertxServerResponseToHttpServletResponse (org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse)4 AsyncContext (javax.servlet.AsyncContext)2 RestVertxProducerInvocationCreator (org.apache.servicecomb.common.rest.RestVertxProducerInvocationCreator)2 VertxRestInvocation (org.apache.servicecomb.common.rest.VertxRestInvocation)2 StandardHttpServletRequestEx (org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx)2 StandardHttpServletResponseEx (org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx)2