-1

Currently I'm working on legacy Hybris project. We use Hybris 4.8 and Srping 3 with Java 7.

There is a factory class which performs some logic in order to instantiate another bean. The thing is that this factory bean interacts with other beans from Spring context and with database during startup and Spring seems to be unable to resolve all dependencies correctly. So we get deadlock during startup.

To avoid this problem this particular bean could be created after all other beans are initialized (or even right after server startup). How do I do such kind of thing in hybris?

I understand that the whole architectural concept looks a little bit odd, but it's a legacy project and the solution must be found as quickly as possible and with minimal changes

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Roman P
  • 51
  • 7
  • 1. Create a bean class that implements `ApplicationListener` and listens to the `ContextRefreshedEvent` event. 2. Implement the `onApplicationEvent` method of this class to perform the required logic, for example, `MyFactory factory = new MyFactory(); context.getAutowireCapableBeanFactory().autowireBean(factory);`. – manish Aug 14 '18 at 06:47

1 Answers1

0

You can probably achieve what you need with BeanFactoryPostProcessor or BeanPostProcessor.

About the difference read : https://stackoverflow.com/a/30456202/1140748

You can find implementation sample on the net.

alain.janinm
  • 19,951
  • 10
  • 65
  • 112