Class JetSpringServiceFactories

java.lang.Object
com.hazelcast.spring.jet.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 Details

    • bean

      public static <T> ServiceFactory<?,T> bean(@Nonnull String beanName, @Nonnull Class<T> requiredType)
      Returns a Spring Bean 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(Locale.ROOT)))
               .writeTo(Sinks.logger());
       
      Type Parameters:
      T - the type of the bean
      Parameters:
      beanName - the name of the bean
      requiredType - the class of the bean
    • bean

      public static <T> ServiceFactory<?,T> bean(@Nonnull Class<T> requiredType)
      Returns a Spring Bean 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(Locale.ROOT)))
               .writeTo(Sinks.logger());
       
      Type Parameters:
      T - the type of the bean
      Parameters:
      requiredType - the class of the bean
    • bean

      public static <T> ServiceFactory<?,T> bean(@Nonnull String beanName)
      Returns a Spring Bean 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(Locale.ROOT)))
               .writeTo(Sinks.logger());
       
      Type Parameters:
      T - the type of the bean
      Parameters:
      beanName - the name of the bean