HATEOAS Patch

Devan Goodwin dgoodwin at rm-rf.ca
Wed Aug 18 16:50:28 UTC 2010


On Wed, Aug 18, 2010 at 12:45 PM, Jesus M. Rodriguez <jesusr at redhat.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 08/18/2010 08:57 AM, Devan Goodwin wrote:
>> Attached is a work in progress patch for HATEOAS support.
>>
>
> [snip]
>
>> As far as making it happen it got a little messy. I had to dig way
>> into Jackson internals and the end result was creation of our own
>> SerializerProvider and SerializerFactory sub-classes. These are both
>> configured on the ObjectMapper, and then once in the serializer it
>> assumes the provider configured is our's and casts it. (if you tried
>> to use our custom serializer in an object mapper that didn't use our
>> serializer provider and factory, this would error out fast, but not a
>> problem generally as far as I've seen) Worst of all, there is a 30-odd
>> line method copied in our SerializerFactory that comes straight from
>> it's grandparent class in Jackson.
>
> Did you comment the method to show that it came from its grandparent
> class?
>
>> All of the above is done so we can register customer serializer, and
>> then within that serializer, have a method call available to us which
>> circumvents the custom serializers registered and just moves on to use
>> the default. (thus preventing infinite recursion with our serializer)
>> I tried everything I could come up with to manually create the default
>> object serializer but it's a BeanSerailizer in Jackson and it's
>> creation is non-trivial.
>>
>> So while this code doesn't thrill me, it's isolated and not something
>> that can spread throughout the code base, and the end result JSON
>> appears to be spot on for what we want. If in the future it were to
>> become unmaintainable or break, we could work out another solution, or
>> do custom serializers for all our objects, and just keep the JSON
>> consistent. As such I think it's worth proceeding with this, provided
>> there are no hidden gremlins.
>
> Fair enough.
>
> [snip]
>
> Comments on patch:
>
> * getHref() seems to 'hardcode' paths i.e. "/consumers/", is
>  there any way to get these values from the annotations?

Summary of IRC convo, we're sticking with this for now, zeus is still
noodling on it.

>
> * I like the use of reflection in CandlepinSerializer very nice :D
>
> * can you add a link to the source for jackson's
>  beanserializerFactory in your CandlepinSerializerFactory?

Will do!

>
> * SerializerProvider looks ok except is has an _serializerFactory
>  and _config. Is those jackson variables? If so, we'll need to
>  get checkstyle to ignore this file somehow

Checkstyle wasn't griping, possibly because we don't actually declare
them. (they are from Jackson parent class)

>
> I like it so far, my biggest beef is with the Href() methods
> explicitly listing urls in them vs using some sort of annotations.
>
> jesus

Thanks for checking it over, we'll see if we can come up with
something better for that href.

>
> - --
> jesus m. rodriguez          | jesusr at redhat.com
> principal software engineer | irc: zeus
> red hat systems management  | 919.754.4413 (w)
> rhce # 805008586930012      | 919.623.0080 (c)
> +---------------------------------------------+
> |   "Those who cannot remember the past       |
> |    are condemned to repeat it."             |
> |                        -- George Santayana  |
> +---------------------------------------------+
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkxsAAsACgkQvJZ57YntiYPNiwCdFME/ms/+mbgsN4yK3ROCVo5b
> sLAAoMpu1xSU33+SEh6haYHi1zViFM+A
> =WqkC
> -----END PGP SIGNATURE-----
>



-- 
Devan Goodwin <dgoodwin at rm-rf.ca>
http://rm-rf.ca



More information about the candlepin mailing list