[picocontainer-dev] ComponentMonitorStrategy Interface Problem + Pico Scripting
"Michael Rimov" <[email protected]> Tue, 17 Jun 2008 23:18:50 -0700
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Organization | Centerline Computers, Inc |
| Message-ID | <013201c8d10b$2ea99410$8bfcbc30$@com> |
Hi all. I hit a problem with the new DefaultClassLoadingPicoContainer. The
culprit code is invoked when parent.createChildContainer() is called:
protected DefaultClassLoadingPicoContainer createChildContainer() {
MutablePicoContainer child = getDelegate().makeChildContainer();
DefaultClassLoadingPicoContainer container = new
DefaultClassLoadingPicoContainer(getComponentClassLoader(), child);
container.changeMonitor(currentMonitor());
return container;
}
public void changeMonitor(ComponentMonitor monitor) {
((ComponentMonitorStrategy) getDelegate()).changeMonitor(monitor);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
If the delegate happens to be a DefaultClassLoadingPicoContainer, then the
result is a class cast exception, which happens a little more often than not
because there's only a few containers that implement ComponentMonitorStrategy,
and AbstractDelegatingPicoContainer is not one of them.
So, do we have MutablePicoContainer implement ComponentMonitorStrategy, or do we
just more defensively program changeMonitor()? Or is there another option?
Thanks,
-Mike
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email