aerogear-controller 1.0.0.M1

org.jboss.aerogear.controller.router
Class Routes

java.lang.Object
  extended by org.jboss.aerogear.controller.router.Routes

public class Routes
extends Object

Routes is a collection of Route instances that are able to handle certain RequestMethod/requestURI combinations.

This class also provides static factory methods for creating Routes instances.


Field Summary
private  List<Route> routes
           
 
Constructor Summary
private Routes(List<RouteBuilder> routeBuilders)
           
 
Method Summary
static Routes from(List<RouteBuilder> routes)
          Factory method that constructs a Routes instance using the list of RouteBuilders provided.
 boolean hasRouteFor(RequestMethod method, String requestURI, Set<String> acceptHeaders)
          Determines is there is a Route for the RequestMethod/URI combination.
static RouteBuilder route()
          Simple Factory method for creating a RouteBuilder which is used to define a route.
 Route routeFor(RequestMethod method, String requestURI, Set<String> acceptHeaders)
          Returns the Route for the specified RequestMethod/URI combination.
 Route routeFor(Throwable throwable)
          Returns the Route for the specified Throwable.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

routes

private final List<Route> routes
Constructor Detail

Routes

private Routes(List<RouteBuilder> routeBuilders)
Method Detail

route

public static RouteBuilder route()
Simple Factory method for creating a RouteBuilder which is used to define a route.

Returns:
RouteBuilder which can be used to gather information about a Route.

from

public static Routes from(List<RouteBuilder> routes)
Factory method that constructs a Routes instance using the list of RouteBuilders provided.

Parameters:
routes - the list of RouteBuilders which will be used to create the Routes.
Returns:
Routes with the Routes from the passed in list of RouteBuilders.

toString

public String toString()
Overrides:
toString in class Object

hasRouteFor

public boolean hasRouteFor(RequestMethod method,
                           String requestURI,
                           Set<String> acceptHeaders)
Determines is there is a Route for the RequestMethod/URI combination.

Parameters:
method - the HTTP RequestMethod.
requestURI - the URI.
acceptHeaders - the accept headers provided, or an empty set if none were provided.
Returns:
true if this Routes has a Route for the specified RequestMethod/URI combination

routeFor

public Route routeFor(RequestMethod method,
                      String requestURI,
                      Set<String> acceptHeaders)
Returns the Route for the specified RequestMethod/URI combination.

Parameters:
method - the HTTP RequestMethod.
requestURI - the URI.
acceptHeaders - the accept headers provided, or an empty set if none were provided.
Returns:
Route configured to server the RequestMethod/URI combination. Will throw a RuntimeException if the specified RequestMethod/URI combination is not supported by this Routes instance.

routeFor

public Route routeFor(Throwable throwable)
Returns the Route for the specified Throwable.

Parameters:
throwable - the Throwable to match with a Route
Returns:
Route an error Route that can the type of the passed-in Throwable, or if no error route was specified a ErrorRoute.DEFAULT will be returned.

aerogear-controller 1.0.0.M1

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.