Hi,
I have a resource that generates a subresource using assisted
injection and a factory (built with FactoryProvider). It works pretty
well, but it has me thinking ... Is there perhaps a better way to
solve the problem?
One of the things the locator resource method does is builds a
DataSource that is specific to that session (based on username and a
lookup using a master database somewhere).
public class MainResource {
@Path("something")
public SubResource getIt(@InjectParam SomethingFactory provider) {
DataSource subDataSource = figureOutDatasource(username);
return provider.create(subDataSource);
}
}
I gather though that there's a way to do this without assisted
injection, whereby I can create up a child injector that says "When
any resources created by this injector say @Inject DataSource ds, you
should inject subDataSource."
Generally speaking, does that seem better or worse than passing them
in via assisted injection?
--Chris