You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@reef.apache.org by Rogan Carr <ro...@gmail.com> on 2017/10/22 04:54:13 UTC

Question about Injecting Instances

Hi All,

I'm in a funny situation. I am instantiating a REEF-aware class ("Class A")
that is running in a REEF task from a class that's not aware of REEF
("Class B"). Is there any way for "Class B" to get handles to its
dependencies after it's already been instantiated?

Thanks for your help!

Best,
Rogan

Re: Question about Injecting Instances

Posted by Rogan Carr <ro...@gmail.com>.
Hi Markus,

The problem I'm having is that Class A is constructed explicitly by Class
B, but I need to access instances of objects in Task A that have already
been created in the task. I would usually inject these into task A, but I
don't have the option. Could 1) or 2) help me do that?

Best,
Rogan

On Sun, Oct 22, 2017 at 3:02 PM, Markus Weimer <ma...@weimo.de> wrote:

> There are two escape hatches in Tang for these situations:
>
> (1) External constructors. They can be used to instantiate B via Tang even
> as you don't change the class itself. Instead, you implement
> `IExternalConstructor<B>` and bind it as part of the configuration.
>
> (2) `IInjector.BindVolatile`, which allows you to make an instance of B
> available to classes instantiated by that Injector after you made that
> call.
>
> Maybe one of those will help?
>
> Markus
>
> On Sun, Oct 22, 2017 at 12:07 PM, Rogan Carr <ro...@gmail.com> wrote:
>
> > That's right. Class A fulfills an interface that class B instantiates.
> > Class A does all my multi-node work that I need REEF for, and B organizes
> > the general computation. I cannot put REEF/Tang dependencies in Class B,
> so
> > I'm trying to find a way for Class A to get access to the classes that
> have
> > been instantiated in the REEF Context and Task.
> >
> > Thanks for your help!
> >
> > Best,
> > Rogan
> >
> > On Sat, Oct 21, 2017 at 11:32 PM, Julia Wang (QIUHE) <
> > Qiuhe.Wang@microsoft.com.invalid> wrote:
> >
> > > When you say "not aware of REEF", do you mean class B doesn't use Tang?
> > >
> > > -----Original Message-----
> > > From: Rogan Carr [mailto:rogan.carr@gmail.com]
> > > Sent: Saturday, October 21, 2017 9:54 PM
> > > To: dev@reef.apache.org
> > > Subject: Question about Injecting Instances
> > >
> > > Hi All,
> > >
> > > I'm in a funny situation. I am instantiating a REEF-aware class ("Class
> > > A") that is running in a REEF task from a class that's not aware of
> REEF
> > > ("Class B"). Is there any way for "Class B" to get handles to its
> > > dependencies after it's already been instantiated?
> > >
> > > Thanks for your help!
> > >
> > > Best,
> > > Rogan
> > >
> >
>

Re: Question about Injecting Instances

Posted by Markus Weimer <ma...@weimo.de>.
There are two escape hatches in Tang for these situations:

(1) External constructors. They can be used to instantiate B via Tang even
as you don't change the class itself. Instead, you implement
`IExternalConstructor<B>` and bind it as part of the configuration.

(2) `IInjector.BindVolatile`, which allows you to make an instance of B
available to classes instantiated by that Injector after you made that call.

Maybe one of those will help?

Markus

On Sun, Oct 22, 2017 at 12:07 PM, Rogan Carr <ro...@gmail.com> wrote:

> That's right. Class A fulfills an interface that class B instantiates.
> Class A does all my multi-node work that I need REEF for, and B organizes
> the general computation. I cannot put REEF/Tang dependencies in Class B, so
> I'm trying to find a way for Class A to get access to the classes that have
> been instantiated in the REEF Context and Task.
>
> Thanks for your help!
>
> Best,
> Rogan
>
> On Sat, Oct 21, 2017 at 11:32 PM, Julia Wang (QIUHE) <
> Qiuhe.Wang@microsoft.com.invalid> wrote:
>
> > When you say "not aware of REEF", do you mean class B doesn't use Tang?
> >
> > -----Original Message-----
> > From: Rogan Carr [mailto:rogan.carr@gmail.com]
> > Sent: Saturday, October 21, 2017 9:54 PM
> > To: dev@reef.apache.org
> > Subject: Question about Injecting Instances
> >
> > Hi All,
> >
> > I'm in a funny situation. I am instantiating a REEF-aware class ("Class
> > A") that is running in a REEF task from a class that's not aware of REEF
> > ("Class B"). Is there any way for "Class B" to get handles to its
> > dependencies after it's already been instantiated?
> >
> > Thanks for your help!
> >
> > Best,
> > Rogan
> >
>

Re: Question about Injecting Instances

Posted by Rogan Carr <ro...@gmail.com>.
That's right. Class A fulfills an interface that class B instantiates.
Class A does all my multi-node work that I need REEF for, and B organizes
the general computation. I cannot put REEF/Tang dependencies in Class B, so
I'm trying to find a way for Class A to get access to the classes that have
been instantiated in the REEF Context and Task.

Thanks for your help!

Best,
Rogan

On Sat, Oct 21, 2017 at 11:32 PM, Julia Wang (QIUHE) <
Qiuhe.Wang@microsoft.com.invalid> wrote:

> When you say "not aware of REEF", do you mean class B doesn't use Tang?
>
> -----Original Message-----
> From: Rogan Carr [mailto:rogan.carr@gmail.com]
> Sent: Saturday, October 21, 2017 9:54 PM
> To: dev@reef.apache.org
> Subject: Question about Injecting Instances
>
> Hi All,
>
> I'm in a funny situation. I am instantiating a REEF-aware class ("Class
> A") that is running in a REEF task from a class that's not aware of REEF
> ("Class B"). Is there any way for "Class B" to get handles to its
> dependencies after it's already been instantiated?
>
> Thanks for your help!
>
> Best,
> Rogan
>

RE: Question about Injecting Instances

Posted by "Julia Wang (QIUHE)" <Qi...@microsoft.com.INVALID>.
When you say "not aware of REEF", do you mean class B doesn't use Tang? 

-----Original Message-----
From: Rogan Carr [mailto:rogan.carr@gmail.com] 
Sent: Saturday, October 21, 2017 9:54 PM
To: dev@reef.apache.org
Subject: Question about Injecting Instances

Hi All,

I'm in a funny situation. I am instantiating a REEF-aware class ("Class A") that is running in a REEF task from a class that's not aware of REEF ("Class B"). Is there any way for "Class B" to get handles to its dependencies after it's already been instantiated?

Thanks for your help!

Best,
Rogan