|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
assign null in constructor paramHello,
My setup is PicoContainer 2.8.3 against JVM 1.5. I'm trying to explicitly assign a null in a constructor param: === public class ComponentClass{ public ComponentClass(ArgClass arg) } } pico.addComponent("myComponent", ComponentClass.class, new ConstantParameter(null)) === produces an unsatisfied dependency error on ArgClass. That's the exact same result as this: === pico.addComponent("myComponent", ComponentClass.class, new ComponentParameter()) === which makes me think that both calls are going down the same auto wiring path. How can I get a null assigned? thanks, Joe --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
RE: assign null in constructor param> My setup is PicoContainer 2.8.3 against JVM 1.5.
> > I'm trying to explicitly assign a null in a constructor param: > > === > public class ComponentClass{ > public ComponentClass(ArgClass arg) > } > } > > pico.addComponent("myComponent", ComponentClass.class, new > ConstantParameter(null)) > === > > produces an unsatisfied dependency error on ArgClass. That's the exact > same result as this: > > === > pico.addComponent("myComponent", ComponentClass.class, new > ComponentParameter()) > === > > which makes me think that both calls are going down the same auto > wiring path. How can I get a null assigned? Joe, I took a look and Pico definitely cannot do it with your code base. (The ConstantParameter has some type checking which returns false if the parameter is null.) I took a stab with a new Parameter class to specifically handle Nulls, but SingleMemberInjector is currently guarded against null parameters.... if I change that particular behavior without the checking with the other developers, I'd be causing problems. Sorry. I've opened issue PICO-364 here: http://jira.codehaus.org/browse/PICO-364 The workaround until we get this fixed is: pico.addComponent("myComponent", new ComponentClass( pico.getComponent('arg1'), pico.getComponent('arg2'), null) ); (That's the beauty of using Scripts and Java for Application composition, you can always do individual objects manually if all else fails.) Thanks for reporting this, and I hope the workaround helps. -Mike --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |