0
votes

Is there a way to retrieve the job beans declared within this location: classpath*/META-INF/spring/batch/jobs/*.xml ?

Tried the code below but I was not able to retrieve them.

  @Autowired
  private ApplicationContext applicationContext;

  public void sometMethod() {

      AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
      String[] strings = ((BeanDefinitionRegistry) beanFactory).getBeanDefinitionNames();

  }
1

1 Answers

0
votes

I was able to able to merge the applicationContext and the job bean definitions with the following changes:

      @Autowired
      private ApplicationContext applicationContext;

      public void sometMethod() {

          ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"classpath:META-INF/spring/batch/jobs/*.xml"}, applicationContext); 
          AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
          String[] strings = ((BeanDefinitionRegistry) beanFactory).getBeanDefinitionNames();

      }