Removal of Proxy Dependencies

172 views
Skip to first unread message

jnoody

unread,
Apr 1, 2009, 5:24:17 PM4/1/09
to nhusers
This is in reference to the new ability to choose your proxy
implementation, description found here:
http://nhforge.org/blogs/nhibernate/archive/2008/11/09/nh2-1-0-bytecode-providers.aspx

Would someone mind elaborating as to why one would want to change the
underlying proxy implementation? I'm not suggesting that it's not
nice or even necessary. I am simply trying to understand of what
benefit this is?

I've heard that an example can be seen in
NHibernate.ByteCode.Castle.Tests, but I still don't understand after
reviewing the code.

Fabio suggested that one advantage is that those who use Castle with
NH have the benefit of now having a circular reference, which I don't
really understand.

What are some of the major benefits, otherwise?

Thank you.

Fabio Maulo

unread,
Apr 1, 2009, 5:42:53 PM4/1/09
to nhu...@googlegroups.com
2009/4/1 jnoody <jno...@gmail.com>


What are some of the major benefits, otherwise?

To work with lazy-loading NH need, so far, a Dynamic-Proxy system.
Do you have some advise about which one all users should use ?

--
Fabio Maulo

Joshua

unread,
Apr 1, 2009, 5:46:59 PM4/1/09
to nhusers
I have too little understanding on the subject to suggest a specific
dynamic proxy system.

On Apr 1, 3:42 pm, Fabio Maulo <fabioma...@gmail.com> wrote:
> 2009/4/1 jnoody <jno...@gmail.com>
>
>
>
> > What are some of the major benefits, otherwise?
>
> To work with lazy-loading NH need, so far, a Dynamic-Proxy system.Do you

Sidar Ok

unread,
Apr 1, 2009, 6:13:17 PM4/1/09
to nhu...@googlegroups.com
One benefit is, for me from the real life, I use LinFu for all my other AOP, and I don't have to have Castle DP2 anymore.

Linfu also claims to be more performant than DP ( http://www.codeproject.com/KB/cs/LinFuPart1.aspx ) .
--
Sidar Ok

http://www.sidarok.com
http://www.twitter.com/sidarok

Fabio Maulo

unread,
Apr 1, 2009, 6:14:19 PM4/1/09
to nhu...@googlegroups.com
2009/4/1 Joshua <jno...@gmail.com>


I have too little understanding on the subject to suggest a specific
dynamic proxy system.

Well... each one may have different performance, different features, and in general is integrated with an AOP.
We have no reason to chose one specific DynamicProxy... well... there is some "sentimental" reason to chose Castle because Castle was, and is, very important for NH (probably as NH is important for Castle).

--
Fabio Maulo

Joshua

unread,
Apr 1, 2009, 6:18:16 PM4/1/09
to nhusers
But why is not having to have Castle an advantage? Because you don't
have to keep track of where another assembly sits on your computer?
Unless how NH uses your dynamic proxy implementation affects how you
write your other code or how it runs, what does it matter what NH is
using under the hood?

On Apr 1, 4:13 pm, Sidar Ok <sida...@gmail.com> wrote:
> One benefit is, for me from the real life, I use LinFu for all my other AOP,
> and I don't have to have Castle DP2 anymore.
>
> Linfu also claims to be more performant than DP (http://www.codeproject.com/KB/cs/LinFuPart1.aspx) .

Joshua

unread,
Apr 1, 2009, 6:19:44 PM4/1/09
to nhusers
What do you mean by saying that it is integrated with an AOP? Isn't
how NH uses a dynamic proxy under the hood completely independent of
however else you are using AOP in your projects?

Fabio Maulo

unread,
Apr 1, 2009, 6:27:27 PM4/1/09
to nhu...@googlegroups.com
2009/4/1 Joshua <jno...@gmail.com>


But why is not having to have Castle an advantage?  Because you don't
have to keep track of where another assembly sits on your computer?

If you are working with Castle IoC you should know why.
A formal final release of Castle.DynamicProxy2 is available only since few days before NH2.1.0Alpha1 but if you are using Castle you still need download and compile all (because the other Castle prj still using Dynamic proxy trunk).
 
Who are using Castle trunk (many of us) now need to build only the NHibernate.ByteCode.Castle because NH don't have the circular reference.

-- 
Fabio Maulo

Fabio Maulo

unread,
Apr 1, 2009, 6:31:45 PM4/1/09
to nhu...@googlegroups.com
2009/4/1 Joshua <jno...@gmail.com>


What do you mean by saying that it is integrated with an AOP?  Isn't
how NH uses a dynamic proxy under the hood completely independent of
however else you are using AOP in your projects?

Try it by your self configuring some AOP for a class you are persisting with NH, then upload the configuration of AOP before configure NH.

So far the only completely independent is LinFu.
--
Fabio Maulo

Joshua

unread,
Apr 1, 2009, 6:44:23 PM4/1/09
to nhusers
I realize that part of my confusion is that I need more understanding
of and experience with AOP. Perhaps I'll take your advice and just
try some tinkering and come back with more educated questions.

Thanks for all the help, btw. And sorry for my ignorance.

Fabio Maulo

unread,
Apr 1, 2009, 6:45:01 PM4/1/09
to nhu...@googlegroups.com
2009/4/1 Joshua <jno...@gmail.com>


Because you don't
have to keep track of where another assembly sits on your computer?
Unless how NH uses your dynamic proxy implementation affects how you
write your other code or how it runs, what does it matter what NH is
using under the hood?


Joshua,

Sidar prefer LinFu.
In some few cases I'm using LinFu, in the mayor I'm using Castle.
Probably Spring users will use the proxy of Spring.
When we will have the implementation using Unity, probably, all Unity's users will use Unity as dynamic-proxy system.

Which is the problem ? The diversity ? The possibility to use what you want ?

You start saying that you "have too little understanding on the subject to suggest a specific dynamic proxy system"
but now you are questioning who are choosing what he prefer ?

-- 
Fabio Maulo

Joshua

unread,
Apr 1, 2009, 6:53:22 PM4/1/09
to nhusers
I'm sorry if I came off like I was questioning anybody's individual
choice. I'm not. I'm trying to understand the ideas behind the
choice so I can make the right choice. I'll return with further
questions if I have any revelations.

Perhaps nhusers isn't the correct forum for my questions. Could you
please suggest someplace I can go to ask for advice on how to solve a
particular problem I have in the design of a component I'm developing
that revolves around dynamic proxies, please? Thanks.

Fabio Maulo

unread,
Apr 1, 2009, 7:02:58 PM4/1/09
to nhu...@googlegroups.com
You can look for forums of (in alphabetical order):



--
Fabio Maulo

Darius Damalakas

unread,
Apr 2, 2009, 12:52:15 AM4/2/09
to nhu...@googlegroups.com
We have an existing problem with our software:

We use Boo extensively to run custom business rules. Everything
works fine until Boo encounters lazy loaded object. Then if you try to
create a variable in boo, for example myBooVaribleDepartmentLeader =
myCompany.MyLazyLoadedDepartmentLeader;
it fails with exception saying "can not make reference to transient
module .... ".

I do not remember the exact error message. Basically, what i have
understood and investigated, is that it tells that
MyLazyLoadedDepartmentLeader is a type loaded from in-memory assembly.
And that causes problem.

So having an ability to change proxy generation strategy might help us
solve that. There is two possible ways (of which i am aware now):
1. In one or another way force proxy generator to first save assembly
to disk, and then load it to memory.
2. Pre-generate classes and load them from disk at startup time.

Please correct me if in any way i am wrong :)
Darius


2009/4/2 jnoody <jno...@gmail.com>:
--
Darius Damalakas

Fabio Maulo

unread,
Apr 2, 2009, 1:21:54 AM4/2/09
to nhu...@googlegroups.com
2009/4/2 Darius Damalakas <darius.d...@gmail.com>


So having an ability to change proxy generation strategy might help us
solve that. There is two possible ways (of which i am aware now):
1. In one or another way force proxy generator to first save assembly
to disk, and then load it to memory.
2. Pre-generate classes and load them from disk at startup time.


In Hibernate (JAVA) all this stuff are solved in just only one level : The Bytecode injection

In NHibernate we have different levels:
- entirely Bytecode (include all even ReflectionOptimizer)
- ProxyFactoryFactory (for proxy system)

About option 1 and 2 you can use NHPG or share an equivalent solution for others dynamic-proxy


--
Fabio Maulo

Stefan Steinegger

unread,
Apr 2, 2009, 7:52:09 AM4/2/09
to nhusers
We are using Spring, DynamicProxy and Rhino Mocks (using Dynamic
Proxy). I have to admit that I still don't have any clue which proxy
system to choose. There are some problems with DP I could solve by
compiling Rhino. Switching to LinFu might be even easier. But what are
the actual differences of these proxy systems?

Today it's kind of "It doesn't matter, just pick one by random".
Fabio, you're talking about different features. Can I benefit from
them somehow, when using NHibernate? Are there differences in
scalability, performance, limitations, whatever? Of course everyone
can read the documentation of all the proxy implementations and try to
make a comparison himself - just to find out that it really doesn't
matter for his case.

It would be a great topic for a blog, some rules of thumb which proxy
system to choose if you don't have a clue. So if someone has the
knowledge and time to write such an article, it would be very
appreciated.


On 2 Apr., 07:21, Fabio Maulo <fabioma...@gmail.com> wrote:
> 2009/4/2 Darius Damalakas <darius.damala...@gmail.com>

Dario Quintana

unread,
Apr 2, 2009, 8:33:28 AM4/2/09
to nhu...@googlegroups.com
Right now, seems a matter of taste, or how easy/fast we can configurate our NH-app (the first link of this post point to this)
But... looking to this...
http://gustavoringel.blogspot.com/2009/03/unhaddins-sessionwrapper-and.html

Seems like there is something else :-)


On Thu, Apr 2, 2009 at 8:52 AM, Stefan Steinegger <stefa...@bluewin.ch> wrote:

We are using Spring, DynamicProxy and Rhino Mocks (using Dynamic
Proxy). I have to admit that I still don't have any clue which proxy
system to choose. There are some problems with DP I could solve by
compiling Rhino. Switching to LinFu might be even easier. But what are
the actual differences of these proxy systems?

Today it's kind of "It doesn't matter, just pick one by random".
Fabio, you're talking about different features. Can I benefit from
them somehow, when using NHibernate? Are there differences in
scalability, performance, limitations, whatever? Of course everyone
can read the documentation of all the proxy implementations and try to
make a comparison himself - just to find out that it really doesn't
matter for his case.

It would be a great topic for a blog, some rules of thumb which proxy
system to choose if you don't have a clue. So if someone has the
knowledge and time to write such an article, it would be very
appreciated.


--
Dario Quintana
http://darioquintana.com.ar

Fabio Maulo

unread,
Apr 2, 2009, 9:57:27 AM4/2/09
to nhu...@googlegroups.com
Hi Stefan,
You are right, a blog post would be useful.

2009/4/2 Stefan Steinegger <stefa...@bluewin.ch>



--
Fabio Maulo
Reply all
Reply to author
Forward
0 new messages