Is there a javax.inject.* equivalent to @Assisted
We're looking at using the JSR-330 javax.inject.* annotations instead of the com.google.inject.* equivalents. It looks like the JSR-330 standard does not include several features that I've come to love in Guice.
Specifically, I see no support for the @Assisted keyword. Also, what about @AssistedInject? Is 开发者_JAVA技巧@Inject able to be placed on multiple constructors?
I'm interested in being vendor neutral, but not at the cost of handy features. Any recommendations?
@Assisted
is Guice-only. You can use it with JSR 330's @Inject
. If you don't want the Guice dependency, do manual assisted injection by implementing the factory interface in code.
In answer to one of your questions:
Is @Inject able to be placed on multiple constructors?
from javadoc
Injectable constructors are annotated with @Inject and accept zero or more dependencies as arguments. @Inject can apply to at most one constructor per class.
So I think the answer is no.
精彩评论