0

In my application I use an XML Application Context to configure and build Spring beans.

I have a bean which is an observer and an observed bean. The configuration looks something like

<bean class="com.example.Observer">
  <property name="observedBean">
    <bean class="com.example.Observed" />
  </property>
</bean>

My problem is, that there is nobody explicitly asking for a reference of the observer neither the observer nor the observed bean will be created.

Since there is no need of an explicit reference I would like to avoid just asking the ApplicationContext for a reference to just ignore it again.

Is there any solution for my problem or do I have a problem with my concept?

Hannes
  • 5,002
  • 8
  • 31
  • 60
  • 2
    It should be available after [`ApplicationContext.refresh()`](http://docs.spring.io/spring/docs/2.5.x/api/org/springframework/context/support/AbstractApplicationContext.html#refresh()) is called. How is your application bootstrapped? – Bart Mar 17 '14 at 17:27
  • @Bart Nothing special, I instantiate the application context and that's all. I was looking for bootstrapping hints for Spring applications which are not deployed on an Application Server but I didn't quite find anything. – Hannes Mar 17 '14 at 20:55
  • Then call the refresh method on that instance. – Bart Mar 17 '14 at 21:31
  • @Bart Thanks for your input - but is this an ugly workaround or way to go? Anyway, I will try it ... – Hannes Mar 17 '14 at 21:40
  • I can't say calling a method is a ugly workaround ;) – Bart Mar 17 '14 at 22:12

0 Answers0