Search in sources :

Example 1 with BinderAndLoader

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

the class ScopedRouteBuilderImpl method addContentRoute.

@Override
public void addContentRoute(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!!
    BinderAndLoader container = holder.getFinder().loadContentController(resettingLogic.getInjector(), routeInfo);
    MatchInfo matchInfo = createMatchInfo(p, port, method, holder.getUrlEncoding());
    LoadedController loadedController = container.getMetaAndController().getLoadedController();
    FContentRouter router = new FContentRouter(holder.getRouteInvoker2(), loadedController, moduleInfo, matchInfo, container.getBinder());
    SvcProxyForContent svc = new SvcProxyForContent(holder.getSvcProxyLogic(), futureUtil);
    RouterAndInfo routerAndInfo = new RouterAndInfo(router, routeInfo, container.getMetaAndController(), 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 : BinderAndLoader(org.webpieces.router.impl.loader.BinderAndLoader) LoadedController(org.webpieces.router.impl.loader.LoadedController) UrlPath(org.webpieces.router.impl.UrlPath) MatchInfo(org.webpieces.router.impl.routers.MatchInfo) SvcProxyForContent(org.webpieces.router.impl.services.SvcProxyForContent) FContentRouter(org.webpieces.router.impl.routers.FContentRouter) RouteModuleInfo(org.webpieces.router.impl.model.RouteModuleInfo)

Example 2 with BinderAndLoader

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

the class ContentTypeBuilderImpl method addRoute.

@Override
public void addRoute(String path, String controllerMethod) {
    if (!controllerMethod.contains("."))
        throw new IllegalArgumentException("controllerMethod must contain a . for the form Controller.method");
    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!!
    BinderAndLoader container = holder.getFinder().loadContentController(resettingLogic.getInjector(), routeInfo);
    MatchInfo matchInfo = createMatchInfo(p, Port.HTTPS, HttpMethod.POST, holder.getUrlEncoding());
    LoadedController loadedController = container.getMetaAndController().getLoadedController();
    FContentRouter router = new FContentRouter(holder.getRouteInvoker2(), loadedController, moduleInfo, matchInfo, container.getBinder());
    SvcProxyForContent svc = new SvcProxyForContent(holder.getSvcProxyLogic(), futureUtil);
    RouterAndInfo routerAndInfo = new RouterAndInfo(router, routeInfo, container.getMetaAndController(), svc);
    newDynamicRoutes.add(routerAndInfo);
    // There is no routeId...
    // if(routeId != null) //if there is a routeId, then add the reverse mapping
    // resettingLogic.getReverseRoutes().addRoute(routeId, router);
    log.info("scope:'" + routerInfo + "' added content route=" + matchInfo + " method=" + routeInfo.getControllerMethodString());
}
Also used : BinderAndLoader(org.webpieces.router.impl.loader.BinderAndLoader) LoadedController(org.webpieces.router.impl.loader.LoadedController) UrlPath(org.webpieces.router.impl.UrlPath) MatchInfo(org.webpieces.router.impl.routers.MatchInfo) SvcProxyForContent(org.webpieces.router.impl.services.SvcProxyForContent) FContentRouter(org.webpieces.router.impl.routers.FContentRouter) RouteModuleInfo(org.webpieces.router.impl.model.RouteModuleInfo)

Aggregations

UrlPath (org.webpieces.router.impl.UrlPath)2 BinderAndLoader (org.webpieces.router.impl.loader.BinderAndLoader)2 LoadedController (org.webpieces.router.impl.loader.LoadedController)2 RouteModuleInfo (org.webpieces.router.impl.model.RouteModuleInfo)2 FContentRouter (org.webpieces.router.impl.routers.FContentRouter)2 MatchInfo (org.webpieces.router.impl.routers.MatchInfo)2 SvcProxyForContent (org.webpieces.router.impl.services.SvcProxyForContent)2