Search in sources :

Example 1 with Port

use of org.webpieces.router.api.routes.Port in project webpieces by deanhiller.

the class SharedMatchUtil method buildRoutes.

protected List<AbstractRouter> buildRoutes(List<FilterInfo<?>> routeFilters) {
    List<AbstractRouter> routers = new ArrayList<>();
    for (RouterAndInfo routerAndInfo : newDynamicRoutes) {
        AbstractDynamicRouter router = routerAndInfo.getRouter();
        MatchInfo matchInfo = router.getMatchInfo();
        String path = matchInfo.getFullPath();
        Port port = matchInfo.getExposedPorts();
        ResolvedMethod methodMeta = routerAndInfo.getMetaAndController().getMethodMeta();
        StreamService streamSvc;
        if (routerAndInfo.getRouteType() == RouteType.STREAMING) {
            streamSvc = new StreamProxy(holder.getFutureUtil(), holder.getServiceInvoker());
        } else {
            // Wire in request/response filters at this point
            List<FilterInfo<?>> filters = findMatchingFilters(methodMeta, path, port, routeFilters);
            FilterCreationMeta chainInfo = new FilterCreationMeta(resettingLogic.getInjector(), filters, routerAndInfo.getSvcProxy());
            Service<MethodMeta, Action> service = holder.getFinder().loadFilters(chainInfo);
            Processor processor;
            if (routerAndInfo.getRouteType() == RouteType.CONTENT) {
                processor = holder.getResponseProcessorContent();
            } else if (routerAndInfo.getRouteType() == RouteType.HTML) {
                processor = holder.getResponseProcessorHtml();
            } else {
                throw new IllegalStateException("RouteType not supported here=" + routerAndInfo.getRouteType());
            }
            String i18nBundleName = routerAndInfo.getRouteInfo().getRouteModuleInfo().getI18nBundleName();
            Endpoint svc = new Endpoint(service);
            streamSvc = new RequestResponseStream(svc, i18nBundleName, processor, holder.getBodyParsers(), holder.getServiceInvoker());
        }
        // Add streaming filters at this point here...
        router.setDynamicInfo(streamSvc);
        routers.add(router);
    }
    return routers;
}
Also used : StreamService(org.webpieces.router.api.streams.StreamService) Action(org.webpieces.router.api.controller.actions.Action) Processor(org.webpieces.router.impl.routeinvoker.Processor) Port(org.webpieces.router.api.routes.Port) ArrayList(java.util.ArrayList) MethodMeta(org.webpieces.router.api.routes.MethodMeta) AbstractDynamicRouter(org.webpieces.router.impl.routers.AbstractDynamicRouter) ResolvedMethod(org.webpieces.router.impl.loader.ResolvedMethod) Endpoint(org.webpieces.router.impl.routers.Endpoint) MatchInfo(org.webpieces.router.impl.routers.MatchInfo) AbstractRouter(org.webpieces.router.impl.routers.AbstractRouter)

Aggregations

ArrayList (java.util.ArrayList)1 Action (org.webpieces.router.api.controller.actions.Action)1 MethodMeta (org.webpieces.router.api.routes.MethodMeta)1 Port (org.webpieces.router.api.routes.Port)1 StreamService (org.webpieces.router.api.streams.StreamService)1 ResolvedMethod (org.webpieces.router.impl.loader.ResolvedMethod)1 Processor (org.webpieces.router.impl.routeinvoker.Processor)1 AbstractDynamicRouter (org.webpieces.router.impl.routers.AbstractDynamicRouter)1 AbstractRouter (org.webpieces.router.impl.routers.AbstractRouter)1 Endpoint (org.webpieces.router.impl.routers.Endpoint)1 MatchInfo (org.webpieces.router.impl.routers.MatchInfo)1