2009-05-09

Sun's JVM has an HTTP server embedded: com.sun.net.httpserver

Very useful ! Sun's Java Standard Edition has a simple HTTP Server: com.sun.net.httpserver.

It simplifies dependencies since you don't have to add a new library. It is straightforward to use it with Jersey to publish Restful Services. But it isn't a standard feature !

Eclipse users might see compile errors saying Access restriction: The type ... is not accessible due to restriction on required library ...
The problem is that the HTTP server is part of the Sun JRE6 but not part of standardized Java.
Eclipse therefore blocks access to it.
This can be fixed by going to the Window->Preferences window, selecting Java->Compiler->Errors/Warnings, selecting Deprecated and Restricted API and then changing the setting for Forbidden Reference and Discouraged Reference to Warning instead of Error.

Jersey client, Jax-rs, Jaxb, RESTFUL client in Java

RESTFUL web-services, in Java, concern mostly server side developments. The client is generally the browser.
Now I am in the process of developing a Java client for web-service. I searched Java solutions in this space and found that Jersey was also a good client. I already known Jersey, for being the reference implementation for Jax-rs (Restful Services ?) and even saw Paul Sandoz himself in Grenoble. But I never imagined that there could be another consumer than the browser.
Well obviously, they needed to test Jersey, hence ad-hoc code, then a framework and a finally a jersey-client for everyone's pleasure.
The funny parts is that I am using jersey-server to test jersey-client: the other way around ... That is not pure Unit Test, in the sense that I prefer functional or integration test than testing every tiny development chunk and mocking everything around.
Point is that implementing Restful Services in java with Jersey and Jasxb is really easy. overall, I stumbled on a problem with Jaxb and the way it doesn't handle immutable objects, but I will make another post about this.

2023 summary

  Life is bigger than what you can imagine.  Still using Roam  http://www.roamresearch.com/  to take notes Still using Mastodon mainly, but ...