Search in sources :

Example 1 with InvokeInfo

use of org.webpieces.router.impl.routeinvoker.InvokeInfo in project webpieces by deanhiller.

the class EInternalErrorRouter method invokeErrorRoute.

public XFuture<StreamWriter> invokeErrorRoute(RequestContext ctx, ProxyStreamHandle handle, Throwable exc) {
    Endpoint info = new Endpoint(svc);
    RouteInfoForInternalError data = new RouteInfoForInternalError(exc);
    InvokeInfo invokeInfo = new InvokeInfo(ctx, handle, RouteType.INTERNAL_SERVER_ERROR, loadedController, i18nBundleName);
    return invoker.invokeErrorController(invokeInfo, info, data).thenApply(voidd -> new NullStreamWriter());
}
Also used : RouteInfoForInternalError(org.webpieces.router.impl.services.RouteInfoForInternalError) InvokeInfo(org.webpieces.router.impl.routeinvoker.InvokeInfo)

Example 2 with InvokeInfo

use of org.webpieces.router.impl.routeinvoker.InvokeInfo in project webpieces by deanhiller.

the class DevRouteInvoker method invokeDevelopmentErrorPage.

private XFuture<Void> invokeDevelopmentErrorPage(InvokeInfo invokeInfo, RouteInfoForInternalError data) {
    RequestContext requestCtx = invokeInfo.getRequestCtx();
    ProxyStreamHandle handler = invokeInfo.getHandler();
    RouterRequest req = requestCtx.getRequest();
    Throwable exception = data.getException();
    Injector webAppInjector = webInjector.getCurrentInjector();
    RouteInfo routeInfo = new RouteInfo(new RouteModuleInfo("", null), "/org/webpieces/devrouter/impl/DevelopmentController.internalError");
    SvcProxyFixedRoutes svcProxy = new SvcProxyFixedRoutes(serviceInvoker, futureUtil);
    LoadedController newLoadedController = controllerFinder.loadGenericController(webAppInjector, routeInfo).getLoadedController();
    Endpoint newInfo = new Endpoint(svcProxy);
    RouterRequest newRequest = new RouterRequest();
    newRequest.putMultipart("url", req.relativePath);
    newRequest.isHttps = req.isHttps;
    newRequest.isBackendRequest = req.isBackendRequest;
    newRequest.originalRequest = req.originalRequest;
    newRequest.requestState.put(DevelopmentController.ORIGINAL_REQUEST, req);
    newRequest.requestState.put(DevelopmentController.EXCEPTION, exception);
    newRequest.requestState.put(DevRouteInvoker.ERROR_KEY, req.requestState.get(DevRouteInvoker.ERROR_KEY));
    ApplicationContext ctx = webInjector.getAppContext();
    RequestContext overridenCtx = new RequestContext(requestCtx.getValidation(), (FlashSub) requestCtx.getFlash(), requestCtx.getSession(), newRequest, ctx);
    InvokeInfo newInvokeInfo = new InvokeInfo(overridenCtx, handler, RouteType.INTERNAL_SERVER_ERROR, newLoadedController, null);
    RequestContext oldContext = Current.getContext();
    Current.setContext(overridenCtx);
    try {
        return super.invokeErrorController(newInvokeInfo, newInfo, data);
    } finally {
        Current.setContext(oldContext);
    }
}
Also used : LoadedController(org.webpieces.router.impl.loader.LoadedController) Endpoint(org.webpieces.router.impl.routers.Endpoint) ProxyStreamHandle(org.webpieces.router.impl.proxyout.ProxyStreamHandle) WebInjector(org.webpieces.router.impl.WebInjector) Injector(com.google.inject.Injector) SvcProxyFixedRoutes(org.webpieces.router.impl.services.SvcProxyFixedRoutes) InvokeInfo(org.webpieces.router.impl.routeinvoker.InvokeInfo) RouteInfo(org.webpieces.router.impl.routebldr.RouteInfo) RouteModuleInfo(org.webpieces.router.impl.model.RouteModuleInfo)

Example 3 with InvokeInfo

use of org.webpieces.router.impl.routeinvoker.InvokeInfo in project webpieces by deanhiller.

the class FContentRouter method invoke.

@Override
public RouterStreamRef invoke(RequestContext ctx, ProxyStreamHandle handler) {
    RouteData data = new RouteInfoForContent(bodyContentBinder);
    String i18nBundleName = moduleInfo.getI18nBundleName();
    InvokeInfo invokeInfo = new InvokeInfo(ctx, handler, RouteType.CONTENT, loadedController, i18nBundleName);
    return routeInvoker.invokeContentController(invokeInfo, dynamicInfo, data);
}
Also used : RouteInfoForContent(org.webpieces.router.impl.services.RouteInfoForContent) InvokeInfo(org.webpieces.router.impl.routeinvoker.InvokeInfo) RouteData(org.webpieces.router.impl.services.RouteData)

Example 4 with InvokeInfo

use of org.webpieces.router.impl.routeinvoker.InvokeInfo in project webpieces by deanhiller.

the class FStreamingRouter method invoke.

@Override
public RouterStreamRef invoke(RequestContext ctx, ProxyStreamHandle handler) {
    RouteData data = new RouteInfoForStream();
    InvokeInfo invokeInfo = new InvokeInfo(ctx, handler, RouteType.STREAMING, loadedController, i18nBundleName);
    return routeInvoker.invokeStreamingController(invokeInfo, dynamicInfo, data);
}
Also used : RouteInfoForStream(org.webpieces.router.impl.services.RouteInfoForStream) InvokeInfo(org.webpieces.router.impl.routeinvoker.InvokeInfo) RouteData(org.webpieces.router.impl.services.RouteData)

Example 5 with InvokeInfo

use of org.webpieces.router.impl.routeinvoker.InvokeInfo in project webpieces by deanhiller.

the class ENotFoundRouter method invokeNotFoundRoute.

public XFuture<StreamWriter> invokeNotFoundRoute(RequestContext ctx, ProxyStreamHandle handle, NotFoundException exc) {
    Endpoint info = new Endpoint(svc);
    RouteInfoForNotFound data = new RouteInfoForNotFound(exc);
    InvokeInfo invokeInfo = new InvokeInfo(ctx, handle, RouteType.NOT_FOUND, loadedController, i18nBaseBundle);
    return invoker.invokeNotFound(invokeInfo, info, data).thenApply(voidd -> new NullWriter());
}
Also used : InvokeInfo(org.webpieces.router.impl.routeinvoker.InvokeInfo) RouteInfoForNotFound(org.webpieces.router.impl.services.RouteInfoForNotFound) NullWriter(org.webpieces.router.impl.routeinvoker.NullWriter)

Aggregations

InvokeInfo (org.webpieces.router.impl.routeinvoker.InvokeInfo)7 RouteData (org.webpieces.router.impl.services.RouteData)3 Injector (com.google.inject.Injector)2 WebInjector (org.webpieces.router.impl.WebInjector)2 LoadedController (org.webpieces.router.impl.loader.LoadedController)2 RouteModuleInfo (org.webpieces.router.impl.model.RouteModuleInfo)2 ProxyStreamHandle (org.webpieces.router.impl.proxyout.ProxyStreamHandle)2 RouteInfo (org.webpieces.router.impl.routebldr.RouteInfo)2 Endpoint (org.webpieces.router.impl.routers.Endpoint)2 RouteInfoForInternalError (org.webpieces.router.impl.services.RouteInfoForInternalError)2 RouteInfoForNotFound (org.webpieces.router.impl.services.RouteInfoForNotFound)2 SvcProxyFixedRoutes (org.webpieces.router.impl.services.SvcProxyFixedRoutes)2 NotFoundException (org.webpieces.http.exception.NotFoundException)1 NullWriter (org.webpieces.router.impl.routeinvoker.NullWriter)1 RouteInfoForContent (org.webpieces.router.impl.services.RouteInfoForContent)1 RouteInfoForHtml (org.webpieces.router.impl.services.RouteInfoForHtml)1 RouteInfoForStream (org.webpieces.router.impl.services.RouteInfoForStream)1