You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Loic Petit <lo...@gmail.com> on 2011/01/11 19:00:28 UTC

[iPojo] Validate not called after API component creation

Hi everyone,

I think I discovered a bug with iPojo.
I quickly summarize what I do. I've got a class

@Component
@Provides(strategy = "SERVICE")
class A implements B {
    @Validate
    public void ready() {
           // Initialize Stuff
    }
}

Then, inside my code, I create a new instance via the factory and the API.
(mostly copied from
http://felix.apache.org/site/how-to-use-ipojo-factories.html#How-touseiPOJOfactories-Creatinginstances
)
Unfortunately, when I get the service via OSGi (or @Requires) the object is
well created, the instance is valid, but the method @Validate is not called.

I tried this on the ipojo core versions 1.6.2, 1.6.8 release and on the
trunk snapshot.
Is it me or the core has a bug ? When I do a ipojo:instance on the created
instance in the shell, I see that the handler callback is in the list but I
did not look inside the code to see how it is handled.

Thanks

LP

Re: [iPojo] Validate not called after API component creation

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

On 11.01.11 21:19, "Loic Petit" <lo...@gmail.com> wrote:

>Oh... that's weird :)
>
>I'll check tomorrow what is different in my case... thank you about that !

iPOJO creates the POJO object only when required. In your case, it's when
the service will be used. If you'd like to initialize the object first,
you should not use the SERVICE strategy (one object per requiring bundle)
but keep the default one (Singleton) and add 'immediate=true' to your
@Component.

Regards,

Clement


>
>LP
>
>Le 11 janv. 2011 à 21:05, Richard S. Hall a écrit :
>
>> I created this component:
>> 
>> @Provides(strategy="SERVICE")
>> @Component
>> public class ServiceImpl implements Service
>> {
>>    @Validate
>>    public void ready()
>>    {
>>        System.out.println("Starting");
>>    }
>> 
>>   ...
>> 
>> And deployed it and instantiated an instance:
>> 
>> g! (getService ((getServiceReferences null
>>"(factory.name=main.bundle.ServiceImpl)") 0)) createComponentInstance
>>null
>> Starting
>> 
>> You can see that it prints out the "Starting" message, so it seems to
>>be working for me.
>> 
>> -> richard
>> 
>> 
>> On 1/11/11 13:00, Loic Petit wrote:
>>> Hi everyone,
>>> 
>>> I think I discovered a bug with iPojo.
>>> I quickly summarize what I do. I've got a class
>>> 
>>> @Component
>>> @Provides(strategy = "SERVICE")
>>> class A implements B {
>>>     @Validate
>>>     public void ready() {
>>>            // Initialize Stuff
>>>     }
>>> }
>>> 
>>> Then, inside my code, I create a new instance via the factory and the
>>>API.
>>> (mostly copied from
>>> 
>>>http://felix.apache.org/site/how-to-use-ipojo-factories.html#How-touseiP
>>>OJOfactories-Creatinginstances
>>> )
>>> Unfortunately, when I get the service via OSGi (or @Requires) the
>>>object is
>>> well created, the instance is valid, but the method @Validate is not
>>>called.
>>> 
>>> I tried this on the ipojo core versions 1.6.2, 1.6.8 release and on the
>>> trunk snapshot.
>>> Is it me or the core has a bug ? When I do a ipojo:instance on the
>>>created
>>> instance in the shell, I see that the handler callback is in the list
>>>but I
>>> did not look inside the code to see how it is handled.
>>> 
>>> Thanks
>>> 
>>> LP
>>> 
>> 
>> ---------------------------------------------------------------------
>> 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
>



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


Re: [iPojo] Validate not called after API component creation

Posted by Loic Petit <lo...@gmail.com>.
Oh... that's weird :)

I'll check tomorrow what is different in my case... thank you about that !

LP

Le 11 janv. 2011 à 21:05, Richard S. Hall a écrit :

> I created this component:
> 
> @Provides(strategy="SERVICE")
> @Component
> public class ServiceImpl implements Service
> {
>    @Validate
>    public void ready()
>    {
>        System.out.println("Starting");
>    }
> 
>   ...
> 
> And deployed it and instantiated an instance:
> 
> g! (getService ((getServiceReferences null "(factory.name=main.bundle.ServiceImpl)") 0)) createComponentInstance null
> Starting
> 
> You can see that it prints out the "Starting" message, so it seems to be working for me.
> 
> -> richard
> 
> 
> On 1/11/11 13:00, Loic Petit wrote:
>> Hi everyone,
>> 
>> I think I discovered a bug with iPojo.
>> I quickly summarize what I do. I've got a class
>> 
>> @Component
>> @Provides(strategy = "SERVICE")
>> class A implements B {
>>     @Validate
>>     public void ready() {
>>            // Initialize Stuff
>>     }
>> }
>> 
>> Then, inside my code, I create a new instance via the factory and the API.
>> (mostly copied from
>> http://felix.apache.org/site/how-to-use-ipojo-factories.html#How-touseiPOJOfactories-Creatinginstances
>> )
>> Unfortunately, when I get the service via OSGi (or @Requires) the object is
>> well created, the instance is valid, but the method @Validate is not called.
>> 
>> I tried this on the ipojo core versions 1.6.2, 1.6.8 release and on the
>> trunk snapshot.
>> Is it me or the core has a bug ? When I do a ipojo:instance on the created
>> instance in the shell, I see that the handler callback is in the list but I
>> did not look inside the code to see how it is handled.
>> 
>> Thanks
>> 
>> LP
>> 
> 
> ---------------------------------------------------------------------
> 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: [iPojo] Validate not called after API component creation

Posted by "Richard S. Hall" <he...@ungoverned.org>.
I created this component:

@Provides(strategy="SERVICE")
@Component
public class ServiceImpl implements Service
{
     @Validate
     public void ready()
     {
         System.out.println("Starting");
     }

    ...

And deployed it and instantiated an instance:

g! (getService ((getServiceReferences null 
"(factory.name=main.bundle.ServiceImpl)") 0)) createComponentInstance null
Starting

You can see that it prints out the "Starting" message, so it seems to be 
working for me.

-> richard


On 1/11/11 13:00, Loic Petit wrote:
> Hi everyone,
>
> I think I discovered a bug with iPojo.
> I quickly summarize what I do. I've got a class
>
> @Component
> @Provides(strategy = "SERVICE")
> class A implements B {
>      @Validate
>      public void ready() {
>             // Initialize Stuff
>      }
> }
>
> Then, inside my code, I create a new instance via the factory and the API.
> (mostly copied from
> http://felix.apache.org/site/how-to-use-ipojo-factories.html#How-touseiPOJOfactories-Creatinginstances
> )
> Unfortunately, when I get the service via OSGi (or @Requires) the object is
> well created, the instance is valid, but the method @Validate is not called.
>
> I tried this on the ipojo core versions 1.6.2, 1.6.8 release and on the
> trunk snapshot.
> Is it me or the core has a bug ? When I do a ipojo:instance on the created
> instance in the shell, I see that the handler callback is in the list but I
> did not look inside the code to see how it is handled.
>
> Thanks
>
> LP
>

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