Friday, May 29, 2009

HATEOAS, REST in the HTTP Analyzer in JDeveloper

I have been working on adding some REST support to JDeveloper back in the labs. In particular I have been focusing on support for HATEOAS in the HTTP Analyzer. I put together a quick viewlet that demonstrates the basic features to get some early feedback.

I cannot say if or when these features will ever see the light of day as per the standard Oracle SOP so please take this into consideration when watching the viewlet.

Update: I noticed that in the demo the create method returns 303, it should proper return "201 Created" to be correct.

Capturing requests sent to localhost and JDK6u14

On of the banes of my recent life has been a bug in the JDK that means http requests to localhost are never proxied no matter how you configure your environment. This is a pain when running against a server local to your machine and you want to capture traffic in say the HTTP Analyzer in JDeveloper

There is a workaround in JDK6u14 where you can use a special "-Dhttp.nonProxyHosts=~localhost" value to ensure request to localhost are proxied. In JDK 7 making the nonProxyHosts value blank will have the same effect but they didn't want to risk the change in 6.

(Note of course u14 might not be support for a given production environment, it does give a nice debugging tool though.

Thursday, May 21, 2009

New project to watch, atmosphere : cometd for the masses

A new project called atmosphere has popped up that aims to make writing and deploying cometd application really easy. You don't need to install any fancy web containers such as grizzly, just drop a war in whatever you are current using. It then appears to make use of facilities as they are available. (for example Servlet 3.0)

The basic examples look interesting; but where the power seems to come with when combined with Jersey. So you can write a service that looks like this:

 @Suspend
 @GET
 @Produces("text/html")
 public String cometGet() {
     return "\n";
 }

 @Broadcast
 @Consumes("application/x-www-form-urlencoded")
 @POST
 @Produces("text/html")
 public String cometPost(MultivaluedMap form) {
     String action = form.getFirst("action");
     String name = form.getFirst("name");

     if ("login".equals(action)) {
         return BEGIN_SCRIPT_TAG + toJsonp("System Message", name + " has joined.") + END_SCRIPT_TAG;
     } else if ("post".equals(action)) {
         return BEGIN_SCRIPT_TAG + toJsonp(name, form.getFirst("message")) + END_SCRIPT_TAG;
     } else {
         throw new WebApplicationException(422);
     }
 }

 @OnBroadcast
 public String cometPush(String s) {
     System.out.println("cometPush: " + s);
     return s;
 } 

Hopefully the full text of this example will be up on the site as promised soon.

There is a BOF-5009 late Tuesday night which I will try to attend jet lag allowing. But this really does appear to make cometd service in Java real easy... now I wonder if it deploys to AppEngine yet...

Tuesday, May 19, 2009

LambdaJ

Really very busy with feature freeze and prep for JavaOne, I did come across this interesting project that makes certain operations much simpler in particular working on lists.

List<Integer> biggerThan3 = filter(greaterThan(3), asList(1, 2, 3, 4, 5));

This is something I miss from when I started playing with python.

Wednesday, May 6, 2009

javax.inject

Just a quick one, here is a proposal from some of the chaps behind Guice and Spring to create a standard for dependency injection annotations in Java. This will only define a standard set of annotations, much the same way the aspect people did, but at least it will make code more portable across implementations.

Tuesday, May 5, 2009

What version of JAX-WS is my weblogic using

Useful to know if you want to download the source for debugging purposes. Take a look at the following path:

%BEA_HOME%/modules/glassfish.jaxws.rt*.jar

For example you might see a file named "glassfish.jaxws.rt_2.1.3.jar". This tells you that we are using 2.1.3 of JAX-WS (src). On my machine using internal builds I get "glassfish.jaxws.rt_1.0.0.0_2-1-4.jar" which tells me that I am using a patched version of the 2.1.4 build of JAX-WS (src). The latter might differ slightly from the published source; but probably not enough to worry about.