You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Michiel Vermandel <mv...@yahoo.com> on 2013/05/04 12:54:14 UTC

[iPOJO] how to control when instance starts?

Hi,

I create a component instance like this:

ComponentInstance instance = new PrimitiveComponentType()
            .setBundleContext(context)
            .setClassName(BeanFilterImpl.class.getName())
            .setValidateMethod("start")
            .createInstance("com.ce.flowbeans.impl.BeanFilterImpl-1455-8997-5268-2476");

1) It seems that the moment that createInstance is called, the start method is called.
Is this normal? If so, then what is the purpose of instance.start()?

 
2) I have the annotation @Validate on my start method of my component.
Though, when I do not add .setValidateMethod("start") then the component is not started, not even when I call instance.start() ?

3) Is there a way to create an instance and have control over the moment when the instance is started?

Thanks

Michiel 

-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials

Re: [iPOJO] how to control when instance starts?

Posted by Michiel Vermandel <mv...@yahoo.com>.
Hi,

Thank you for your response.
About 3) => So I'll have to get those handlers to work.
I'm having some issues with that for the moment.
I need to try v 1.9.0 of the manipulator. That will be for tomorrow, probably.
I'll keep you all posted.

Thanks,

Michiel

 
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials


________________________________
 From: Guillaume Sauthier (OW2/GMail) <gu...@gmail.com>
To: users@felix.apache.org 
Sent: Saturday, May 4, 2013 11:55 PM
Subject: Re: [iPOJO] how to control when instance starts?
 

1) Yes, when created, instances are auto started.
ComponentInstance.start() is useful because you can start/stop the instance
plenty of times

2) Looks like the annotations are not read with the API, Maybe Clement can
confirm. if that's true, it's a bug.

3) when instance is started, that really means the component instance
management begins, this includes starting all the handlers (start tracking
of dependencies, configuration injection, ...). The real POJO instance
(instance of the class you wrote) will be instantiated only if all handlers
are valid. So POJO instance may not be started/created when component
instance is started.
So if you're referring to the POJO instance, you may control its lifecycle
with something like a @Controller handler, or playing with required
dependencies. If you're referring to the component instance, you have no
real choice ATM since its started automatically after creation. You can
stop the component instance, but it's possible that it succeded to be VALID
on creation.

--G



2013/5/4 Michiel Vermandel <mv...@yahoo.com>

> Hi,
>
> I create a component instance like this:
>
> ComponentInstance instance = new PrimitiveComponentType()
>             .setBundleContext(context)
>             .setClassName(BeanFilterImpl.class.getName())
>             .setValidateMethod("start")
>
> .createInstance("com.ce.flowbeans.impl.BeanFilterImpl-1455-8997-5268-2476");
>
> 1) It seems that the moment that createInstance is called, the start
> method is called.
> Is this normal? If so, then what is the purpose of instance.start()?
>
>
> 2) I have the annotation @Validate on my start method of my component.
> Though, when I do not add .setValidateMethod("start") then the component
> is not started, not even when I call instance.start() ?
>
> 3) Is there a way to create an instance and have control over the moment
> when the instance is started?
>
> Thanks
>
> Michiel
>
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials

Re: [iPOJO] how to control when instance starts?

Posted by "Guillaume Sauthier (OW2/GMail)" <gu...@gmail.com>.
1) Yes, when created, instances are auto started.
ComponentInstance.start() is useful because you can start/stop the instance
plenty of times

2) Looks like the annotations are not read with the API, Maybe Clement can
confirm. if that's true, it's a bug.

3) when instance is started, that really means the component instance
management begins, this includes starting all the handlers (start tracking
of dependencies, configuration injection, ...). The real POJO instance
(instance of the class you wrote) will be instantiated only if all handlers
are valid. So POJO instance may not be started/created when component
instance is started.
So if you're referring to the POJO instance, you may control its lifecycle
with something like a @Controller handler, or playing with required
dependencies. If you're referring to the component instance, you have no
real choice ATM since its started automatically after creation. You can
stop the component instance, but it's possible that it succeded to be VALID
on creation.

--G



2013/5/4 Michiel Vermandel <mv...@yahoo.com>

> Hi,
>
> I create a component instance like this:
>
> ComponentInstance instance = new PrimitiveComponentType()
>             .setBundleContext(context)
>             .setClassName(BeanFilterImpl.class.getName())
>             .setValidateMethod("start")
>
> .createInstance("com.ce.flowbeans.impl.BeanFilterImpl-1455-8997-5268-2476");
>
> 1) It seems that the moment that createInstance is called, the start
> method is called.
> Is this normal? If so, then what is the purpose of instance.start()?
>
>
> 2) I have the annotation @Validate on my start method of my component.
> Though, when I do not add .setValidateMethod("start") then the component
> is not started, not even when I call instance.start() ?
>
> 3) Is there a way to create an instance and have control over the moment
> when the instance is started?
>
> Thanks
>
> Michiel
>
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials