scubadev
scubadev

Reputation: 1072

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 @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?

Upvotes: 2

Views: 940

Answers (2)

Jesse Wilson
Jesse Wilson

Reputation: 40585

@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.

Upvotes: 4

emory
emory

Reputation: 10891

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.

Upvotes: 0

Related Questions