Package io.micronaut.function.web
Class AnnotatedFunctionRouteBuilder
java.lang.Object
io.micronaut.web.router.DefaultRouteBuilder
io.micronaut.function.web.AnnotatedFunctionRouteBuilder
- All Implemented Interfaces:
AnnotationProcessor<FunctionBean,
,ExecutableMethod<?, ?>> ExecutableMethodProcessor<FunctionBean>
,LocalFunctionRegistry
,MediaTypeCodecRegistry
,RouteBuilder
@Singleton
@Replaces(DefaultLocalFunctionRegistry.class)
public class AnnotatedFunctionRouteBuilder
extends DefaultRouteBuilder
implements ExecutableMethodProcessor<FunctionBean>, LocalFunctionRegistry, MediaTypeCodecRegistry
Process methods for
FunctionBean
instances.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.web.router.RouteBuilder
RouteBuilder.UriNamingStrategy
-
Field Summary
Fields inherited from class io.micronaut.web.router.DefaultRouteBuilder
CAMEL_CASE_NAMING_STRATEGY, conversionService, defaultCharset, executionHandleLocator, LOG, uriNamingStrategy
Fields inherited from interface io.micronaut.function.LocalFunctionRegistry
FUNCTION_CHARSET, FUNCTION_NAME, FUNCTION_PREFIX
Fields inherited from interface io.micronaut.web.router.RouteBuilder
ID
-
Constructor Summary
ConstructorDescriptionAnnotatedFunctionRouteBuilder
(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy, ConversionService conversionService, MediaTypeCodecRegistry codecRegistry, String contextPath) Constructor. -
Method Summary
Modifier and TypeMethodDescription<T,
R> Optional<? extends ExecutableMethod<T, R>> Find the first available registered function.<T,
U, R> Optional<ExecutableMethod<BiFunction<T, U, R>, R>> findBiFunction
(String name) Find aBiFunction
for the given name.Find a codec for the given media type.Find a codec for the given media type and target type.<T> Optional<ExecutableMethod<Consumer<T>,
Void>> findConsumer
(String name) Find aConsumer
for the given name.<T,
R> Optional<? extends ExecutableMethod<T, R>> Find the first available registered function.<T,
R> Optional<ExecutableMethod<Function<T, R>, R>> findFunction
(String name) Find aFunction
for the given name.<T> Optional<ExecutableMethod<Supplier<T>,
T>> findSupplier
(String name) Find aSupplier
for the given name.A map of available functions with the key being the function name and the value being the function URI.void
process
(BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) The process method will be called for everyExecutableMethod
that is annotated with the type parameter A.Methods inherited from class io.micronaut.web.router.DefaultRouteBuilder
addFilter, buildBeanRoute, buildRoute, buildRoute, DELETE, DELETE, DELETE, error, error, GET, GET, GET, getErrorRoutes, getExposedPorts, getFilterRoutes, getStatusRoutes, getUriNamingStrategy, getUriRoutes, HEAD, HEAD, HEAD, OPTIONS, OPTIONS, OPTIONS, PATCH, PATCH, PATCH, POST, POST, POST, PUT, PUT, PUT, resources, single, status, status, TRACE, TRACE, TRACE
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.web.router.RouteBuilder
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
-
Constructor Details
-
AnnotatedFunctionRouteBuilder
public AnnotatedFunctionRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy, ConversionService conversionService, MediaTypeCodecRegistry codecRegistry, @Value("${micronaut.function.context-path:/}") String contextPath) Constructor.- Parameters:
executionHandleLocator
- executionHandleLocatoruriNamingStrategy
- uriNamingStrategyconversionService
- conversionServicecodecRegistry
- codecRegistrycontextPath
- contextPath
-
-
Method Details
-
process
Description copied from interface:ExecutableMethodProcessor
The process method will be called for everyExecutableMethod
that is annotated with the type parameter A.- Specified by:
process
in interfaceAnnotationProcessor<FunctionBean,
ExecutableMethod<?, ?>> - Specified by:
process
in interfaceExecutableMethodProcessor<FunctionBean>
- Parameters:
beanDefinition
- The bean definition to processmethod
- The executable method
-
getAvailableFunctions
A map of available functions with the key being the function name and the value being the function URI.- Specified by:
getAvailableFunctions
in interfaceLocalFunctionRegistry
- Returns:
- A map of functions
-
findFirst
Description copied from interface:LocalFunctionRegistry
Find the first available registered function.- Specified by:
findFirst
in interfaceLocalFunctionRegistry
- Type Parameters:
T
- The declaring typeR
- The result of the method call- Returns:
- The
ExecutableMethod
method representing the function
-
find
Description copied from interface:LocalFunctionRegistry
Find the first available registered function.- Specified by:
find
in interfaceLocalFunctionRegistry
- Type Parameters:
T
- The declaring typeR
- The result of the method call- Parameters:
name
- the name- Returns:
- The
ExecutableMethod
method representing the function
-
findSupplier
Description copied from interface:LocalFunctionRegistry
Find aSupplier
for the given name.- Specified by:
findSupplier
in interfaceLocalFunctionRegistry
- Type Parameters:
T
- The type- Parameters:
name
- The name- Returns:
- An
Optional
of aSupplier
-
findConsumer
Description copied from interface:LocalFunctionRegistry
Find aConsumer
for the given name.- Specified by:
findConsumer
in interfaceLocalFunctionRegistry
- Type Parameters:
T
- The type- Parameters:
name
- The name- Returns:
- An
Optional
of aConsumer
-
findFunction
Description copied from interface:LocalFunctionRegistry
Find aFunction
for the given name.- Specified by:
findFunction
in interfaceLocalFunctionRegistry
- Type Parameters:
T
- The typeR
- The result of the method call- Parameters:
name
- The name- Returns:
- An
Optional
of aFunction
-
findBiFunction
Description copied from interface:LocalFunctionRegistry
Find aBiFunction
for the given name.- Specified by:
findBiFunction
in interfaceLocalFunctionRegistry
- Type Parameters:
T
- The typeU
- the type of the second argument to the functionR
- The result of the method call- Parameters:
name
- The name- Returns:
- An
Optional
of aBiFunction
-
findCodec
Description copied from interface:MediaTypeCodecRegistry
Find a codec for the given media type.- Specified by:
findCodec
in interfaceMediaTypeCodecRegistry
- Parameters:
mediaType
- TheMediaType
- Returns:
- The codec
-
findCodec
Description copied from interface:MediaTypeCodecRegistry
Find a codec for the given media type and target type.- Specified by:
findCodec
in interfaceMediaTypeCodecRegistry
- Parameters:
mediaType
- TheMediaType
type
- The type- Returns:
- The codec
-
getCodecs
- Specified by:
getCodecs
in interfaceMediaTypeCodecRegistry
- Returns:
- The available codecs
-