iPojo - How can I force the factory to create an instance

View: New views
4 Messages — Rating Filter:   Alert me  

iPojo - How can I force the factory to create an instance

by Vrignaud Etienne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am in trouble to figure out how I can force the factories of iPojo to create an instance of a component.

In my case, I have a "manager" class that have an optional @Requires on an Array of plugins.
My problem is that if nobody use my "manager", no instance of this manager is created.
And in my case, it's the fact nobody use it because it's a "manager".

I found a simple workaround. When my manager implements also the Felix Command interface, then the instance is created.
Could you help me to figure out what can be done to "force" the instantiation without the workaround.

I also tried with arch to dig into that problem and try to get a list of pending instantiations.
But I fail to find this. Don't you thing that this kind of feature could be helpful?

Regards,
/Etienne

Re: iPojo - How can I force the factory to create an instance

by clement escoffier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 24.06.2009, at 12:14, Vrignaud Etienne wrote:

>
> Hi,
>
> I am in trouble to figure out how I can force the factories of iPojo  
> to
> create an instance of a component.
>
> In my case, I have a "manager" class that have an optional @Requires  
> on an
> Array of plugins.
> My problem is that if nobody use my "manager", no instance of this  
> manager
> is created.
> And in my case, it's the fact nobody use it because it's a "manager".
>
> I found a simple workaround. When my manager implements also the Felix
> Command interface, then the instance is created.
> Could you help me to figure out what can be done to "force" the
> instantiation without the workaround.

You can just set immediate="true" in your component type declaration:
@Component(immediate="true")

this will creates a POJO object as soon as your instance is valid (as  
you have an optional service requirement, it will be immediately).
(components that do not provide any service are immediate by default)


>
> I also tried with arch to dig into that problem and try to get a  
> list of
> pending instantiations.
> But I fail to find this. Don't you thing that this kind of feature  
> could be
> helpful?

Your iPOJO instance should be listed with arch -instances. However  
arch -instance your_instance_name says :
- I'm valid
- I have no created any POJO object

Regards,

Clement


>
> Regards,
> /Etienne
>
> --
> View this message in context: http://www.nabble.com/iPojo---How-can-I-force-the-factory-to-create-an-instance-tp24182075p24182075.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>


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


Re: iPojo - How can I force the factory to create an instance

by Vrignaud Etienne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok, thanks. for the immediate.
It works.

I have understood my trouble.
The <instance> tags doesn't say anything when the component name provided is wrong.
Do you think that its normal?

For example:
           <instance component="whatever"/>
never complains

Thanks,
/Etienne

Re: iPojo - How can I force the factory to create an instance

by clement escoffier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 24.06.2009, at 12:39, Vrignaud Etienne wrote:

>
> Ok, thanks. for the immediate.
> It works.
>
> I have understood my trouble.
> The <instance> tags doesn't say anything when the component name  
> provided is
> wrong.
> Do you think that its normal?
>
> For example:
>           <instance component="whatever"/>
> never complains

Yep,

iPOJO just wait for the "whatever" factory that can arrive and leave  
at anytime...
However, I'm not against logging a warning message in this case, that  
might help a little bit.

Regards,

Clement

>
> Thanks,
> /Etienne
> --
> View this message in context: http://www.nabble.com/iPojo---How-can-I-force-the-factory-to-create-an-instance-tp24182075p24182424.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>


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