public class BeanFactoryAwareFunctionRegistry extends Object implements FunctionRegistry, FunctionInspector, org.springframework.context.ApplicationContextAware
FunctionRegistry
and FunctionCatalog
which is aware of the
underlying BeanFactory
to access available functions. Functions that are registered via
register(FunctionRegistration)
operation are stored/cached locally.Modifier and Type | Class and Description |
---|---|
class |
BeanFactoryAwareFunctionRegistry.FunctionInvocationWrapper
Single wrapper for all Suppliers, Functions and Consumers managed by this
catalog.
|
Constructor and Description |
---|
BeanFactoryAwareFunctionRegistry(org.springframework.core.convert.ConversionService conversionService,
org.springframework.messaging.converter.CompositeMessageConverter messageConverter) |
Modifier and Type | Method and Description |
---|---|
Set<String> |
getNames(Class<?> type) |
FunctionRegistration<?> |
getRegistration(Object function) |
<T> T |
lookup(Class<?> type,
String definition)
Will look up the instance of the functional interface by name and type which
can only be Supplier, Consumer or Function.
|
<T> T |
lookup(String definition,
String... acceptedOutputTypes)
Will look up the instance of the functional interface by name only.
|
<T> void |
register(FunctionRegistration<T> registration) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
int |
size()
Return the count of functions registered in this catalog.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
lookup
getInputType, getInputWrapper, getName, getOutputType, getOutputWrapper, isMessage
public BeanFactoryAwareFunctionRegistry(org.springframework.core.convert.ConversionService conversionService, @Nullable org.springframework.messaging.converter.CompositeMessageConverter messageConverter)
public <T> T lookup(Class<?> type, String definition)
FunctionCatalog
lookup
in interface FunctionCatalog
T
- instance typetype
- the type of functional interface. Can be nulldefinition
- the definition of the functional interface. Must
not be null;public int size()
FunctionCatalog
size
in interface FunctionCatalog
public <T> T lookup(String definition, String... acceptedOutputTypes)
FunctionCatalog
Message<byte[]>
. Function<Message<byte[]>, Message<byte[]>>
or
Function<Flux<Message<byte[]>>, Flux<Message<byte[]>>>
or
Consumer<Flux<Message<Flux<Message<byte[]>>>
etc. . .
acceptedOutputMimeTypes
are the string representation of MimeType
where each
mime-type in the provided array would correspond to the output with the same index
(for cases of functions with multiple outputs) and is used to convert such output back
to Message<byte[]>
.
If you need to provide several accepted types per specific output you can simply delimit
them with comma (e.g., application/json,text/plain...
).lookup
in interface FunctionCatalog
T
- instance type which should be one of Supplier
, Function
or Consumer
.definition
- the definition of a function (e.g., 'foo' or 'foo|bar')acceptedOutputTypes
- acceptedOutputMimeTypes array of string representation of MimeType
s
used to convert function output back to Message<byte[]>
.public Set<String> getNames(Class<?> type)
getNames
in interface FunctionCatalog
public <T> void register(FunctionRegistration<T> registration)
register
in interface FunctionRegistry
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public FunctionRegistration<?> getRegistration(Object function)
getRegistration
in interface FunctionInspector
Copyright © 2019 Pivotal Software, Inc.. All rights reserved.