org.resthub.web.springmvc.router
Class Router

java.lang.Object
  extended by org.resthub.web.springmvc.router.Router

public class Router
extends Object

The router matches HTTP requests to action invocations.

Courtesy of Play! Framework Router

Author:
Play! Framework developers, Brian Clozel
See Also:
RouterHandlerMapping

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 List<Router.Route> routes
           
 
Constructor Summary
Router()
           
 
Method Summary
static void addRoute(int position, String method, String path, String headers)
          Add a route at the given position
static void addRoute(int position, String method, String path, String action, String headers)
          Add a route at the given position
static void addRoute(int position, String method, String path, String action, String params, String headers)
          Add a route at the given position
static void addRoute(String method, String path, String action)
          Add a new route.
static void addRoute(String method, String path, String action, String headers)
          Add a route at the given position
static void addRoute(String method, String path, String action, String params, String headers)
          Add a route
static void appendRoute(String method, String path, String action, String params, String headers, String sourceFile, int line)
          This is used internally when reading the route file.
static void detectChanges(org.springframework.core.io.Resource fileResource, String prefix)
           
static String getFullUrl(String action)
           
static String getFullUrl(String action, Map<String,Object> args)
           
static Router.Route getRoute(String method, String path, String action, String params, String headers)
           
static Router.Route getRoute(String method, String path, String action, String params, String headers, String sourceFile, int line)
           
static void load(org.springframework.core.io.Resource fileResource, String prefix)
          Parse the routes file.
static void prependRoute(String method, String path, String action)
          This one can be called to add new route.
static void prependRoute(String method, String path, String action, String headers)
          This one can be called to add new route.
static void prependRoute(String method, String path, String action, String params, String headers)
          Add a new route at the beginning of the route list
static Router.ActionDefinition reverse(String action)
           
static Router.ActionDefinition reverse(String action, Map<String,Object> args)
           
static Router.Route route(HTTPRequestAdapter request)
           
static Map<String,String> route(String method, String path)
           
static Map<String,String> route(String method, String path, String headers)
           
static Map<String,String> route(String method, String path, String headers, String host)
           
 
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 List<Router.Route> routes
Constructor Detail

Router

public Router()
Method Detail

load

public static void load(org.springframework.core.io.Resource fileResource,
                        String prefix)
                 throws IOException
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.
Throws:
IOException

prependRoute

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


prependRoute

public static void prependRoute(String method,
                                String path,
                                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,
                            String method,
                            String path,
                            String action,
                            String params,
                            String headers)
Add a route at the given position


addRoute

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


addRoute

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


addRoute

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


addRoute

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


addRoute

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


appendRoute

public static void appendRoute(String method,
                               String path,
                               String action,
                               String params,
                               String headers,
                               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(String method,
                                    String path,
                                    String action,
                                    String params,
                                    String headers)

getRoute

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

prependRoute

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


detectChanges

public static void detectChanges(org.springframework.core.io.Resource fileResource,
                                 String prefix)
                          throws IOException
Throws:
IOException

route

public static Router.Route route(HTTPRequestAdapter request)

route

public static Map<String,String> route(String method,
                                       String path)

route

public static Map<String,String> route(String method,
                                       String path,
                                       String headers)

route

public static Map<String,String> route(String method,
                                       String path,
                                       String headers,
                                       String host)

reverse

public static Router.ActionDefinition reverse(String action)

getFullUrl

public static String getFullUrl(String action,
                                Map<String,Object> args)

getFullUrl

public static String getFullUrl(String action)

reverse

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


Copyright © 2010-2012. All Rights Reserved.