play.mvc
Class Router

java.lang.Object
  extended by play.mvc.Router

public class Router
extends java.lang.Object

The router matches HTTP requests to action invocations


Nested Class Summary
static class Router.ActionDefinition
           
static class Router.Route
           
 
Field Summary
static long lastLoading
          Timestamp the routes file was last loaded at.
static java.util.List<Router.Route> routes
          All the loaded routes.
 
Constructor Summary
Router()
           
 
Method Summary
static void addRoute(int position, java.lang.String method, java.lang.String path, java.lang.String headers)
          Add a route at the given position
static void addRoute(int position, java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String headers)
          Add a route at the given position
static void addRoute(int position, java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers)
          Add a route at the given position
static void addRoute(java.lang.String method, java.lang.String path, java.lang.String action)
          Add a new route.
static void addRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String headers)
          Add a route at the given position
static void addRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers)
          Add a route
static void appendRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers, java.lang.String sourceFile, int line)
          This is used internally when reading the route file.
static void detectChanges(java.lang.String prefix)
          In PROD mode and if the routes are already loaded, this does nothing.
protected static java.lang.String getBaseUrl()
           
static java.lang.String getFullUrl(java.lang.String action)
           
static java.lang.String getFullUrl(java.lang.String action, java.util.Map<java.lang.String,java.lang.Object> args)
           
static Router.Route getRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers)
           
static Router.Route getRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers, java.lang.String sourceFile, int line)
           
static void load(java.lang.String prefix)
          Parse the routes file.
static void prependRoute(java.lang.String method, java.lang.String path, java.lang.String action)
          This one can be called to add new route.
static void prependRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String headers)
          This one can be called to add new route.
static void prependRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers)
          Add a new route at the beginning of the route list
static Router.ActionDefinition reverse(java.lang.String action)
           
static Router.ActionDefinition reverse(java.lang.String action, java.util.Map<java.lang.String,java.lang.Object> args)
           
static java.lang.String reverse(VirtualFile file)
           
static java.lang.String reverse(VirtualFile file, boolean absolute)
           
static java.lang.String reverseWithCheck(java.lang.String name, VirtualFile file, boolean absolute)
           
static Router.Route route(Http.Request request)
           
static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method, java.lang.String path)
           
static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method, java.lang.String path, java.lang.String headers)
           
static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method, java.lang.String path, java.lang.String headers, java.lang.String host)
           
static void routeOnlyStatic(Http.Request request)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastLoading

public static long lastLoading
Timestamp the routes file was last loaded at.


routes

public static java.util.List<Router.Route> routes
All the loaded routes.

Constructor Detail

Router

public Router()
Method Detail

load

public static void load(java.lang.String prefix)
Parse the routes file. This is called at startup.

Parameters:
prefix - The prefix that the path of all routes in this route file start with. This prefix should not end with a '/' character.

prependRoute

public static void prependRoute(java.lang.String method,
                                java.lang.String path,
                                java.lang.String action,
                                java.lang.String headers)
This one can be called to add new route. Last added is first in the route list.


prependRoute

public static void prependRoute(java.lang.String method,
                                java.lang.String path,
                                java.lang.String action)
This one can be called to add new route. Last added is first in the route list.


addRoute

public static void addRoute(int position,
                            java.lang.String method,
                            java.lang.String path,
                            java.lang.String action,
                            java.lang.String params,
                            java.lang.String headers)
Add a route at the given position


addRoute

public static void addRoute(int position,
                            java.lang.String method,
                            java.lang.String path,
                            java.lang.String headers)
Add a route at the given position


addRoute

public static void addRoute(int position,
                            java.lang.String method,
                            java.lang.String path,
                            java.lang.String action,
                            java.lang.String headers)
Add a route at the given position


addRoute

public static void addRoute(java.lang.String method,
                            java.lang.String path,
                            java.lang.String action)
Add a new route. Will be first in the route list


addRoute

public static void addRoute(java.lang.String method,
                            java.lang.String path,
                            java.lang.String action,
                            java.lang.String headers)
Add a route at the given position


addRoute

public static void addRoute(java.lang.String method,
                            java.lang.String path,
                            java.lang.String action,
                            java.lang.String params,
                            java.lang.String headers)
Add a route


appendRoute

public static void appendRoute(java.lang.String method,
                               java.lang.String path,
                               java.lang.String action,
                               java.lang.String params,
                               java.lang.String headers,
                               java.lang.String sourceFile,
                               int line)
This is used internally when reading the route file. The order the routes are added matters and we want the method to append the routes to the list.


getRoute

public static Router.Route getRoute(java.lang.String method,
                                    java.lang.String path,
                                    java.lang.String action,
                                    java.lang.String params,
                                    java.lang.String headers)

getRoute

public static Router.Route getRoute(java.lang.String method,
                                    java.lang.String path,
                                    java.lang.String action,
                                    java.lang.String params,
                                    java.lang.String headers,
                                    java.lang.String sourceFile,
                                    int line)

prependRoute

public static void prependRoute(java.lang.String method,
                                java.lang.String path,
                                java.lang.String action,
                                java.lang.String params,
                                java.lang.String headers)
Add a new route at the beginning of the route list


detectChanges

public static void detectChanges(java.lang.String prefix)
In PROD mode and if the routes are already loaded, this does nothing.

In DEV mode, this checks each routes file's "last modified" time to see if the routes need updated.

Parameters:
prefix - The prefix that the path of all routes in this route file start with. This prefix should not end with a '/' character.

routeOnlyStatic

public static void routeOnlyStatic(Http.Request request)

route

public static Router.Route route(Http.Request request)

route

public static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method,
                                                                     java.lang.String path)

route

public static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method,
                                                                     java.lang.String path,
                                                                     java.lang.String headers)

route

public static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method,
                                                                     java.lang.String path,
                                                                     java.lang.String headers,
                                                                     java.lang.String host)

reverse

public static Router.ActionDefinition reverse(java.lang.String action)

getFullUrl

public static java.lang.String getFullUrl(java.lang.String action,
                                          java.util.Map<java.lang.String,java.lang.Object> args)

getBaseUrl

protected static java.lang.String getBaseUrl()

getFullUrl

public static java.lang.String getFullUrl(java.lang.String action)

reverse

public static java.lang.String reverse(VirtualFile file)

reverse

public static java.lang.String reverse(VirtualFile file,
                                       boolean absolute)

reverseWithCheck

public static java.lang.String reverseWithCheck(java.lang.String name,
                                                VirtualFile file,
                                                boolean absolute)

reverse

public static Router.ActionDefinition reverse(java.lang.String action,
                                              java.util.Map<java.lang.String,java.lang.Object> args)


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly