This could be solved as a part of WELD-2258 (contextual reference of WeldInstance.Handler will be obtained lazily):
class Foo { |
|
Handler<Bar> lazyBar; |
|
@Inject |
Foo(WeldInstance<Bar> instance) |
lazyBar = instance.getHandler(); |
} |
|
void doSomething() { |
if (someCondition) { |
lazyBar.get().ping(); // Bar instance is initialized lazily |
} |
} |
}
|
|