Search in sources :

Example 1 with DScopedRouter

use of org.webpieces.router.impl.routers.DScopedRouter in project webpieces by deanhiller.

the class RouteBuilderImpl method buildRouter.

public DScopedRouter buildRouter() {
    if (pageNotFoundInfo == null)
        throw new IllegalStateException("Client did not call setPageNotFoundRoute for router=" + routerInfo + " and that's required to catch stray not founds");
    else if (internalErrorInfo == null)
        throw new IllegalStateException("Client did not call setInternalErrorRoute for router=" + routerInfo + " and that's required to catch stray bugs in your application");
    List<AbstractRouter> routers = super.buildRoutes(routeFilters);
    // static routes get cached in browser typically so add them last so dynamic routes which are not cached are
    // pattern matched first and we don't waste loop matching static routes
    routers.addAll(staticRouters);
    Map<String, EScopedRouter> pathToRouter = buildScopedRouters(routeFilters);
    SvcProxyFixedRoutes svcProxy = new SvcProxyFixedRoutes(holder.getSvcProxyLogic().getServiceInvoker(), futureUtil);
    FilterCreationMeta notFoundChain = new FilterCreationMeta(resettingLogic.getInjector(), notFoundFilters, svcProxy);
    FilterCreationMeta internalErrorChain = new FilterCreationMeta(resettingLogic.getInjector(), internalErrorFilters, svcProxy);
    Service<MethodMeta, Action> svc = holder.getFinder().loadFilters(internalErrorChain);
    String i18nBundleName = internalErrorInfo.getRouteModuleInfo().getI18nBundleName();
    EInternalErrorRouter internalErrorRouter = new EInternalErrorRouter(holder.getRouteInvoker2(), i18nBundleName, internalErrorController, svc);
    Service<MethodMeta, Action> notFoundSvc = holder.getFinder().loadFilters(notFoundChain);
    String notFoundBundleName = pageNotFoundInfo.getRouteModuleInfo().getI18nBundleName();
    ENotFoundRouter notFoundRouter = new ENotFoundRouter(holder.getRouteInvoker2(), notFoundBundleName, notFoundControllerInst, notFoundSvc);
    return new DScopedRouter(routerInfo, pathToRouter, routers, notFoundRouter, internalErrorRouter, routerFutures, futureUtil);
}
Also used : Action(org.webpieces.router.api.controller.actions.Action) ENotFoundRouter(org.webpieces.router.impl.routers.ENotFoundRouter) MethodMeta(org.webpieces.router.api.routes.MethodMeta) EInternalErrorRouter(org.webpieces.router.impl.routers.EInternalErrorRouter) SvcProxyFixedRoutes(org.webpieces.router.impl.services.SvcProxyFixedRoutes) EScopedRouter(org.webpieces.router.impl.routers.EScopedRouter) AbstractRouter(org.webpieces.router.impl.routers.AbstractRouter) DScopedRouter(org.webpieces.router.impl.routers.DScopedRouter)

Example 2 with DScopedRouter

use of org.webpieces.router.impl.routers.DScopedRouter in project webpieces by deanhiller.

the class AllContentTypesBuilderImpl method buildRouter.

public CRouter buildRouter() {
    DScopedRouter router = leftOverDomainsBuilder.buildRouter();
    Map<String, DContentTypeRouter> domainToRouter = new HashMap<>();
    for (Entry<String, ContentTypeBuilderImpl> entry : domainToRouteBuilder.entrySet()) {
        DContentTypeRouter router2 = entry.getValue().buildRouter();
        domainToRouter.put(entry.getKey(), router2);
    }
    return new CRouter(router, domainToRouter);
}
Also used : HashMap(java.util.HashMap) DContentTypeRouter(org.webpieces.router.impl.routers.DContentTypeRouter) DScopedRouter(org.webpieces.router.impl.routers.DScopedRouter) CRouter(org.webpieces.router.impl.routers.CRouter)

Aggregations

DScopedRouter (org.webpieces.router.impl.routers.DScopedRouter)2 HashMap (java.util.HashMap)1 Action (org.webpieces.router.api.controller.actions.Action)1 MethodMeta (org.webpieces.router.api.routes.MethodMeta)1 AbstractRouter (org.webpieces.router.impl.routers.AbstractRouter)1 CRouter (org.webpieces.router.impl.routers.CRouter)1 DContentTypeRouter (org.webpieces.router.impl.routers.DContentTypeRouter)1 EInternalErrorRouter (org.webpieces.router.impl.routers.EInternalErrorRouter)1 ENotFoundRouter (org.webpieces.router.impl.routers.ENotFoundRouter)1 EScopedRouter (org.webpieces.router.impl.routers.EScopedRouter)1 SvcProxyFixedRoutes (org.webpieces.router.impl.services.SvcProxyFixedRoutes)1