I have a custom scope defined for my Spring configuration, I want to initialize some of my beans “right after” my custom scope is created. At the moment my bean is not initialized because probably it is not called on right time when the scope is ready yet.
“myScope” is created through Java code.
<bean id="myAdvice" class="com.myclass" scope="myScope">
<property name="name1" ref="ref1" />
</bean>
Well then either switch to XML or to Java-based configuration. If you do, your scope can have lifecycle callback methods, implement InitializingBean etc.
If you don’t you have to do all that yourself programmatically when you initialize your scope. You would use
applicationContext.getAutowireCapableBeanfactory()and use theAutowireCapableBeanFactoryto wire the scope manually, using something likeAutowireCapableBeanFactory.initializeBean(Object, String)to post-process the scope (which will also execute any registered lifecycle callbacks).