aerogear-controller 1.0.1

org.jboss.aerogear.controller.router
Class DefaultRoute

java.lang.Object
  extended by org.jboss.aerogear.controller.router.DefaultRoute
All Implemented Interfaces:
Route

public class DefaultRoute
extends Object
implements Route

An immutable implementation of Route.


Field Summary
private  Set<String> consumes
           
private  Set<RequestMethod> methods
           
private  List<Parameter<?>> parameters
           
private  String path
           
private  Set<MediaType> produces
           
private  Set<String> roles
           
private  Class<?> targetClass
           
private  Method targetMethod
           
private  Set<Class<? extends Throwable>> throwables
           
 
Constructor Summary
DefaultRoute(RouteDescriptor descriptor)
          Constructs a Route with the specified RouteDescriptor configuration options.
 
Method Summary
private  Set<String> asSet(List<String> strings, String defaultValue)
           
private  Set<MediaType> asSet(MediaType[] types)
           
private  Set<RequestMethod> asSet(RequestMethod[] methods)
           
private  Set<String> asSet(String[] strings)
           
 boolean canHandle(Throwable throwable)
          Determines if this Route can handle the throwable.
 Set<String> consumes()
          Returns the media types that this Route is capable of consuming.
private static MediaType[] defaultMediaTypes()
           
private static Set<Class<? extends Throwable>> emptyThrowableSet()
           
 Set<RequestMethod> getMethods()
          Gets the RequestMethods for this Route.
 List<Parameter<?>> getParameters()
          Returns the Parameter's that this route accepts.
 String getPath()
          Gets the path for this Route.
 Set<String> getRoles()
          Gets this Routes associated roles.
 Class<?> getTargetClass()
          Gets the target class for this Route
 Method getTargetMethod()
          Gets the Method of the target class for this Route.
 boolean hasExceptionsRoutes()
          Determines if this Route contains one or more exception routes.
 boolean isParameterized()
          Determines if this Route's path is parameterized.
private  boolean isPathCompatible(String realPath)
           
 boolean isSecured()
          Determines if this Route has roles configured.
 boolean matches(RequestMethod method, String path, Set<String> acceptHeaders)
          Determines if this Route can handle the RequestMethod and path combination.
private  boolean matchesProduces(Set<String> acceptHeaders)
           
 Set<MediaType> produces()
          Returns the media types that this Route is capable of serving.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

path

private final String path

targetClass

private final Class<?> targetClass

targetMethod

private final Method targetMethod

methods

private final Set<RequestMethod> methods

roles

private final Set<String> roles

consumes

private final Set<String> consumes

produces

private final Set<MediaType> produces

throwables

private final Set<Class<? extends Throwable>> throwables

parameters

private final List<Parameter<?>> parameters
Constructor Detail

DefaultRoute

public DefaultRoute(RouteDescriptor descriptor)
Constructs a Route with the specified RouteDescriptor configuration options.

Parameters:
descriptor - the RouteDescriptor with the configured values.
Method Detail

getMethods

public Set<RequestMethod> getMethods()
Description copied from interface: Route
Gets the RequestMethods for this Route.

Specified by:
getMethods in interface Route
Returns:
the RequestMethods, or an empty set.

getPath

public String getPath()
Description copied from interface: Route
Gets the path for this Route.

Specified by:
getPath in interface Route
Returns:
the path for this route, or null if no path exists for this Route.

getTargetClass

public Class<?> getTargetClass()
Description copied from interface: Route
Gets the target class for this Route

Specified by:
getTargetClass in interface Route
Returns:
the target class.

matches

public boolean matches(RequestMethod method,
                       String path,
                       Set<String> acceptHeaders)
Description copied from interface: Route
Determines if this Route can handle the RequestMethod and path combination.

Specified by:
matches in interface Route
Parameters:
method - the http request methods.
path - the request path.
acceptHeaders - the accept headers provided, or an empty set if none were provided.
Returns:
true if this Route can handle the method and path passed in, false otherwise.

matchesProduces

private boolean matchesProduces(Set<String> acceptHeaders)

isPathCompatible

private boolean isPathCompatible(String realPath)

getTargetMethod

public Method getTargetMethod()
Description copied from interface: Route
Gets the Method of the target class for this Route.

Specified by:
getTargetMethod in interface Route
Returns:
the target method.

isParameterized

public boolean isParameterized()
Description copied from interface: Route
Determines if this Route's path is parameterized.

Specified by:
isParameterized in interface Route
Returns:
true if this Route's path parameterized, otherwise false.

isSecured

public boolean isSecured()
Description copied from interface: Route
Determines if this Route has roles configured.

Specified by:
isSecured in interface Route
Returns:
true if this Route has roles associated with its Route.

getRoles

public Set<String> getRoles()
Description copied from interface: Route
Gets this Routes associated roles.

Specified by:
getRoles in interface Route
Returns:
the roles associated with this Route, or an empty set if there are no roles associated.

hasExceptionsRoutes

public boolean hasExceptionsRoutes()
Description copied from interface: Route
Determines if this Route contains one or more exception routes.

Specified by:
hasExceptionsRoutes in interface Route
Returns:
true if this Route has one or more exception routes.

produces

public Set<MediaType> produces()
Description copied from interface: Route
Returns the media types that this Route is capable of serving.

Specified by:
produces in interface Route
Returns:
the media types that this routes can produce.

getParameters

public List<Parameter<?>> getParameters()
Description copied from interface: Route
Returns the Parameter's that this route accepts.

Specified by:
getParameters in interface Route
Returns:
the Parameter's that this route accepts.

consumes

public Set<String> consumes()
Description copied from interface: Route
Returns the media types that this Route is capable of consuming.

Specified by:
consumes in interface Route
Returns:
the media types that this routes can consuming.

canHandle

public boolean canHandle(Throwable throwable)
Description copied from interface: Route
Determines if this Route can handle the throwable.

Specified by:
canHandle in interface Route
Returns:
true if this Route can handle the Throwable, otherwise false.

toString

public String toString()
Overrides:
toString in class Object

asSet

private Set<RequestMethod> asSet(RequestMethod[] methods)

asSet

private Set<String> asSet(String[] strings)

asSet

private Set<MediaType> asSet(MediaType[] types)

asSet

private Set<String> asSet(List<String> strings,
                          String defaultValue)

emptyThrowableSet

private static Set<Class<? extends Throwable>> emptyThrowableSet()

defaultMediaTypes

private static MediaType[] defaultMediaTypes()

aerogear-controller 1.0.1

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