JAX-RS Done Right! (X. – Custom Entity Providers)

Hey guys! How’s it going?

Let’s write custom entity providers to process any document formats we like with JAX-RS – without sacrifying SoC!

Today’s episode of “JAX-RS Done Right!” keeps Separation of Concerns while adding support for ANY document type – even your own fancy one! So the application only has PURE domain code when it comes to handling http bodies, while the dealing with the new data type happens in separate classes. The key for this are CUSTOM Entity Providers (i. e. renderers and parsers for a combination of Java class and media type OTHER than plain text, json or xml). This is much easier as you might expect, makes you application very flexible, but still keeps the domain logic PERFECTLY READABLE even when you add MANY data types!

This builds upon an early episode, in which we learned what Entity Providers are in general, and Default Entity Providers for plain text, json and xml in particular.

Code example can be found on Gitlab: https://gitlab.com/mkarg/jaxrs-done-right

Stay safe and… Party on!

About Markus Karg

Java Guru with +30 years of experience in professional software development. I travelled the whole world of IT, starting from Sinclair's great ZX Spectrum 48K, Commodore's 4040, over S/370, PCs since legendary XT, CP/M, VM/ESA, DOS, Windows (remember 3.1?), OS/2 WARP, Linux to Android and iOS... and still coding is my passion, and Java is my favourite drug!
This entry was posted in Jakarta EE, Java, Programming, Standards and tagged , , , , , , , , , , , . Bookmark the permalink.