public abstract class DefaultRouteBuilder extends java.lang.Object implements RouteBuilder
RouteBuilder.UriNamingStrategy
Modifier and Type | Field and Description |
---|---|
static RouteBuilder.UriNamingStrategy |
CAMEL_CASE_NAMING_STRATEGY
A
RouteBuilder.UriNamingStrategy where by camel case conventions are used. |
protected ConversionService<?> |
conversionService |
protected java.nio.charset.Charset |
defaultCharset |
protected ExecutionHandleLocator |
executionHandleLocator |
protected static org.slf4j.Logger |
LOG |
protected RouteBuilder.UriNamingStrategy |
uriNamingStrategy |
ID
Constructor and Description |
---|
DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator) |
DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator,
RouteBuilder.UriNamingStrategy uriNamingStrategy) |
DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator,
RouteBuilder.UriNamingStrategy uriNamingStrategy,
ConversionService<?> conversionService) |
Modifier and Type | Method and Description |
---|---|
FilterRoute |
addFilter(java.lang.String pathPattern,
BeanLocator beanLocator,
BeanDefinition<? extends HttpFilter> beanDefinition)
Add a filter.
|
FilterRoute |
addFilter(java.lang.String pathPattern,
java.util.function.Supplier<HttpFilter> filter)
Add a filter.
|
protected UriRoute |
buildBeanRoute(java.lang.String httpMethodName,
HttpMethod httpMethod,
java.lang.String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
A special case that is required for non standard http methods.
|
protected UriRoute |
buildRoute(HttpMethod httpMethod,
java.lang.String uri,
java.lang.Class<?> type,
java.lang.String method,
java.lang.Class... parameterTypes)
Build a route.
|
protected UriRoute |
buildRoute(HttpMethod httpMethod,
java.lang.String uri,
MethodExecutionHandle<?,java.lang.Object> executableHandle)
Build a route.
|
UriRoute |
DELETE(java.lang.String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
DELETE(java.lang.String uri,
java.lang.Class type,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
DELETE(java.lang.String uri,
java.lang.Object target,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
ErrorRoute |
error(java.lang.Class<? extends java.lang.Throwable> error,
java.lang.Class type,
java.lang.String method,
java.lang.Class[] parameterTypes)
Register a route to handle the error.
|
ErrorRoute |
error(java.lang.Class originatingClass,
java.lang.Class<? extends java.lang.Throwable> error,
java.lang.Class type,
java.lang.String method,
java.lang.Class[] parameterTypes)
Register a route to handle the error.
|
UriRoute |
GET(java.lang.String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
GET(java.lang.String uri,
java.lang.Class<?> type,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
GET(java.lang.String uri,
java.lang.Object target,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
java.util.List<ErrorRoute> |
getErrorRoutes() |
java.util.Set<java.lang.Integer> |
getExposedPorts() |
java.util.List<FilterRoute> |
getFilterRoutes() |
java.util.List<StatusRoute> |
getStatusRoutes() |
RouteBuilder.UriNamingStrategy |
getUriNamingStrategy() |
java.util.List<UriRoute> |
getUriRoutes() |
UriRoute |
HEAD(java.lang.String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
HEAD(java.lang.String uri,
java.lang.Class type,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
HEAD(java.lang.String uri,
java.lang.Object target,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
OPTIONS(java.lang.String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
OPTIONS(java.lang.String uri,
java.lang.Class type,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
OPTIONS(java.lang.String uri,
java.lang.Object target,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
PATCH(java.lang.String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
PATCH(java.lang.String uri,
java.lang.Class type,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
PATCH(java.lang.String uri,
java.lang.Object target,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
POST(java.lang.String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
POST(java.lang.String uri,
java.lang.Class type,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
POST(java.lang.String uri,
java.lang.Object target,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
PUT(java.lang.String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
PUT(java.lang.String uri,
java.lang.Class type,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
PUT(java.lang.String uri,
java.lang.Object target,
java.lang.String method,
java.lang.Class... parameterTypes)
Route the specified URI template to the specified target.
|
ResourceRoute |
resources(java.lang.Class cls)
Builds the necessary mappings to treat the given class as a REST endpoint.
|
ResourceRoute |
single(java.lang.Class cls)
Builds the necessary mappings to treat the given class as a singular REST endpoint.
|
StatusRoute |
status(java.lang.Class originatingClass,
HttpStatus status,
java.lang.Class type,
java.lang.String method,
java.lang.Class[] parameterTypes)
Register a route to handle the returned status code.
|
StatusRoute |
status(HttpStatus status,
java.lang.Class type,
java.lang.String method,
java.lang.Class[] parameterTypes)
Register a route to handle the returned status code.
|
UriRoute |
TRACE(java.lang.String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
TRACE(java.lang.String uri,
java.lang.Class type,
java.lang.String method,
java.lang.Class[] parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
TRACE(java.lang.String uri,
java.lang.Object target,
java.lang.String method,
java.lang.Class[] parameterTypes)
Route the specified URI template to the specified target.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
DELETE, DELETE, DELETE, DELETE, DELETE, DELETE, error, error, error, error, GET, GET, GET, GET, GET, GET, HEAD, HEAD, HEAD, HEAD, HEAD, HEAD, OPTIONS, OPTIONS, OPTIONS, OPTIONS, OPTIONS, OPTIONS, PATCH, PATCH, PATCH, PATCH, PATCH, PATCH, POST, POST, POST, POST, POST, POST, PUT, PUT, PUT, PUT, PUT, PUT, resources, single, status, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE
public static final RouteBuilder.UriNamingStrategy CAMEL_CASE_NAMING_STRATEGY
RouteBuilder.UriNamingStrategy
where by camel case conventions are used.protected static final org.slf4j.Logger LOG
protected final ExecutionHandleLocator executionHandleLocator
protected final RouteBuilder.UriNamingStrategy uriNamingStrategy
protected final ConversionService<?> conversionService
protected final java.nio.charset.Charset defaultCharset
public DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator)
executionHandleLocator
- The execution handler locatorpublic DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy)
executionHandleLocator
- The execution handler locatoruriNamingStrategy
- The URI naming strategypublic DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy, ConversionService<?> conversionService)
executionHandleLocator
- The execution handler locatoruriNamingStrategy
- The URI naming strategyconversionService
- The conversion servicepublic java.util.Set<java.lang.Integer> getExposedPorts()
getExposedPorts
in interface RouteBuilder
public java.util.List<FilterRoute> getFilterRoutes()
getFilterRoutes
in interface RouteBuilder
public FilterRoute addFilter(java.lang.String pathPattern, java.util.function.Supplier<HttpFilter> filter)
RouteBuilder
addFilter
in interface RouteBuilder
pathPattern
- The path pattern for the filterfilter
- The filter itselfFilterRoute
public FilterRoute addFilter(java.lang.String pathPattern, BeanLocator beanLocator, BeanDefinition<? extends HttpFilter> beanDefinition)
RouteBuilder
addFilter
in interface RouteBuilder
pathPattern
- The path pattern for the filterbeanLocator
- The bean locatorbeanDefinition
- The bean definitionFilterRoute
public java.util.List<StatusRoute> getStatusRoutes()
getStatusRoutes
in interface RouteBuilder
public java.util.List<ErrorRoute> getErrorRoutes()
getErrorRoutes
in interface RouteBuilder
public java.util.List<UriRoute> getUriRoutes()
getUriRoutes
in interface RouteBuilder
public RouteBuilder.UriNamingStrategy getUriNamingStrategy()
getUriNamingStrategy
in interface RouteBuilder
public ResourceRoute resources(java.lang.Class cls)
RouteBuilder
Builds the necessary mappings to treat the given class as a REST endpoint.
For example given a class called BookController the following routes will be produced:
GET "/book"
GET "/book{/id}"
POST "/book"
PUT "/book{/id}"
PATCH "/book{/id}"
DELETE "/book{/id}"
By default it is assumed the accepted and returned content type is
MediaType.APPLICATION_JSON_TYPE
.
resources
in interface RouteBuilder
cls
- The classResourceRoute
public ResourceRoute single(java.lang.Class cls)
RouteBuilder
Builds the necessary mappings to treat the given class as a singular REST endpoint.
For example given a class called BookController the following routes will be produced:
GET "/book"
POST "/book"
PUT "/book"
PATCH "/book"
DELETE "/book"
By default it is assumed the accepted and returned content type is
MediaType.APPLICATION_JSON_TYPE
.
single
in interface RouteBuilder
cls
- The classResourceRoute
public StatusRoute status(java.lang.Class originatingClass, HttpStatus status, java.lang.Class type, java.lang.String method, java.lang.Class[] parameterTypes)
RouteBuilder
status
in interface RouteBuilder
originatingClass
- The class where the error originates fromstatus
- The status codetype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic StatusRoute status(HttpStatus status, java.lang.Class type, java.lang.String method, java.lang.Class[] parameterTypes)
RouteBuilder
status
in interface RouteBuilder
status
- The status codetype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic ErrorRoute error(java.lang.Class originatingClass, java.lang.Class<? extends java.lang.Throwable> error, java.lang.Class type, java.lang.String method, java.lang.Class[] parameterTypes)
RouteBuilder
error
in interface RouteBuilder
originatingClass
- The class where the error originates fromerror
- The error typetype
- The type to route tomethod
- The method THe method to route toparameterTypes
- The parameter types for the target methodpublic ErrorRoute error(java.lang.Class<? extends java.lang.Throwable> error, java.lang.Class type, java.lang.String method, java.lang.Class[] parameterTypes)
RouteBuilder
error
in interface RouteBuilder
error
- The errortype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute GET(java.lang.String uri, java.lang.Object target, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
GET
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute GET(java.lang.String uri, java.lang.Class<?> type, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
GET
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute POST(java.lang.String uri, java.lang.Object target, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
POST
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute POST(java.lang.String uri, java.lang.Class type, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
POST
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute PUT(java.lang.String uri, java.lang.Object target, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PUT
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute PUT(java.lang.String uri, java.lang.Class type, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PUT
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute PATCH(java.lang.String uri, java.lang.Object target, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PATCH
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute PATCH(java.lang.String uri, java.lang.Class type, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PATCH
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute DELETE(java.lang.String uri, java.lang.Object target, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
DELETE
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute DELETE(java.lang.String uri, java.lang.Class type, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
DELETE
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute OPTIONS(java.lang.String uri, java.lang.Object target, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
OPTIONS
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute OPTIONS(java.lang.String uri, java.lang.Class type, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
OPTIONS
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute HEAD(java.lang.String uri, java.lang.Object target, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
HEAD
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute HEAD(java.lang.String uri, java.lang.Class type, java.lang.String method, java.lang.Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
HEAD
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute TRACE(java.lang.String uri, java.lang.Object target, java.lang.String method, java.lang.Class[] parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
TRACE
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute TRACE(java.lang.String uri, java.lang.Class type, java.lang.String method, java.lang.Class[] parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
TRACE
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute GET(java.lang.String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
GET
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute POST(java.lang.String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
POST
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute PUT(java.lang.String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PUT
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute PATCH(java.lang.String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PATCH
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute DELETE(java.lang.String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
DELETE
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute OPTIONS(java.lang.String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
OPTIONS
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute HEAD(java.lang.String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
HEAD
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute TRACE(java.lang.String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
TRACE
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodprotected UriRoute buildRoute(HttpMethod httpMethod, java.lang.String uri, java.lang.Class<?> type, java.lang.String method, java.lang.Class... parameterTypes)
httpMethod
- The HTTP methoduri
- The URItype
- The typemethod
- The methodparameterTypes
- ParametersUriRoute
protected UriRoute buildRoute(HttpMethod httpMethod, java.lang.String uri, MethodExecutionHandle<?,java.lang.Object> executableHandle)
httpMethod
- The HTTP methoduri
- The URIexecutableHandle
- The executable handleUriRoute
protected UriRoute buildBeanRoute(java.lang.String httpMethodName, HttpMethod httpMethod, java.lang.String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
httpMethodName
- The name of method. For standard http methods matches Enum.name()
httpMethod
- The http method. Is HttpMethod.CUSTOM
for non standard http methods.uri
- The uri.beanDefinition
- The definition of the bean.method
- The method description