From: <phr...@im...> - 2002-10-21 22:55:14
|
hi, On Tue, 22 Oct 2002 04:34:54 +1000, "Gavin King" <ga...@ap...> said: > Can we use this to do lazy initialization of objects without the need for > proxy interfaces? wouldn't you have to do this at class loading time then? that is: how would you make your generated look like the original one? with interfaces it's doable at runtime, as long as the client refers to the generated class through the interface... viktor -- phr...@im... -- http://fastmail.fm - Access your email with Outlook or over the web |
From: Ampie B. <amp...@mw...> - 2002-10-22 04:18:00
|
hi, Cglib is brilliant for simply wrapping method calls. As I understand its main feature is generating classes dynamically by merging two classes that were not in any way related at compile time. The generated class looks like a subclass of the original, so you don't need 1000 interfaces as with proxies. If access to the internal state of an object always goes through its accessors, this tool could be ideal for lazy fetching of state just before a getter or setter method call, maybe through fetch groups. I think it is a good idea Gavin. In theory, it should be faster than proxies, but one might just want to test that theory. Ampie -----Original Message----- From: hib...@li... [mailto:hib...@li...]On Behalf Of phr...@im... Sent: 22 October 2002 00:55 To: Gavin King; hib...@li... Subject: Re: [Hibernate] Ohhh this looks cool hi, On Tue, 22 Oct 2002 04:34:54 +1000, "Gavin King" <ga...@ap...> said: > Can we use this to do lazy initialization of objects without the need for > proxy interfaces? wouldn't you have to do this at class loading time then? that is: how would you make your generated look like the original one? with interfaces it's doable at runtime, as long as the client refers to the generated class through the interface... viktor -- phr...@im... -- http://fastmail.fm - Access your email with Outlook or over the web ------------------------------------------------------- This sf.net emial is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ad.doubleclick.net/clk;4699841;7576298;k?http://www.sun.com/javavote _______________________________________________ hibernate-devel mailing list hib...@li... https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Viktor S. <phr...@im...> - 2002-10-22 04:31:57
|
hi, Ampie Barnard wrote: >The generated class looks like a subclass of the original > > heh, but of course :) silly me... >I think it is a good idea Gavin. In theory, it should be faster than >proxies, but one might just want to test that theory. > i think the difference would be marginal, as dynamic proxies also use class generation behind the scenes... v. |
From: Gavin K. <ga...@ap...> - 2002-10-22 04:39:19
|
> i think the difference would be marginal, as dynamic proxies also use > class generation behind the scenes... I have a suspicion it will be slightly slower with CGLIB, actually. |
From: Gavin K. <ga...@ap...> - 2002-10-22 04:37:56
|
I'm currently re-implementing the Proxy feature using CGLIB, as an alternative to JDK proxies. Its turning out really nicely. I have always been so frustrated by the inability to intercept calls to an object if the object doesn't implement an interface. CGLIB seems to solve that problem nicely. > Cglib is brilliant for simply wrapping method calls. As I understand its > main feature is generating classes dynamically by merging two classes that > were not in any way related at compile time. The generated class looks like > a subclass of the original, so you don't need 1000 interfaces as with > proxies. > > If access to the internal state of an object always goes through its > accessors, this tool could be ideal for lazy fetching of state just before a > getter or setter method call, maybe through fetch groups. > > I think it is a good idea Gavin. In theory, it should be faster than > proxies, but one might just want to test that theory. > > Ampie > > -----Original Message----- > From: hib...@li... > [mailto:hib...@li...]On Behalf Of > phr...@im... > Sent: 22 October 2002 00:55 > To: Gavin King; hib...@li... > Subject: Re: [Hibernate] Ohhh this looks cool > > > hi, > > On Tue, 22 Oct 2002 04:34:54 +1000, "Gavin King" <ga...@ap...> > said: > > Can we use this to do lazy initialization of objects without the need for > > proxy interfaces? > > wouldn't you have to do this at class loading time then? that is: how > would you make your generated look like the original one? with interfaces > it's doable at runtime, as long as the client refers to the generated > class through the interface... > > viktor > -- > > phr...@im... > > -- > http://fastmail.fm - Access your email with Outlook or over the web > > > ------------------------------------------------------- > This sf.net emial is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ad.doubleclick.net/clk;4699841;7576298;k?http://www.sun.com/javavote > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > ------------------------------------------------------- > This sf.net emial is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ad.doubleclick.net/clk;4699841;7576298;k?http://www.sun.com/javavote > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Gavin K. <ga...@ap...> - 2002-10-22 04:42:34
|
> Cglib is brilliant for simply wrapping method calls. As I understand its > main feature is generating classes dynamically by merging two classes that > were not in any way related at compile time. The generated class looks like > a subclass of the original, so you don't need 1000 interfaces as with > proxies. And another advantage is that you don't need to break identity equals the way you do with java.lang.reflect.Proxy. (The Proxy is always a different object.) Very, very nice. I wish I knew about this before! |
From: Gavin K. <ga...@ap...> - 2002-10-22 05:19:51
|
Ah. I ran into a limitation. CGLIB is great for our proxies, as long as the persistent classes are not polymorphic. But in the case of a class with subclasses, we don't know the concrete class at proxy-creation time. And theres no way for the proxy to be an instance of both Bar and Baz if Bar and Baz are two possible subclasses of foo. Thats a Java language limitation. So we end up needing the proxy interfaces after all, in that case. Oh well, it still helps for non-polymorphic associations! |
From: Ampie B. <amp...@mw...> - 2002-10-22 08:52:57
|
I did some superficial tests under JDK1.4. With invocation handling that just delegates to the actual implementation, it seems that CG is slower than Proxies initially. But after several thousand invocations CG gets substantially (20+%) faster than Proxies. My theory is that CG somehow benefits more from hot spot compilation. I might be missing something, so if you want to see my tests I'll send it to the list. P.S. sorry for barging in on the list like this. I only realised it is actually the devel list after it was too late. -----Original Message----- From: hib...@li... [mailto:hib...@li...]On Behalf Of Gavin King Sent: 22 October 2002 06:41 To: Viktor Szathmary Cc: hib...@li... Subject: Re: [Hibernate] Ohhh this looks cool > i think the difference would be marginal, as dynamic proxies also use > class generation behind the scenes... I have a suspicion it will be slightly slower with CGLIB, actually. ------------------------------------------------------- This sf.net emial is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ad.doubleclick.net/clk;4699841;7576301;v? http://www.sun.com/javavote _______________________________________________ hibernate-devel mailing list hib...@li... https://lists.sourceforge.net/lists/listinfo/hibernate-devel |