java - Not able to understand the Proxy cons -
i reading proxy pattern in this article , understood example, this commentconfused me. comment states:
there 2 big problems proxies, in enterprise environments.
1) you can't self calls. example proxy transaction management or security. need make sure instead of doing self call, forward call proxy. makes simple classes complex.
2) there issues identity; examlpe hibernate proxy makes impossible reference comparison, though guarantee there not multiple object instances of same entity in session.
my questions:
- what meaning of self call?
- why can not reference comparison when both refers proxy object?
"self call" refers calling method on same object, using
othermethod()
instead ofvar.othermethod()
. since call on same object goes straight throughthis
, not proxy, special treatment proxy apply doesn't happen.the runtime environment may fiddle around proxy object, , run risk of accidentally trying compare proxy business object hiding behind it, in case object passes
this
reference out somewhere , trying compare looks runtime (and gets proxy).
Comments
Post a Comment