incubator-graffito-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexandru Popescu" <the.mindstorm.mailingl...@gmail.com>
Subject Re: Bug in ObjectConvertImpl#insertBeanFields for custom bean converter
Date Fri, 08 Sep 2006 13:23:33 GMT
I may miss something but: your bean converter just delegates back to
the same default object converter with the initial object value so I
guess it is normal that when reaching again the

<bean-descriptor fieldName="author" jcrName="author" proxy="true"
converter="org.eclipse.emf.teneo.graffito.emf.TestBeanConverterImpl" />

than it will invoke yours again and so on. I would say that your code
is creating the infinite recursion. Probably you would like to invoke
the default converter with a property retreived from the object and
not once again with the full object.

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


On 9/8/06, Dan Connelly <dsconnelly@adelphia.net> wrote:
> Alexandru Popescu wrote:
>
> >
> > Dan can you show us your code pls? It would be much easier to
> > understand the issue.
> >
> > TIA,
> >
> > ./alex
>
> Alex:
>
> I believe that my code is irrelevant to this bug, but correct me if I am
> wrong.
>
> My TestBeanConverterImp source is attached.   Only the insert method is
> being used for this test.
>
> The significant metadata is here:
>
>     <class-descriptor
>         className="org.eclipse.example.library.impl.BookImpl"
>             extend="org.eclipse.emf.ecore.EObject"
>         jcrNodeType="graffito:eobject">
>         <implement-descriptor
> interfaceName="org.eclipse.example.library.Book"/>
>         <field-descriptor fieldName="title"  jcrName="title" path="true"
> id="true" />
>         <field-descriptor fieldName="pages"  jcrName="pages" />
>         <bean-descriptor fieldName="author" jcrName="author" proxy="true"
>
> converter="org.eclipse.emf.teneo.graffito.emf.TestBeanConverterImpl" />
>         <bean-descriptor fieldName="category"  jcrName="category"
> inline="true"
>         />
>     </class-descriptor>
>
>   <nodeType name="graffito:eobject" isMixin="false">
>     <supertypes>
>       <supertype>mix:referenceable</supertype>
>       <supertype>nt:unstructured</supertype>
>     </supertypes>
>   </nodeType>
>
>
> A fragment of the console output is as follows:
>
> Object Class = org.eclipse.example.library.impl.BookImpl object =
> org.eclipse.example.library.impl.BookImpl@159576c3 (title: The Hobbit,
> pages: 305, category: ScienceFiction)
> Parent Node name = author
> Parent Node path = /Library1/Books/The
> Hobbit/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author/author
> Interface name: org.eclipse.example.library.Book
>
>        -- Dan
>
>
> package org.eclipse.emf.teneo.graffito.emf;
>
> import javax.jcr.Node;
> import javax.jcr.Session;
> import javax.jcr.UnsupportedRepositoryOperationException;
>
> import org.apache.portals.graffito.jcr.exception.JcrMappingException;
> import org.apache.portals.graffito.jcr.exception.PersistenceException;
> import org.apache.portals.graffito.jcr.exception.RepositoryException;
> import org.apache.portals.graffito.jcr.mapper.model.BeanDescriptor;
> import org.apache.portals.graffito.jcr.persistence.objectconverter.BeanConverter;
> import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
> import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.AbstractBeanConverterImpl;
> import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ParentBeanConverterImpl;
> import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.Reference;
> import org.eclipse.emf.ecore.EObject;
>
> public class TestBeanConverterImpl extends AbstractBeanConverterImpl implements BeanConverter
{
>
>         private ObjectConverter objectConverter;
>
>         public TestBeanConverterImpl(ObjectConverter objectConverter)
>         {
>                 super(objectConverter);
>                 this.objectConverter = objectConverter;
>         }
>
>         @Override
>         public Object getObject(Session session, Node parentNode,
>                         BeanDescriptor descriptor, Class beanClass)
>                         throws PersistenceException, RepositoryException,
>                         JcrMappingException {
>                 // TODO Auto-generated method stub
>                 return null;
>         }
>
>         @Override
>         public void insert(Session session, Node parentNode,
>                         BeanDescriptor descriptor, Object object)
>                         throws PersistenceException, RepositoryException,
>                         JcrMappingException {
>
>                 Class objectClass = object.getClass();
>                 System.out.println("Object Class = "+objectClass.getName() +" object
= "+object.toString());
>                 try {
>                         System.out.println("Parent Node name = "+parentNode.getName());
>                         System.out.println("Parent Node path = "+parentNode.getPath());
>                 } catch (javax.jcr.RepositoryException e2) {
>                         // TODO Auto-generated catch block
>                         e2.printStackTrace();
>                 }
>                 objectConverter.insert(session, parentNode, descriptor.getJcrName(),
object);
>
>         }
>
>         @Override
>         public void remove(Session session, Node parentNode,
>                         BeanDescriptor descriptor) throws PersistenceException,
>                         RepositoryException, JcrMappingException {
>                 // TODO Auto-generated method stub
>
>         }
>
>         @Override
>         public void update(Session session, Node parentNode,
>                         BeanDescriptor descriptor, Object object)
>                         throws PersistenceException, RepositoryException,
>                         JcrMappingException {
>                 // TODO Auto-generated method stub
>                 objectConverter.update(session, parentNode, descriptor.getJcrName(),
object);
>         }
>
> }
>
>
>

Mime
View raw message