Search in sources :

Example 1 with WebServiceHandlerPlugin

use of io.vertigo.vega.impl.webservice.WebServiceHandlerPlugin in project vertigo by KleeGroup.

the class HandlerChain method handle.

/**
 * Do handle of this route.
 *
 * @param request spark.Request
 * @param response spark.Response
 * @param routeContext Context of this route
 * @return WebService result
 * @throws SessionException Session exception
 */
public Object handle(final Request request, final Response response, final WebServiceCallContext routeContext) throws SessionException {
    int lookAhead = 0;
    while (offset + lookAhead < handlers.size()) {
        final WebServiceHandlerPlugin nextHandler = handlers.get(offset + lookAhead);
        // >>> before doFilter " + nextHandler
        if (nextHandler.accept(routeContext.getWebServiceDefinition())) {
            return nextHandler.handle(request, response, routeContext, new HandlerChain(handlers, offset + lookAhead));
        }
        // if current  doesn't apply for this WebServiceDefinition we look ahead
        lookAhead++;
    // <<< after doFilter " + nextHandler
    }
    throw new IllegalStateException("Last WebServiceHandlerPlugin haven't send a response body");
}
Also used : WebServiceHandlerPlugin(io.vertigo.vega.impl.webservice.WebServiceHandlerPlugin)

Aggregations

WebServiceHandlerPlugin (io.vertigo.vega.impl.webservice.WebServiceHandlerPlugin)1