Paul Clapham wrote:Really? I mean, reflection is a fairly standard part of Java so you shouldn't have had to ask that many times. Here's a tutorial about it: https://docs.oracle.com/javase/tutorial/reflect/
Edit: Also, for those of us who never heard of it, could you explain what "weld" is? Obviously Google isn't helpful for that word.
If I inject a field of the same type in two different classes, the same object will get injected if that is specified to be a singleton or application scoped.
Jim Whitaker wrote:@Rob Spoor
In your example, whether I use @Inject, MyManager manager = new MyManager(); or getDeclaredConstructor().newInstance();
will all work the exact same.
Jim Whitaker wrote:But still which injection and scope is the best for a paginator witn many users online? Just using paginator as an example.
Paul Clapham wrote:The question boils down to, is the paginator thread-safe?
Jim Whitaker wrote:If I am paginating say accounts receivable in Dallas TX (just example), and you are paginating accounts payable in Houston TX, and I click page 3, suddenly you will see the data I am paginating?
All because getInstance is a static method? Can you please explain.
Jim Whitaker wrote:I just don't get the problem with static methods, to me they are the best way to return things,
even a Guice example uses static:
But if I don't use static, how then should I return the instance?
Paul Clapham wrote:
I'm still not happy with that code -- it's possible for a thread to call setInstance(X) and then not get X back when calling getInstance() because some other thread called setInstance(Y) in between those two calls, but that's a side issue which isn't related to the "static" issue.
Jim Whitaker wrote:Ever work before @Inject came along? Am I not to use new just @Inject?