JSR-330 support in Picocontainer : @Inject … @Name

2019-07-21 03:08发布

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条回答
Root(大扎)
2楼-- · 2019-07-21 03:22

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.

查看更多
登录 后发表回答