Search in sources :

Example 1 with MethodMetaAndController

use of org.webpieces.router.impl.loader.MethodMetaAndController in project webpieces by deanhiller.

the class ScopedRouteBuilderImpl method addRoute.

@Override
public void addRoute(Port port, HttpMethod method, String path, String controllerMethod, RouteId routeId, boolean checkToken) {
    if (!controllerMethod.contains("."))
        throw new IllegalArgumentException("controllerMethod='" + controllerMethod + " does not contain a '.' which is required separating class name and method");
    UrlPath p = new UrlPath(routerInfo, path);
    boolean isPostOnly = method == HttpMethod.POST;
    RouteModuleInfo moduleInfo = CurrentRoutes.get();
    RouteInfo routeInfo = new RouteInfo(moduleInfo, controllerMethod);
    // MUST DO loadControllerIntoMetat HERE so stack trace has customer's line in it so he knows EXACTLY what
    // he did wrong when reading the exception!!
    MethodMetaAndController metaAndController = holder.getFinder().loadHtmlController(resettingLogic.getInjector(), routeInfo, isPostOnly);
    MatchInfo matchInfo = createMatchInfo(p, port, method, holder.getUrlEncoding());
    LoadedController loadedController = metaAndController.getLoadedController();
    FHtmlRouter router = new FHtmlRouter(holder.getRouteInvoker2(), loadedController, moduleInfo.getI18nBundleName(), matchInfo, checkToken);
    SvcProxyForHtml svc = new SvcProxyForHtml(holder.getSvcProxyLogic(), futureUtil);
    RouterAndInfo routerAndInfo = new RouterAndInfo(router, routeInfo, metaAndController, svc);
    newDynamicRoutes.add(routerAndInfo);
    resettingLogic.getReverseRoutes().addRoute(routeId, router);
    log.info("scope:'" + routerInfo + "' added route=" + matchInfo + " method=" + routeInfo.getControllerMethodString());
}
Also used : SvcProxyForHtml(org.webpieces.router.impl.services.SvcProxyForHtml) LoadedController(org.webpieces.router.impl.loader.LoadedController) UrlPath(org.webpieces.router.impl.UrlPath) MatchInfo(org.webpieces.router.impl.routers.MatchInfo) RouteModuleInfo(org.webpieces.router.impl.model.RouteModuleInfo) FHtmlRouter(org.webpieces.router.impl.routers.FHtmlRouter) MethodMetaAndController(org.webpieces.router.impl.loader.MethodMetaAndController)

Example 2 with MethodMetaAndController

use of org.webpieces.router.impl.loader.MethodMetaAndController in project webpieces by deanhiller.

the class ScopedRouteBuilderImpl method addStreamRoute.

@Override
public void addStreamRoute(Port port, HttpMethod method, String path, String controllerMethod, RouteId routeId) {
    UrlPath p = new UrlPath(routerInfo, path);
    RouteModuleInfo moduleInfo = CurrentRoutes.get();
    RouteInfo routeInfo = new RouteInfo(moduleInfo, controllerMethod);
    // MUST DO loadControllerIntoMeta HERE so stack trace has customer's line in it so he knows EXACTLY what
    // he did wrong when reading the exception!!
    MethodMetaAndController container = holder.getFinder().loadGenericController(resettingLogic.getInjector(), routeInfo);
    MatchInfo matchInfo = createMatchInfo(p, port, method, holder.getUrlEncoding());
    FStreamingRouter router = new FStreamingRouter(holder.getRouteInvoker2(), container.getLoadedController(), moduleInfo.getI18nBundleName(), matchInfo);
    SvcProxyForContent svc = new SvcProxyForContent(holder.getSvcProxyLogic(), futureUtil);
    RouterAndInfo routerAndInfo = new RouterAndInfo(router, routeInfo, container, svc);
    newDynamicRoutes.add(routerAndInfo);
    if (// if there is a routeId, then add the reverse mapping
    routeId != null)
        resettingLogic.getReverseRoutes().addRoute(routeId, router);
    log.info("scope:'" + routerInfo + "' added content route=" + matchInfo + " method=" + routeInfo.getControllerMethodString());
}
Also used : FStreamingRouter(org.webpieces.router.impl.routers.FStreamingRouter) UrlPath(org.webpieces.router.impl.UrlPath) MatchInfo(org.webpieces.router.impl.routers.MatchInfo) SvcProxyForContent(org.webpieces.router.impl.services.SvcProxyForContent) RouteModuleInfo(org.webpieces.router.impl.model.RouteModuleInfo) MethodMetaAndController(org.webpieces.router.impl.loader.MethodMetaAndController)

Aggregations

UrlPath (org.webpieces.router.impl.UrlPath)2 MethodMetaAndController (org.webpieces.router.impl.loader.MethodMetaAndController)2 RouteModuleInfo (org.webpieces.router.impl.model.RouteModuleInfo)2 MatchInfo (org.webpieces.router.impl.routers.MatchInfo)2 LoadedController (org.webpieces.router.impl.loader.LoadedController)1 FHtmlRouter (org.webpieces.router.impl.routers.FHtmlRouter)1 FStreamingRouter (org.webpieces.router.impl.routers.FStreamingRouter)1 SvcProxyForContent (org.webpieces.router.impl.services.SvcProxyForContent)1 SvcProxyForHtml (org.webpieces.router.impl.services.SvcProxyForHtml)1