HATEOAS Patch

Jesus M. Rodriguez jesusr at redhat.com
Wed Aug 18 15:45:15 UTC 2010


-----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?

* 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?

* 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

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

- -- 
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-----



More information about the candlepin mailing list