On Feb 2, 10:41 am, "jdwy" <jdw
...@gmail.com> wrote:
> I got a chance to look at the code and I do think that this will have
> some nice results. For unit testing in particular.
Good to hear :-)
> Plugging in my little HibernateEscaping stream will be easier with
> this structure. It looks like I'd subclass RemoteServiceServlet and
> override processCall() with one that call my own RPC mechanism right?
Yes, absolutely.
> The only further request I'd have is to make the RPC.java a bit easier
> to extend since it's not so much that I want to replace the current
> RPC imp as to extend it with my Hibernate filter.
Well, actually, the RPC class is probably better thought of as a pile
of static helper methods. So it's not really something you extend --
it's a collection of methods that you can use, or not, as you please.
In your case I'd just write my own encodeHibernateResponse method that
used your special serialization stream, and then override
RemoteServiceServlet.processCall (as you already did) to use
RPC.decodeRequest, invoke your method, and then use
MyRPC.encodeHibernateResponse. Shouldn't be too much code.
We could conceivably add another overloading of encodeResponse,
something like RPC.encodeResult(Method method, Object result,
ServerSerializationStreamWriter writer), but I don't think it would be
all that great a win. There are so many possible hooks once you go
down that road, sometimes it's simpler to just roll your own where
it's needed :-) It's probably still a big win to be reusing the
majority of RemoteServiceServlet, and to get to use the
RPC.decodeRequest method exactly as is. Just be careful with your
exception handling, so you are encoding expected exceptions (which
you'll probably have to serialize with your special writer as well).
> I think that this a a really common result for anyone using ORM
> software. The Hibernate folks are (with reason) absolutely aghast at
> saying un-initialized == null, but sending lazy objects into the
> presentation tier is a tricky thing to solve if you're allergic to
> DTOs. In my personal opinion it's one of the real unsolved problems
> with the current state of the art.
I hear you. I'm going to be in exactly the same situation myself.
But I think that this is a case where it might be a little early to
introduce a standard hook into GWT. In my own project I'll probably
just make the classes I'm using for this freely available through one
of the GWT sandbox projects, so at least the code is out there. Once
the right pattern emerges then there can be a subsequent GWT patch to
adopt it. In fact, would you consider submitting your Hibernate
serializer to one of the GWT-commons projects? I'm sure there'll be
interest, especially once GWT 1.4 ships with the refactored RPC.
Maybe put up your HibernateRemoteServiceServlet class?
Anyway, it won't be a one-liner, but it'll be a lot less than it
was :-)
Cheers!
Rob