On Mon, Dec 13, 2010 at 17:51, Thomas Mortagne
<thomas.morta...@xwiki.com> wrote:
> On Mon, Dec 13, 2010 at 17:25, Vincent Massol <vinc...@massol.net> wrote:
>>
>> On Dec 13, 2010, at 5:16 PM, tmortagne (SVN) wrote:
>>
>>> Author: tmortagne
>>> Date: 2010-12-13 17:16:56 +0100 (Mon, 13 Dec 2010)
>>> New Revision: 33366
>>>
>>> Modified:
>>>   
>>> platform/core/trunk/xwiki-component/xwiki-component-default/src/main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
>>>   
>>> platform/core/trunk/xwiki-component/xwiki-component-default/src/test/java/org/xwiki/component/embed/EmbeddableComponentManagerTest.java
>>> Log:
>>> XWIKI-5792: ComponentManager#hasComponent does not work if the component 
>>> has not already been lookuped
>>>
>>> Modified: 
>>> platform/core/trunk/xwiki-component/xwiki-component-default/src/main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
>>> ===================================================================
>>> --- 
>>> platform/core/trunk/xwiki-component/xwiki-component-default/src/main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
>>>        2010-12-13 16:03:58 UTC (rev 33365)
>>> +++ 
>>> platform/core/trunk/xwiki-component/xwiki-component-default/src/main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
>>>        2010-12-13 16:16:56 UTC (rev 33366)
>>> @@ -93,7 +93,7 @@
>>>      */
>>>     public <T> boolean hasComponent(Class<T> role, String roleHint)
>>>     {
>>> -        return this.components.containsKey(new RoleHint<T>(role, 
>>> roleHint));
>>> +        return this.descriptors.containsKey(new RoleHint<T>(role, 
>>> roleHint));
>>
>> Isn't this what we used to have and you changed it because you wanted 
>> hasComponent to return true if the component had been instantiated vs the 
>> component had been registered, no?
>
> No I would never do that, I actually remember that I fixed the same
> thing already in other places ;)

(remember now, was for components events)

>
> Looking at the components instances cache does not make any sense.
>
>>
>> Thanks
>> -Vincent
>>
>>>     }
>>>
>>>     /**
>>> @@ -103,7 +103,7 @@
>>>      */
>>>     public <T> boolean hasComponent(Class<T> role)
>>>     {
>>> -        return this.components.containsKey(new RoleHint<T>(role));
>>> +        return this.descriptors.containsKey(new RoleHint<T>(role));
>>>     }
>>>
>>>     /**
>>>
>>> Modified: 
>>> platform/core/trunk/xwiki-component/xwiki-component-default/src/test/java/org/xwiki/component/embed/EmbeddableComponentManagerTest.java
>>> ===================================================================
>>> --- 
>>> platform/core/trunk/xwiki-component/xwiki-component-default/src/test/java/org/xwiki/component/embed/EmbeddableComponentManagerTest.java
>>>    2010-12-13 16:03:58 UTC (rev 33365)
>>> +++ 
>>> platform/core/trunk/xwiki-component/xwiki-component-default/src/test/java/org/xwiki/component/embed/EmbeddableComponentManagerTest.java
>>>    2010-12-13 16:16:56 UTC (rev 33366)
>>> @@ -180,4 +180,18 @@
>>>         parent.registerComponent(cd);
>>>         return parent;
>>>     }
>>> +
>>> +   �...@test
>>> +    public void testHasComponent() throws Exception
>>> +    {
>>> +        EmbeddableComponentManager ecm = new EmbeddableComponentManager();
>>> +
>>> +        DefaultComponentDescriptor<Role> d1 = new 
>>> DefaultComponentDescriptor<Role>();
>>> +        d1.setRole(Role.class);
>>> +        d1.setRoleHint("default");
>>> +        ecm.registerComponent(d1);
>>> +
>>> +        Assert.assertTrue(ecm.hasComponent(Role.class));
>>> +        Assert.assertTrue(ecm.hasComponent(Role.class, "default"));
>>> +    }
>>> }
>>
>> _______________________________________________
>> devs mailing list
>> devs@xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/devs
>>
>
>
>
> --
> Thomas Mortagne
>



-- 
Thomas Mortagne
_______________________________________________
devs mailing list
devs@xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to