JSR-330 support in Picocontainer : @Inject … @Named("xxx)

天涯浪子 提交于 2020-01-15 06:56:48

问题


We have found code like

private String string = "Not injected.";

@Inject
public void setString(@Named("s") String s) {
    this.string = s;
}

(utilitzing JSR-330 annotations) to be very useful to pass in a string value for "s". We would like to be as flexible as possible regarding which container to use, hence also Picocontainer.

As written, Picocontainer silently ignores the inject. How would I hint to PicoContainer to inject e.g. "String injected!" here?


回答1:


Stable pico 2.x does not have full support for JSR-330 (your particular case), pico 3.x will have. Anyway, @named is not a good way to use picocontainer powers and not a good design for IoC centered app at all. Probably you don't need pico, if you use this stuff.



来源:https://stackoverflow.com/questions/14440363/jsr-330-support-in-picocontainer-inject-namedxxx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!