|
From: Nimish <nim...@ya...> - 2004-05-28 18:39:36
|
> Mike,
>
> Your approach seems to be perfectly OK. I"ve just
tried > to reproduce your issue but wasn"t
> able to: I always get a single instance, no matter
if ? > implementing ApplicationListener or
> not. Could you double-check the effect, and possibly
> send a minimal test case that
> reproduces the problem?
>
> Juergen
Hi,
I am getting a similar problem as Mike. I am writing a
WebApp using Spring and I have a a filter which is
used to trace the requests. In the web.xml, I am
creating two instances of the filter class. However,
when I try to get a singleton bean from
XmlWebApplicationContext in the init() method of the
filter, I get a different object.
The code that retrieves the bean in the init() method,
looks like this:
if(context.containsBean("statusReporter")) {
if(logger.isDebugEnabled()) logger.debug("Singleton:
" + context.isSingleton("statusReporter"));
StatusReporter reporter =
(StatusReporter)context.getBean("statusReporter");
logger.debug("Status reporter: " +
reporter.hashCode());
}
The last debug statements prints a different hashcodes
for each invocation of init(). I have made sure that
the "context" object is the same in both cases.
Any clues, mistakes, bugs that I am overlooking?
Thanks in advance,
Nimish
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
|