Re: Purpose of using java.lang.reflect.Proxy ?
S?bastien de Mapias wrote:
This is a newbie question...
Proxies are not newbie questions (nor anything to do with reflection,
for that matter).
I'm not familiar with this Proxy thing... What purpose does it serve ?
Proxies are one of the more obscure features of reflection. The basic
idea is that the end result is an object which dynamically implements
certain interfaces.
What did the guy who wrote these lines want to achieve ? (he's left,
so
I can't ask him...)
In lieu of context, I can only make assumptions. One possibility is that
the person is wrapping a generic extender around the original object.
Since you mention that the class also appears to extend the interface in
question as well, I can presume that either this was a short-term hack
intended to support something while he was working on making
JdbcStuffServiceImpl implement IService2.
The other possibility that strikes me is that the wrapper is doing some
external operations, such as (judging from Google results) wrapping the
method in a transaction device:
<wrapped method impl>:
try {
beginTransaction();
<call original method>
commitTransaction();
} catch (Throwable t) {
rollbackTransaction();
throw t;
}
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth