reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashvin A <aas....@gmail.com>
Subject Re: Accessing Driver instance using Injector.bindVolatileInstance
Date Mon, 25 Apr 2016 23:02:39 GMT
On Mon, Apr 25, 2016 at 3:50 PM, Markus Weimer <markus@weimo.de> wrote:

> On 4/25/2016 3:29 PM, Ashvin A wrote:
>
>> For e.g. Bind instance of Driver:
>> Tang.Factory.getTang().newInjector().bindVolatileInstance(MyDriver.class,
>> thisDriverInstance) and then access it in Scheduler
>> Tang.Factory.getTang().newInjector().getInstance(MyrDriver.class)
>>
>> The above does not work.
>>
>
> This can't work: Objects created by or added via `boundVolatile()` to an
> injector are local to that injector. They are also a singleton with
> respect to that Injector. There is no `static` state in Tang, so nothing
> is shared between Injectors.


Can I "get" reference to the injector which has the state? Something like
Tang.Factory.getTang.getInjector(some-literal). Although this would be same
as what I have implemented.



> It tries to create a new instance of MyDriver which is not desired.
>>
>
> Yes, because that second injector doesn't know about the first.
>
> 2. Currently I have added a static method in MyDriver to get its
>> instance. Is there a better way to achieve this in REEF.
>>
>
> Can you instantiate the `Scheduler` in the Driver? Then, you can pass a
> reference to `this` to the Scheduler.


No. I cannot instantiate the Scheduler. It is independently instantiated by
a third party class.


>
Thanks,
Ashvin

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message