You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-dev@incubator.apache.org by Alexandru Popescu <th...@gmail.com> on 2006/02/23 10:28:25 UTC

ManageableCollection

Hi!

I have been trying to figure out the reasons behind the ManageableCollection usage. This interface 
defines the following methods:

addObject()
getIterator()
getSize()

IMO this is already what a java.util.Collection is offering. This means that instead of requiring 
the user code to depend on a graffito API, we should use the Collection.

Also, it looks like there is impossible to handle arrays.

What do you think about this? Am I missing something?

./alex
--
.w( the_mindstorm )p.

Re: ManageableCollection

Posted by Christophe Lombart <ch...@gmail.com>.
On 2/23/06, Alexandru Popescu <th...@gmail.com> wrote:
> #: Christophe Lombart changed the world a bit at a time by saying (astral date: 2/23/2006 12:42 PM) :#

> I cannot seem to find the Map usage. Can you point me to it pls.

ArrayList, Vector, Collection, List are supported by default.
If you want to manage a Map, you have to specify the attribute
"collectionClassName" in the collection descriptor. There is an
example in jcrmapping-testmappings.xml. The collectionClassName
contains the ManagableCollection implementation to use. See an example
in jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap

We can see how to support eg. HashMap, Map, ... by creating a default
implementation for the ManageableCollection interface.

See also ManageableCollectionUtil

In summary with the ManageableCollection, it is possible to support
any kind of collection or any kind of Map. The drawback is to write
severals implementations.



	<class-descriptor
className="org.apache.portals.graffito.jcr.testmodel.hashmap.Main"
jcrNodeType="nt:unstructured">
		<field-descriptor fieldName="path" path="true" />
		<field-descriptor fieldName="text" jcrName="text" />
		<collection-descriptor fieldName="elements" proxy="false"
		                      
elementClassName="org.apache.portals.graffito.jcr.testmodel.hashmap.Element"
		                      
collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl"
		                      
collectionClassName="org.apache.portals.graffito.jcr.testmodel.hashmap.HashMapElement"
/>
		
	</class-descriptor>


--
Best regards,

Christophe

Re: ManageableCollection

Posted by Alexandru Popescu <th...@gmail.com>.
#: Christophe Lombart changed the world a bit at a time by saying (astral date: 2/23/2006 12:42 PM) :#
> On 2/23/06, Alexandru Popescu <th...@gmail.com> wrote:
>> Hi!
>>
>> I have been trying to figure out the reasons behind the ManageableCollection usage. This interface
>> defines the following methods:
>>
>> addObject()
>> getIterator()
>> getSize()
>>
>> IMO this is already what a java.util.Collection is offering. This means that instead of requiring
>> the user code to depend on a graffito API, we should use the Collection.
> Using the ManageableCollection interface gives the possiblity to the
> collection-descriptor to use any kind of Collection or any kind of
> Map.
> By this way, this is the same code to use either a collection or either a map.
> Maybe ManageableCollection is not a correct name.
> 

I cannot seem to find the Map usage. Can you point me to it pls.

./alex
--
.w( the_mindstorm )p.

>>
>> Also, it looks like there is impossible to handle arrays.
>>
> Correct, of course, we can add the Array supports.
> 
> --
> Best regards,
> 
> Christophe
> 



Re: ManageableCollection

Posted by Christophe Lombart <ch...@gmail.com>.
On 2/23/06, Alexandru Popescu <th...@gmail.com> wrote:
> Hi!
>
> I have been trying to figure out the reasons behind the ManageableCollection usage. This interface
> defines the following methods:
>
> addObject()
> getIterator()
> getSize()
>
> IMO this is already what a java.util.Collection is offering. This means that instead of requiring
> the user code to depend on a graffito API, we should use the Collection.
Using the ManageableCollection interface gives the possiblity to the
collection-descriptor to use any kind of Collection or any kind of
Map.
By this way, this is the same code to use either a collection or either a map.
Maybe ManageableCollection is not a correct name.

>
> Also, it looks like there is impossible to handle arrays.
>
Correct, of course, we can add the Array supports.

--
Best regards,

Christophe