public final class JetSpringServiceFactories extends Object
service factories
and transform functions.Modifier and Type | Method and Description |
---|---|
static <T> ServiceFactory<?,T> |
bean(Class<T> requiredType)
Returns a Spring Bean
ServiceFactory . |
static <T> ServiceFactory<?,T> |
bean(String beanName)
Returns a Spring Bean
ServiceFactory . |
static <T> ServiceFactory<?,T> |
bean(String beanName,
Class<T> requiredType)
Returns a Spring Bean
ServiceFactory . |
public static <T> ServiceFactory<?,T> bean(@Nonnull String beanName, @Nonnull Class<T> requiredType)
ServiceFactory
. The factory creates a
context object which autowires the ApplicationContext
. The
context object obtains the specified bean from ApplicationContext
and returns it as a service.
Below is a sample usage which reads the names from a list and maps those
names to User
objects using the spring bean userDao
.
Pipeline pipeline = Pipeline.create();
pipeline.<String>readFrom(Sources.list(LIST_NAME))
.mapUsingService(JetSpringServiceFactories.bean("userDao", UserDao.class),
(userDao, item) -> userDao.findByName(item.toLowerCase()))
.writeTo(Sinks.logger());
T
- the type of the beanbeanName
- the name of the beanrequiredType
- the class of the beanpublic static <T> ServiceFactory<?,T> bean(@Nonnull Class<T> requiredType)
ServiceFactory
. The factory creates a
context object which autowires the ApplicationContext
. The
context object obtains the specified bean from ApplicationContext
and returns it as a service.
Below is a sample usage which reads the names from a list and maps those
names to User
objects using the spring bean userDao
.
Pipeline pipeline = Pipeline.create();
pipeline.<String>readFrom(Sources.list(LIST_NAME))
.mapUsingService(JetSpringServiceFactories.bean(UserDao.class),
(userDao, item) -> userDao.findByName(item.toLowerCase()))
.writeTo(Sinks.logger());
T
- the type of the beanrequiredType
- the class of the beanpublic static <T> ServiceFactory<?,T> bean(@Nonnull String beanName)
ServiceFactory
. The factory creates a
context object which autowires the ApplicationContext
. The
context object obtains the specified bean from ApplicationContext
and returns it as a service.
Below is a sample usage which reads the names from a list and maps those
names to User
objects using the spring bean userDao
.
Pipeline pipeline = Pipeline.create();
pipeline.<String>readFrom(Sources.list(LIST_NAME))
.mapUsingService(JetSpringServiceFactories.bean("userDao"),
(userDao, item) -> userDao.findByName(item.toLowerCase()))
.writeTo(Sinks.logger());
T
- the type of the beanbeanName
- the name of the beanCopyright © 2021 Hazelcast, Inc.. All rights reserved.