Package com.hazelcast.spring.jet
Class JetSpringServiceFactories
java.lang.Object
com.hazelcast.spring.jet.JetSpringServiceFactories
Utility class with methods that create several useful Spring Bean
service factories
and transform functions.- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ServiceFactory<?,
T> Returns a Spring BeanServiceFactory
.static <T> ServiceFactory<?,
T> Returns a Spring BeanServiceFactory
.static <T> ServiceFactory<?,
T> Returns a Spring BeanServiceFactory
.
-
Method Details
-
bean
public static <T> ServiceFactory<?,T> bean(@Nonnull String beanName, @Nonnull Class<T> requiredType) Returns a Spring BeanServiceFactory
. The factory creates a context object which autowires theApplicationContext
. The context object obtains the specified bean fromApplicationContext
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 beanuserDao
.Pipeline pipeline = Pipeline.create(); pipeline.<String>readFrom(Sources.list(LIST_NAME)) .mapUsingService(JetSpringServiceFactories.bean("userDao", UserDao.class), (userDao, item) -> userDao.findByName(item.toLowerCase(Locale.ROOT))) .writeTo(Sinks.logger());
- Type Parameters:
T
- the type of the bean- Parameters:
beanName
- the name of the beanrequiredType
- the class of the bean
-
bean
Returns a Spring BeanServiceFactory
. The factory creates a context object which autowires theApplicationContext
. The context object obtains the specified bean fromApplicationContext
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 beanuserDao
.Pipeline pipeline = Pipeline.create(); pipeline.<String>readFrom(Sources.list(LIST_NAME)) .mapUsingService(JetSpringServiceFactories.bean(UserDao.class), (userDao, item) -> userDao.findByName(item.toLowerCase(Locale.ROOT))) .writeTo(Sinks.logger());
- Type Parameters:
T
- the type of the bean- Parameters:
requiredType
- the class of the bean
-
bean
Returns a Spring BeanServiceFactory
. The factory creates a context object which autowires theApplicationContext
. The context object obtains the specified bean fromApplicationContext
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 beanuserDao
.Pipeline pipeline = Pipeline.create(); pipeline.<String>readFrom(Sources.list(LIST_NAME)) .mapUsingService(JetSpringServiceFactories.bean("userDao"), (userDao, item) -> userDao.findByName(item.toLowerCase(Locale.ROOT))) .writeTo(Sinks.logger());
- Type Parameters:
T
- the type of the bean- Parameters:
beanName
- the name of the bean
-