Hi,

Yes, factory lifecycle and instance lifecycle are different. This is because 
they react to different events.

Factories are valid when they can create the instance (container), meaning that 
all the ‘handler factories’ are there.
Instances are valid when all handlers composing its container are valid. This 
generally means all the required services are available, but it’s not limited 
to this.

So, when you create an instance from a factory, the instance is started, but 
may not be in a valid state. It will switch to the valid state only if the 
previous condition is met. You can retrieve the state of the instance from the 
Instance object, as well a register a listener. BTW, this let you create 
instances that will be bound together without having to handle the creation 
order.

A factory can’t know in advance if the instance is going to be valid. This is 
because it depends on numerous factor. For example, the instance configuration 
can customize service dependencies filters, or the code can use a @Controller 
field to decide its state, or a provider may disappear during the creation…

However, factory states impact instance states in a drastic way…. If the 
factory becomes invalid - all instances, created from this factory, are 
destroyed whatever their state. This is because iPOJO cannot guaranty the 
integrity of their container anymore.

Cheers,

Clement
On 11 décembre 2014 at 22:43:48, [email protected] 
([email protected]) wrote:

Hello,  

I realised today I made a wrong assumption with iPojo. I thought that if I  
used a factory to create an instance, that I could be 100% sure that the  
instance was going to be valid because (I thought) that if the instance  
was missing dependencies, the factory itself would be invalid. That is not  
the case, however. So I am wondering, why is this the case? Now i will  
have to check after any instance creation if the instance is valid but I'm  
not sure why.  

What is the use case where you would want a factory to allow you to create  
invalid instances? why isn't the state of the factory tied to the state of  
the instances it creates so that if a factory is not capable of creating  
valid instances, it itself is invalid?  

Thank you for any insights  


Alejandro Endo | Software Designer/Concepteur de logiciels  
Grass Valley, A Belden Brand | Tel: (514) 333-1772 Ext: 3789  
3499 Douglas-B.-Floreani, St-Laurent, Quebec Canada H4S 2C6  

DISCLAIMER:  
Privileged and/or Confidential information may be contained in this  
message. If you are not the addressee of this message, you may not  
copy, use or deliver this message to anyone. In such event, you  
should destroy the message and kindly notify the sender by reply  
e-mail. It is understood that opinions or conclusions that do not  
relate to the official business of the company are neither given  
nor endorsed by the company.  
Thank You.  

Reply via email to