Package com.hazelcast.jet.spring
Class JetSpringServiceFactories
java.lang.Object
com.hazelcast.jet.spring.JetSpringServiceFactories
public final class JetSpringServiceFactories extends Object
Utility class with methods that create several useful Spring Bean
service factories
and transform functions.- Since:
- 4.0
-
Method Summary
Modifier and Type Method Description static <T> ServiceFactory<?,T>
bean(Class<T> requiredType)
Returns a Spring BeanServiceFactory
.static <T> ServiceFactory<?,T>
bean(String beanName)
Returns a Spring BeanServiceFactory
.static <T> ServiceFactory<?,T>
bean(String beanName, Class<T> requiredType)
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())) .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())) .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())) .writeTo(Sinks.logger());
- Type Parameters:
T
- the type of the bean- Parameters:
beanName
- the name of the bean
-