Re: [OJB-developers] OJB ManageableCollection ?
Brought to you by:
thma
From: Jakob B. <jbr...@ho...> - 2001-12-18 19:29:44
|
hi thomas, thank you for clarification. i now understand the intention to have = those collections and i'll try to find a way to support lazy collection = there too. (eventually with a new interface ProxyManageableCollection)=20 i think the current implementation of ProxyCollection should not be used = for ManageableCollection. jakob ----- Original Message -----=20 From: Mahler Thomas=20 To: 'Jakob Braeuchi' ; Objectbridge Developers List (E-mail)=20 Sent: Tuesday, December 18, 2001 9:11 AM Subject: AW: [OJB-developers] OJB ManageableCollection ? Hi Jakob, the ManageableCollection interface maybe helpful if you don't want to = (or can't) implement 1:n association with java.util.Collection derived = classes or with arrays. A typical example are user defined typed collections. See sample code = from package test.ojb.broker below. There is a ProductGroup class with a = collection implementor=20 allArticlesInGroup of type ArticleCollection. Class ArticleCollection only allows typed access (as opposed to the = untyped access with java.util.Collection). You can add only InterfaceArticle objects and with get(...) you = retrieve InterfaceArticle objects from the collection. OJB must interact with such user defined collections in a standardized = way. That's the reason for the callback interface ManageableCollection. = It provides elementary access to the user defined collection for the = materialisation process and for update and delete routines (through = ojbIterator()). HTH, Thomas public class ProductGroupWithTypedCollection { // ... /** collection containing all articles of a given product group*/ private ArticleCollection allArticlesInGroup; // ... } public class ArticleCollection implements ManageableCollection { private Vector elements; /** * ArticleCollection constructor comment. */ public ArticleCollection() { super(); elements =3D new Vector(); } public void add(InterfaceArticle article) { if (elements =3D=3D null) elements =3D new Vector(); elements.add(article); } public InterfaceArticle get(int index) { return (InterfaceArticle) elements.get(index); } /** * add method comment. */ public void ojbAdd(java.lang.Object anObject) { elements.add((InterfaceArticle) anObject); } /** * addAll method comment. */ public void ojbAddAll(ojb.broker.ManageableCollection = otherCollection) { elements.addAll(((ArticleCollection) = otherCollection).elements); } /** * ojbIterator method comment. */ public java.util.Iterator ojbIterator() { return elements.iterator(); } public int size() { return elements.size(); } public String toString() { return elements.toString(); } } -----Urspr=FCngliche Nachricht----- Von: Jakob Braeuchi [mailto:jbr...@ho...] Gesendet: Dienstag, 18. Dezember 2001 08:33 An: Objectbridge Developers List (E-mail) Betreff: [OJB-developers] OJB ManageableCollection ? hi, while working on the proxy-collection, i came across the = ManageableCollection. i do not know what they are needed for, the three methods defined in = this interface are also defined (without ojb prefix) in Collection. jakob |