@Singleton @Replaces(value=DefaultLocalFunctionRegistry.class) public class AnnotatedFunctionRouteBuilder extends DefaultRouteBuilder implements ExecutableMethodProcessor<FunctionBean>, LocalFunctionRegistry, ServiceInstanceMetadataContributor, MediaTypeCodecRegistry
FunctionBean
instances.RouteBuilder.UriNamingStrategy
CAMEL_CASE_NAMING_STRATEGY, conversionService, defaultCharset, executionHandleLocator, LOG, uriNamingStrategy
FUNCTION_CHARSET, FUNCTION_NAME, FUNCTION_PREFIX
ID
Constructor and Description |
---|
AnnotatedFunctionRouteBuilder(ExecutionHandleLocator executionHandleLocator,
RouteBuilder.UriNamingStrategy uriNamingStrategy,
ConversionService<?> conversionService,
MediaTypeCodecRegistry codecRegistry,
java.lang.String contextPath)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
contribute(ServiceInstance instance,
java.util.Map<java.lang.String,java.lang.String> metadata)
Contribute metadata to the given
ServiceInstance prior to registration. |
<T,R> java.util.Optional<? extends ExecutableMethod<T,R>> |
find(java.lang.String name)
Find the first available registered function.
|
<T,U,R> java.util.Optional<ExecutableMethod<java.util.function.BiFunction<T,U,R>,R>> |
findBiFunction(java.lang.String name)
Find a
BiFunction for the given name. |
java.util.Optional<MediaTypeCodec> |
findCodec(MediaType mediaType)
Find a codec for the given media type.
|
java.util.Optional<MediaTypeCodec> |
findCodec(MediaType mediaType,
java.lang.Class<?> type)
Find a codec for the given media type and target type.
|
<T> java.util.Optional<ExecutableMethod<java.util.function.Consumer<T>,java.lang.Void>> |
findConsumer(java.lang.String name)
Find a
Consumer for the given name. |
<T,R> java.util.Optional<? extends ExecutableMethod<T,R>> |
findFirst()
Find the first available registered function.
|
<T,R> java.util.Optional<ExecutableMethod<java.util.function.Function<T,R>,R>> |
findFunction(java.lang.String name)
Find a
Function for the given name. |
<T> java.util.Optional<ExecutableMethod<java.util.function.Supplier<T>,T>> |
findSupplier(java.lang.String name)
Find a
Supplier for the given name. |
java.util.Map<java.lang.String,java.net.URI> |
getAvailableFunctions()
A map of available functions with the key being the function name and the value being the function URI.
|
java.util.Collection<MediaTypeCodec> |
getCodecs() |
void |
process(BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
The process method will be called for every
ExecutableMethod that is annotated with the type parameter A. |
addFilter, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
of, of
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 AnnotatedFunctionRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy, ConversionService<?> conversionService, MediaTypeCodecRegistry codecRegistry, @Value(value="${micronaut.function.context-path:/}") java.lang.String contextPath)
executionHandleLocator
- executionHandleLocatoruriNamingStrategy
- uriNamingStrategyconversionService
- conversionServicecodecRegistry
- codecRegistrycontextPath
- contextPathpublic void process(BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
ExecutableMethodProcessor
ExecutableMethod
that is annotated with the type parameter A.process
in interface AnnotationProcessor<FunctionBean,ExecutableMethod<?,?>>
process
in interface ExecutableMethodProcessor<FunctionBean>
beanDefinition
- The bean definition to processmethod
- The executable methodpublic java.util.Map<java.lang.String,java.net.URI> getAvailableFunctions()
getAvailableFunctions
in interface LocalFunctionRegistry
public <T,R> java.util.Optional<? extends ExecutableMethod<T,R>> findFirst()
LocalFunctionRegistry
findFirst
in interface LocalFunctionRegistry
T
- The declaring typeR
- The result of the method callExecutableMethod
method representing the functionpublic <T,R> java.util.Optional<? extends ExecutableMethod<T,R>> find(java.lang.String name)
LocalFunctionRegistry
find
in interface LocalFunctionRegistry
T
- The declaring typeR
- The result of the method callname
- the nameExecutableMethod
method representing the functionpublic <T> java.util.Optional<ExecutableMethod<java.util.function.Supplier<T>,T>> findSupplier(java.lang.String name)
LocalFunctionRegistry
Supplier
for the given name.findSupplier
in interface LocalFunctionRegistry
T
- The typename
- The nameOptional
of a Supplier
public <T> java.util.Optional<ExecutableMethod<java.util.function.Consumer<T>,java.lang.Void>> findConsumer(java.lang.String name)
LocalFunctionRegistry
Consumer
for the given name.findConsumer
in interface LocalFunctionRegistry
T
- The typename
- The nameOptional
of a Consumer
public <T,R> java.util.Optional<ExecutableMethod<java.util.function.Function<T,R>,R>> findFunction(java.lang.String name)
LocalFunctionRegistry
Function
for the given name.findFunction
in interface LocalFunctionRegistry
T
- The typeR
- The result of the method callname
- The nameOptional
of a Function
public <T,U,R> java.util.Optional<ExecutableMethod<java.util.function.BiFunction<T,U,R>,R>> findBiFunction(java.lang.String name)
LocalFunctionRegistry
BiFunction
for the given name.findBiFunction
in interface LocalFunctionRegistry
T
- The typeU
- the type of the second argument to the functionR
- The result of the method callname
- The nameOptional
of a BiFunction
public void contribute(ServiceInstance instance, java.util.Map<java.lang.String,java.lang.String> metadata)
ServiceInstanceMetadataContributor
ServiceInstance
prior to registration.contribute
in interface ServiceInstanceMetadataContributor
instance
- The instancemetadata
- The metadatapublic java.util.Optional<MediaTypeCodec> findCodec(MediaType mediaType)
MediaTypeCodecRegistry
findCodec
in interface MediaTypeCodecRegistry
mediaType
- The MediaType
public java.util.Optional<MediaTypeCodec> findCodec(MediaType mediaType, java.lang.Class<?> type)
MediaTypeCodecRegistry
findCodec
in interface MediaTypeCodecRegistry
mediaType
- The MediaType
type
- The typepublic java.util.Collection<MediaTypeCodec> getCodecs()
getCodecs
in interface MediaTypeCodecRegistry