Nested call to transformer

5 views
Skip to first unread message

martin.m...@gmail.com

unread,
Jun 9, 2009, 10:42:53 AM6/9/09
to beanlib
Hi,

I have a case where the object graph contains nested objects of a
class I have created a transformer for. Something like:

aFoo.getBar().getFoo();

How do I create a transformer that is able to deal with these nested
levels? Some form of singleton TransformerFactory?

Cheers,
Martin

Hanson Char

unread,
Jun 9, 2009, 12:59:55 PM6/9/09
to bea...@googlegroups.com
Use the internal identity map.

See

  net.sf.beanlib.hibernate3.DateTest.java

under beanlib-hibernate-test in the bundle for example.

martin.m...@gmail.com

unread,
Jun 10, 2009, 1:42:34 PM6/10/09
to beanlib
I may have stated the problem a little wrong. What i have are an
object graph that contains nested instances of Foo (not the same
object). So the question is something like: given that I have custom
transformer for Foo and multiple nested instances of Foo within the
object graph I want to copy, how can I in the custom transformer make
sure that it is called on instances of Foo further down the object
graph?

Cheers,
Martin

On Jun 9, 6:59 pm, Hanson Char <hanson.c...@gmail.com> wrote:
> Use the internal identity map.
>
> See
>
>   net.sf.beanlib.hibernate3.DateTest.java
>
> under beanlib-hibernate-test in the bundle for example.
>
> On Tue, Jun 9, 2009 at 7:42 AM, martin.m...@gmail.com <
>

Hanson Char

unread,
Jun 10, 2009, 5:48:02 PM6/10/09
to bea...@googlegroups.com
If you custom transform Foo, you basically take control over how it's transformed, whether it has nested instances of itself or not.  However, in replicating individual properties of the Foo bean, you can leverage on the built-in/default bean Transformer.  See the internal class

  MyCustomBeanTransformer

in

  net.sf.beanlib.hibernate3.CustomBeanTransformerSpiTest.java

under the beanlib-hibernate-test bundle for a simple example of how to get access of the default transformer.

Hope this helps.
Reply all
Reply to author
Forward
0 new messages