GraniteDS support for Jcrom lazy loading

5 views
Skip to first unread message

Bouiaw

unread,
May 18, 2008, 6:19:57 AM5/18/08
to igenk...@googlegroups.com, gran...@yahoogroups.com, jc...@googlegroups.com
Hi,

On Igenko (http://code.google.com/p/igenko/), we have began to work on
Jcrom lazy loading support for GraniteDS. This functionality is
critical for Igenko, but it is also quite complicated because it touch
really low levels things, and it requires a good knowledge of both
GraniteDS and Jcrom framworks.

The aim of this cross project message is to share with you what I have
understood, to have feedback from both GraniteDS and Jcrom developers.

To quickly summarize usage of each framework in Igenko :

GraniteDS is used to expose our Java POJOs on Flex side. It already
supports Hibernate lazy loading
(http://www.graniteds.org/confluence/display/DOC11/2.4.5.+Lazy+Initialization).
Source code of Hibernate lazy loading support is available here :
http://granite.svn.sourceforge.net/viewvc/granite/graniteds/trunk/hibernate/org/granite/hibernate/

Instead of using a relational datase + Hibernate, we store datas in a
Java Content Repository, witch is like a hierarchical database that
store Nodes and Properties. More details on
http://en.wikipedia.org/wiki/Content_repository_API_for_Java.
Jcrom is a JCR Object Mapper, and it does for JCR what Hibernate did
for JDBC. A quick overview of lazy loading support in Jcrom, based on
Cglib is available here :
http://code.google.com/p/jcrom/source/detail?r=106

I have looked at the files from GraniteDS Hibernate support to
identify all dependencies to Hibernate or EJB3 classes, and I try to
find Cglib equivalent to hibernate classes. I have written bellow my
remarks and questions for each GraniteDS class from Hibernate lazy
loading support.

HibernateClassGetter
Used to retreive to original class name for proxifed objects. It uses
the following Hibernate classes :
- org.hibernate.proxy.LazyInitializer : used to retreive to original
class name for proxifed objects. Perhaps we could use some Jcrom
mapping class that have the same functionnality ?
- org.hibernate.proxy.HibernateProxy : Used to retreive
LazyInitializer. The matching class in cglib seems to be
net.sf.cglib.proxy class ...

HibernateProxyInstanciator
Create a new instance of HibernateProxy

ProxyFactory
Get an existing instance of HibernateFactory. I have not understood
how this class work because it uses a lot of reflection.

HibernateExternalizer
Used to (de)serialize private or protected fields
The isRegularEntity methods should be change to support Jcrom JcrNode
annotation.
Same problem that previously, we should find replacement for
LazyInitializer and HibernateProxy hibernate classes.

HibernatePersistentCollections
There are Java and Flex wrappers for lazy loaded hibernate
collections. I don't think we have wrappers for Jcrom lazy loaded
collections. Do we need some collection wrappers too ?

I have put bellow links to Cglib and Hibernate documentation for
classes that we use.

Hibernate documentation :
LazyInitializer :
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/proxy/LazyInitializer.html
HibernateProxy :
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/proxy/HibernateProxy.html

Cglib documentation :
Proxy : http://cglib.sourceforge.net/apidocs/net/sf/cglib/proxy/Proxy.html
Enhancer : http://cglib.sourceforge.net/apidocs/net/sf/cglib/proxy/Enhancer.html
LazyLoader : http://cglib.sourceforge.net/apidocs/net/sf/cglib/proxy/LazyLoader.html

Any help appreciated.

Regards

Bouiaw

unread,
Jan 1, 2009, 6:45:17 PM1/1/09
to jc...@googlegroups.com
Hi,

I currently try to work again on supporting Jcrom lazy loading for Flex application.
I try to port the Hibernate lazy loading support to Jcrom one.

The main part of the work is that for current Hibernate lazy loading support, HibernateProxy and LazyInitialize classes (http://www.hibernate.org/hib_docs/core/api/org/hibernate/proxy/LazyInitializer.html) are heavily used, and it seems there is no equivalent in Jcrom, so I need your help.

If o is a Java instance of a lazy loaded JcrNode :
- How could I know if o is loaded or not ? In the Hibernate implementation, ((HibernateProxy)o).getHibernateLazyInitializer().isUninitialized() is used.
- How could I retreive the real class of the object is o is not loaded ? In the Hibernate implementation, ((HibernateProxy)o).getHibernateLazyInitializer().getEntityName() is used.
- How could I retreive the real class of the object is o is loaded ? In the Hibernate implementation, ((HibernateProxy)o).getHibernateLazyInitializer().getImplementation().getClass().getName() is used.

Thanks in advance for your help on this functionnality that will be contributed on GraniteDS project, so that will be usable by any Flex project with Jcrom java core.

Bouiaw

unread,
Jan 13, 2009, 6:03:22 AM1/13/09
to jcrom
Hi,

I really need your help on these questions, I hope you will have the
time to answer me.

Regards,
Bouiaw

On 2 jan, 00:45, Bouiaw <bou...@gmail.com> wrote:
> Hi,
>
> I currently try to work again on supporting Jcrom lazy loading for Flex
> application.
> I try to port the Hibernate lazy loading support to Jcrom one.
>
> The main part of the work is that for current Hibernate lazy loading
> support, HibernateProxy and LazyInitialize classes (http://www.hibernate.org/hib_docs/core/api/org/hibernate/proxy/LazyIn...)
> >http://www.graniteds.org/confluence/display/DOC11/2.4.5.+Lazy+Initial...
> > ).
> > Source code of Hibernate lazy loading support is available here :
>
> >http://granite.svn.sourceforge.net/viewvc/granite/graniteds/trunk/hib...
> >http://www.hibernate.org/hib_docs/v3/api/org/hibernate/proxy/LazyInit...
> > HibernateProxy :
>
> >http://www.hibernate.org/hib_docs/v3/api/org/hibernate/proxy/Hibernat...

Ólafur Gauti Guðmundsson

unread,
Jan 13, 2009, 1:46:54 PM1/13/09
to jcrom
Hi Bouiaw,
JCROM uses CGLIB for lazy loading. You can therefore refer to the
CGLIB documentation about how to implement this.
The only JCROM pointer I can give you is to look at the following
methods at the bottom of Mapper.java :

private Object clearCglib( Object obj ) throws IllegalAccessException;
private Object triggerLazyLoading( Object obj ) throws
IllegalAccessException;

Let me know if I there is anything I can do.
Regards,
OGG
Reply all
Reply to author
Forward
0 new messages