Question

I know that Instance is not part of JSR 330, but is there a Spring equivalent? I'm interested in the fact that Instance implements Iterable, so Provider will not be the correct answer.

public interface Report { ... }

(there are 2 classes implementing Report with @Named annotations)

@Named
public class ReportRunner {
    @Inject private Instance<Report> reports;
}

results in: No qualifying bean of type [javax.enterprise.inject.Instance] found for dependency...

Was it helpful?

Solution

Closing this question out because it has been answered in comments. As @JB Nizet mentioned above, List<Report> works.

For those that wonder what I was doing, it was a generic report runner, wherein each report has its own implementing class, each with a set of DB stored parameters. With this set up, I can leave the report runner running in my app server, drop in jars as necessary, hit re-scan on the sub-context that the ReportRunner maintains (which scans only the Reporting package) and I can modify reports on the fly, without a server restart.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top