|
From: JP P. <jp....@ti...> - 2003-07-21 19:58:28
|
Hi,
I have a kind of business objects that initialize them with data from
the Business Messages property file using getMessage().
Searching the MessageSource bean would be a hack.
Currently, AbstractApplicationContext initializes the messageSource at
the very end of the process and notably before
preInstantiateSingletons().
Is a reason for that order or it is only a hazard? I understand that
MessageSource will so not be treated if an Exception is thrown by a
singleton.
That has for consequence that getMessage() is not available when the
bean receives the ApplicationContext. As workaround, I have changed the
concerned singletons from ApplicationContextAware to
ApplicationListener. And the initialization occurs in the
onApplicationEvent with a statement like "if (event instanceof
ContextRefreshedEvent) { x x x }".
Is this the best solution or initialling earlier the messageSource could
be possible?
Regards,
Jean-Pierre
|