Re: custom xmlrpc marshallers
- From: Alexander Larsson <alexl redhat com>
- To: Jonathan Blandford <jrb redhat com>
- Cc: "yarrr-list gnome org" <yarrr-list gnome org>
- Subject: Re: custom xmlrpc marshallers
- Date: Fri, 18 Mar 2005 14:01:38 +0100
On Thu, 2005-03-17 at 18:24 -0500, Jonathan Blandford wrote:
> Alexander Larsson <alexl redhat com> writes:
>
> > I added some highly magic code that lets you register marshallers and
> > demarshallers for custom type for the XmlRpcHandler.
> >
> > Check out ActiveTopic for an example of how to use it. With that i can
> > just define xmlrpc handler methods like:
> >
> > public Vector getLiveComment(ActiveTopic topic, int commentId) {
> >
> > The conversion from the topic long id (which is passed as a string due
> > to 64bit ints parameters not being in xmlrpc) to the looked up
> > ActiveTopic is magically handled in the lower layers.
>
> This is really cool!! We used it to add the chat feature today.
>
> One issue we ran into was that it doesn't seem to recursively convert
> types. For example, we returned a class (hashtable) with a Vector as an
> element. That Vector contained classes, which were not auto marshalled.
> We had to call something like:
>
> Vector marshalledMessages = new Vector();
> for (int i = 0; i < messages.size(); i++) {
> Message msg = (Message) messages.get(i);
> marshalledMessages.add(msg.marshalToHash());
> }
>
> by hand to convert it over in our marshal call.
>
>
> Alex, do you think it would be a lot of work to extend it to handle
> this? Is it worth looking into?
Its sort of hard to recursively handle any type of object. What i
imagined was more like creating a special type for your return object,
and then have a marshaller for that type.
So, you'd have:
class MessageList extends Vector implements XmlRpcMarshaller {
...
Object marshal(Object object, XmlRpcHandler handler) {
// do stuff
}
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Alexander Larsson Red Hat, Inc
alexl redhat com alla lysator liu se
He's a suave flyboy grifter with acid for blood. She's a mistrustful blonde
mercenary on her way to prison for a murder she didn't commit. They fight
crime!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]