JCP is Salvageable

14 Comments

In the wake of Doug Lea leaving the JCP, I just want to say that I think the JCP is salvageable.  This idea the JCP is an unworkable entity is plain and utter myth.  A myth propagated by those that want to see it fail (i.e. SpringSource) or those that want to create their own, and controlled, specification efforts (IBM), or those that are more interested in doing their own thing than collaborating with others (i.e. Google and SpringSource).  Don’t believe me?  Well, let’s discuss it a little more.

First case in point is JPA.  In J2EE 1.4 and earlier we had the crap that was CMP and its unloved and unwanted step-sister JDO.  The Persistence story and message within EE was divided, unclear, and (in CMP’s case) inferior and fundamentally flawed.  This allowed Hibernate to flourish and practically become a de facto standard.  If the JCP was broken and unworkable, we would have never been able to get JPA into the EE 5 specification.  JPA was such an important direction for the EE platform.  Firstly, it brought the innovations of using annotations, but more importantly it unified the platform bringing de facto proprietary implementations like Hibernate and Toplink under the EE umbrella, retiring CMP and bringing the EJB community into the fold, and finally, forcing a shot-gun marriage with the JDO crowd.  The platform needed this, needed this badly to remain relevant.

Second case in point is CDI.  Spring’s rise has always been more about EJB’s incompetence rather than any real technology.  Java EE had three huge holes to fill: injection/IoC, true integration across various specifications, and most importantly an SPI to be able to extend the platform and foster innovation outside the specification process within the Java community.  CDI filled all these holes.  The fact that little Red Hat who is dwarfed in market cap and marketing muscle by the likes of Google, IBM, and Oracle, could push such a game-changing specification through with all the political opposition in place, is a testament that the JCP does work and can work if the participants are willing to focus on technology.

Third, the JCP was already changing pre-Oracle acquisition.  It was already becoming much more open.  Specifications like CDI, JSF, Validation, and JAX-RS all were defined within a completely open process.  Many had open source RIs and TCKs.  Things were improving.

As far as Doug goes, its a big loss.  I know a few of my JBoss colleagues enjoyed working with him.  Personally, I think his departure was premature.   I don’t think the dust has settled yet after the Sun acquisition.  All Java JCP major participants knew that the JCP had to change.  We wanted change.  We still have to give Oracle the benefit of the doubt and, more importantly, time.  Time to get organized.  Acquisitions take time to settle (believe me I know).  From what I’ve seen, Oracle had in the past always been an innovator supporter on the EE specification process.  I don’t see why this couldn’t continue.  They have some good people over there that recognize innovation and want to move the Java EE platform forward.  Whether or not they will have say over the Oracle business people remains to be seen IMO.

HornetQ REST Interface Beta 2 Released

1 Comment

A user requested Selector support. Follow the links and doco from:

http://jboss.org/hornetq/rest

To download, etc…

Is Google Protocol Buffers RESTful?

11 Comments

Recently, a RESTEasy user had a need to transfer a lot of data as efficiently as possible and found Google Protocol Buffers. He came across these blogs questioning the viability of Goggle Protocol Buffers within a RESTful architecture: Ryan’s, Vinoski’s, and Subbu’s. Although I am very late to the discussion, I thought I’d blog about my opinion on the subject to give my RESTEasy user some form of answer.

Who cares if its RESTful or not?

Firstly, who cares if it is RESTful or not?  Does PB fill a need?  If so, don’t worry about the rants of some academic or some architect that hasn’t written a line of code in years (just to be clear, neither Steve, Subbu, or Ryan fall into this academic/non-coding-architect catagory!!!).  REST is described as an architectural style, a set of guidelines, a set of attributes on what the uniqueness of the Web is.  The key words are style and guideline, NOT laws!  Whether you’re borrowing from object-oriented, aspect-oriented, or RESTful principles and guidelines, there’s always going to be tradeoffs you have to make.  It is always much more important to get a working, maintainable, on-time, on-budget system than to satisfy some academic checklist.

Treat Protocol Buffers as a Representation Format

In Steve’s blog, he rants that PB is just a starter drug that puts you on the path to RPC crack-cocaine. Steve says:

In fact, if Google had stopped there [as a definition of a message format], I think Protocol Buffers could be a superb little package.

I agree with this statement.  Treat Protocol Buffers as a representation format only.  Follow REST principles when designing your interface.  Don’t use the RPC junk available in the PB specification.

Not Self-Describing

Ryan makes a good point that PB is not self-describing.  IMO, this is a weak argument.  Unless your clients are going to be rendering agents, self-description is pretty much a pedantic exercise.  Code-based clients generally can’t make many dynamic decisions so self-description information is pretty much useless to Code-based clients.  They have to understand interactions and formats before hand, or they just can’t work.

Subbu, in the comments section of his blog, and Ryan suggest that custom media types are going to have to be defined to satisfy self-description.  Because PB is very brittle (I’ll get into this later) you’ll need to define custom (and versioned) media types to support both older and newer clients.  Something like:

application/customer+x-protobuf

and/or even embed a URL pointing to a .proto file:

application/x-protobuf;format=http:/.../customer.proto

Not Hypermedia Driven?

Ryan’s statement that Protocol Buffers is not hypermedia driven because:

Protocol Buffers do not have a means to describe links to external messages.

This is untrue.  If you’re exchanging PB representations over HTTP, there’s no reason you can’t embed a URL within a PB message body. i.e.

message BookOrder {
...
   repeated Link links = ...;
   message Link {
        required string url = 1;
        optional string type = 2;
   }
}

You have to declare these same kinds of “types” within JSON and XML as well, so I don’t see an issue here.

Stubs means its UnRESTful?

I have to disagree with this point as well.  Stubs are just a means to productively interact with the data format.  You have this issue with XML and strongly typed languages.  Is using XML schema generated JAXB classes in Java any different here?  IMO, no.

Protocol Buffers is a Very Brittle Format

IMO, perhaps the most compelling reason not to use Protocol Buffers is that it is a very very brittle format.  You need to have access to .proto file metadata to parse a PB message body.  Because PB defines a very strict message definition you’re going to have a hard time having older and newer clients co-existing as you add more information to each different message format.  XML and JSON are much more forgiving formats as generally you can ignore extra information.  I’m not sure this is the case with PB.

Edited 10/26:  I was wrong, PB is not so brittle.  Read Bjorg’s comments below.  Apologies for only scanning the PB documentation.  While the stub requirement does make it a little brittle, it does seem you can design your messages to be backward compatible.

As Ryan states in his blog, this brittleness may violate RESTful principles.  IMO though, it should always be a  measure of less RESTful vs. more RESTful, rather than the black and white approach of is RESTful vs. is not RESTful.  This is because, again, there’s always going to be tradeoffs you have to make when implementing your applications.  If you’re following RESTful constraints when applying Protocol Buffers in your implementation, it should be fairly easy to move to less-brittle types like JSON or XML if you no longer find the need to use an ultra-efficient message format like Protocol Buffers.

Conclusion

Protocol Buffers can be used RESTfully if you treat it solely as a representation format.  You can still embed URLs within message definitions to make your representations hypermedia driven.  PB is brittler format than what we’re used to and you may have versioning issues as your interfaces evolve.  Unless PB radically improves the performance of your system, you should probably stick to using formats like XML or JSON as its probably going to be easier to support them across the variety of languages that are now used within the industry.