My question will be quite simple : How to avoid JBoss Weld (1.1.5) to keep references to objects produced by Instance ? Typically, the following code :
class B{}
class A {
@Inject private Instance<B> instanceB;
public B produce(){
return instanceB.get();
}
If I call A#produce(), then the B object won't be garbage-collected before the A object is garbage collected.
Is there any workaround to make it possible for the B object to be garbage-collected, without the A object been garbage-collected ?