You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by fabiolf <fa...@gmail.com> on 2012/06/12 19:15:25 UTC

How to get the ComponentInstance from the instance.name attribute?

Hello!

What is the best way to obtain a ComponentInstance from its instance.name
attribute? Do I have to get all the factories and then, its instances and
then find the one who has the right? instance.name? This seems to have a
high cost. Do anyone has a better and more direct way?

Thanks!
Fabio

--
View this message in context: http://apache-felix.18485.n6.nabble.com/How-to-get-the-ComponentInstance-from-the-instance-name-attribute-tp4997990.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: How to get the ComponentInstance from the instance.name attribute?

Posted by Göktürk Gezer <go...@gmail.com>.
On Wed, Jun 13, 2012 at 4:32 PM, fabiolf <fa...@gmail.com> wrote:

> Hi Göktürk,
>
>
> Göktürk Gezer wrote
> >
> > You can also use filtering on your Archtitecture requirement like
> > "(architecture.instate=your_instance_name)".
> > Then only your intended instance's Architecture reference will be
> injected
> > into your Array, or you can use just single reference.
> >
> > As i understand your situation, something like following may help:
> >
> > @Bind(filter="(architecture.instance=your_instance_name)")
> > public void bind_instance(Architecture arch)
> > {
> >     // Will be called when instance having specified "your_instance_name"
> > is activated with its Architecture reference.
> > }
> >
>
> Thanks for your suggestion, but I don't know previously the instance name I
> will have to look for. So I think the only way is to maintain a copy of all
> instances Architecture references, letting iPOJO simply bind everything in
> that array, and I analyze each one of them to find the one I need, when I
> need to do that. I was hoping I there was some method in a central
> "manager"
> class or something like that, that could give me informations about the
> instance by passing the instance name as a parameter.
>
> But your suggestion gave me an idea for another problem I am having. I
> forgot I could create a callback method for the binding of an specific
> field. That will help a lot! Thanks! :)
>
Yeah, just bind a method to your Architecture[] array then, and analyze it
everytime it changes.

And as this topic is active on
https://issues.apache.org/jira/browse/FELIX-3537 maybe more and more
mechanism those can help you might pop out.

>
> Regards
> Fabio
>
> --
> View this message in context:
> http://apache-felix.18485.n6.nabble.com/How-to-get-the-ComponentInstance-from-the-instance-name-attribute-tp4997990p4998045.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: How to get the ComponentInstance from the instance.name attribute?

Posted by fabiolf <fa...@gmail.com>.
Hi Göktürk,


Göktürk Gezer wrote
> 
> You can also use filtering on your Archtitecture requirement like
> "(architecture.instate=your_instance_name)".
> Then only your intended instance's Architecture reference will be injected
> into your Array, or you can use just single reference.
> 
> As i understand your situation, something like following may help:
> 
> @Bind(filter="(architecture.instance=your_instance_name)")
> public void bind_instance(Architecture arch)
> {
>     // Will be called when instance having specified "your_instance_name"
> is activated with its Architecture reference.
> }
> 

Thanks for your suggestion, but I don't know previously the instance name I
will have to look for. So I think the only way is to maintain a copy of all
instances Architecture references, letting iPOJO simply bind everything in
that array, and I analyze each one of them to find the one I need, when I
need to do that. I was hoping I there was some method in a central "manager"
class or something like that, that could give me informations about the
instance by passing the instance name as a parameter.

But your suggestion gave me an idea for another problem I am having. I
forgot I could create a callback method for the binding of an specific
field. That will help a lot! Thanks! :)

Regards
Fabio

--
View this message in context: http://apache-felix.18485.n6.nabble.com/How-to-get-the-ComponentInstance-from-the-instance-name-attribute-tp4997990p4998045.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: How to get the ComponentInstance from the instance.name attribute?

Posted by Göktürk Gezer <go...@gmail.com>.
Hi,

On Tue, Jun 12, 2012 at 11:22 PM, fabiolf <fa...@gmail.com> wrote:

>
> clement escoffier wrote
> >
> > Hi,
> >
> > It depends what you want to do with the instance.
> >
>
> For now I just want to know its status.
>
>
> clement escoffier wrote
> >
> > If 'reading' metadata is enough, then use the Architecture service and
> the
> > 'architecture.instance' service property.
> >
>
> I think I am doing that (or something like that). I have created a service
> requirement for the Architecture interface (in the array form) and iPOJO
> binds there every instance that has a valid architecture handler. Then I
> iterate over it checking each InstanceDescription to find the desired
> instance. Finally I get the instance state. But I think this process is not
> efficient because I have to iterate through all instances and so on... I
> thought I could call some getInstanceByName() or something like that.
>
You can also use filtering on your Archtitecture requirement like
"(architecture.instate=your_instance_name)".
Then only your intended instance's Architecture reference will be injected
into your Array, or you can use just single reference.

As i understand your situation, something like following may help:

@Bind(filter="(architecture.instance=your_instance_name)")
public void bind_instance(Architecture arch)
{
    // Will be called when instance having specified "your_instance_name"
is activated with its Architecture reference.
}

>
>
> clement escoffier wrote
> >
> > If you really need to access the Component Instance, it's more complex.
> > We're trying to improve this in
> > https://issues.apache.org/jira/browse/FELIX-3537. Feel free to comment
> the
> > issue if you have ideas.
> >
>
> I will have a look and try to help.
>
> Thanks,
> Fabio
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.n6.nabble.com/How-to-get-the-ComponentInstance-from-the-instance-name-attribute-tp4997990p4998005.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: How to get the ComponentInstance from the instance.name attribute?

Posted by fabiolf <fa...@gmail.com>.
clement escoffier wrote
> 
> Hi,
> 
> It depends what you want to do with the instance.
> 

For now I just want to know its status.


clement escoffier wrote
> 
> If 'reading' metadata is enough, then use the Architecture service and the
> 'architecture.instance' service property.
> 

I think I am doing that (or something like that). I have created a service
requirement for the Architecture interface (in the array form) and iPOJO
binds there every instance that has a valid architecture handler. Then I
iterate over it checking each InstanceDescription to find the desired
instance. Finally I get the instance state. But I think this process is not
efficient because I have to iterate through all instances and so on... I
thought I could call some getInstanceByName() or something like that.


clement escoffier wrote
> 
> If you really need to access the Component Instance, it's more complex.
> We're trying to improve this in
> https://issues.apache.org/jira/browse/FELIX-3537. Feel free to comment the
> issue if you have ideas.
> 

I will have a look and try to help.

Thanks,
Fabio



--
View this message in context: http://apache-felix.18485.n6.nabble.com/How-to-get-the-ComponentInstance-from-the-instance-name-attribute-tp4997990p4998005.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: How to get the ComponentInstance from the instance.name attribute?

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

It depends what you want to do with the instance. If 'reading' metadata is enough, then use the Architecture service and the 'architecture.instance' service property. If you really need to access the Component Instance, it's more complex. We're trying to improve this in https://issues.apache.org/jira/browse/FELIX-3537. Feel free to comment the issue if you have ideas.

Regards,

Clement

On 12.06.2012, at 19:15, fabiolf wrote:

> Hello!
> 
> What is the best way to obtain a ComponentInstance from its instance.name
> attribute? Do I have to get all the factories and then, its instances and
> then find the one who has the right? instance.name? This seems to have a
> high cost. Do anyone has a better and more direct way?
> 
> Thanks!
> Fabio
> 
> --
> View this message in context: http://apache-felix.18485.n6.nabble.com/How-to-get-the-ComponentInstance-from-the-instance-name-attribute-tp4997990.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: How to get the ComponentInstance from the instance.name attribute?

Posted by fabiolf <fa...@gmail.com>.
Oh, I'm sorry, I forgot to mention. I'm using iPOJO.

Thanks!
Fabio

--
View this message in context: http://apache-felix.18485.n6.nabble.com/How-to-get-the-ComponentInstance-from-the-instance-name-attribute-tp4997990p4997995.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: How to get the ComponentInstance from the instance.name attribute?

Posted by Felix Meschberger <fm...@adobe.com>.
Are you referring to Declarative Services or iPojo ?

Regards
Felix

Am 12.06.2012 um 13:15 schrieb fabiolf:

> Hello!
> 
> What is the best way to obtain a ComponentInstance from its instance.name
> attribute? Do I have to get all the factories and then, its instances and
> then find the one who has the right? instance.name? This seems to have a
> high cost. Do anyone has a better and more direct way?
> 
> Thanks!
> Fabio
> 
> --
> View this message in context: http://apache-felix.18485.n6.nabble.com/How-to-get-the-ComponentInstance-from-the-instance-name-attribute-tp4997990.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org