Java 类play.mvc.Router.Route 实例源码

项目:swagger-play    文件:SwaggerPlugin.java   
@Override
public void onApplicationStart() {

    final Set<Class<?>> resourceClasses = 
            ApiHelpInventory.getInstance().getRootResources();      

    if (resourceClasses.size() > 0) {

        Map<String, Route> router = new HashMap<>();

        for(Route route : Router.routes){   
            router.put(route.action, route);
        }

        RouteWrapper routeWrapper = new RouteWrapper(router);
        RouteFactory.setRoute(routeWrapper);

        PlaySwaggerConfig playSwaggerConfig = new PlaySwaggerConfig();          
        PlayConfigFactory.setConfig(playSwaggerConfig);

        Router.prependRoute("GET", RESOURCES_JSON, "ApiHelpController.catchAll");
        Logger.info("Swagger: Added ROOT help api @ " + RESOURCES_JSON);
    }
}
项目:swagger-play    文件:RouteWrapper.java   
public RouteWrapper(Map<String, Route> router) {
    this.router = router;
}
项目:swagger-play    文件:RouteWrapper.java   
public Route get(String routeName) {
    return router.get(routeName);
}
项目:swagger-play    文件:RouteWrapper.java   
public Map<String, Route> getAll() {
    return router;
}
项目:play-profiler    文件:ProfilerPlugin.java   
@Override
public void onRequestRouting(Route route) {
    // Logger.info("onRequestRouting:" + route.path + " requestId:" +
    // ProfilerEnhancer.currentRequestId());
    super.onRequestRouting(route);
}
项目:restcommander    文件:ActionInvoker.java   
@SuppressWarnings("unchecked")
public static void resolve(Http.Request request, Http.Response response) {

    if (!Play.started) {
        return;
    }

    Http.Request.current.set(request);
    Http.Response.current.set(response);

    Scope.Params.current.set(request.params);
    Scope.RenderArgs.current.set(new Scope.RenderArgs());
    Scope.RouteArgs.current.set(new Scope.RouteArgs());
    Scope.Session.current.set(Scope.Session.restore());
    Scope.Flash.current.set(Scope.Flash.restore());
    CachedBoundActionMethodArgs.init();

    ControllersEnhancer.currentAction.set(new Stack<String>());

    if (request.resolved) {
        return;
    }

    // Route and resolve format if not already done
    if (request.action == null) {
        Play.pluginCollection.routeRequest(request);
        Route route = Router.route(request);
        Play.pluginCollection.onRequestRouting(route);
    }
    request.resolveFormat();

    // Find the action method
    try {
        Method actionMethod = null;
        Object[] ca = getActionMethod(request.action);
        actionMethod = (Method) ca[1];
        request.controller = ((Class) ca[0]).getName().substring(12).replace("$", "");
        request.controllerClass = ((Class) ca[0]);
        request.actionMethod = actionMethod.getName();
        request.action = request.controller + "." + request.actionMethod;
        request.invokedMethod = actionMethod;

        if (Logger.isTraceEnabled()) {
            Logger.trace("------- %s", actionMethod);
        }

        request.resolved = true;

    } catch (ActionNotFoundException e) {
        Logger.error(e, "%s action not found", e.getAction());
        throw new NotFound(String.format("%s action not found", e.getAction()));
    }

}
项目:restcommander    文件:PlayPlugin.java   
/**
 * Called when the request has been routed.
 * @param route The route selected.
 */
public void onRequestRouting(Route route) {
}