Archive for December, 2006

Tag

Thursday, December 21st, 2006

By this time, I’m sure Paul thought I was never going to respond, but here are some things you may or may not know about me:

  1. I have only received W-2s from one company in my life and that was an internship during my sophomore year of college. I put a high value on working for myself.
  2. I play both the piano and drums. I was on a jazz kick for a while, now I’m attempting to get back into classical Piano. Travelling makes this a bit hard to do though as the technical mastery needed demands constant attention.
  3. I didn’t study comp-sci. Chemical Engineering sounded interesting and it was something I didn’t know much about, so I took that. However I got pulled into open source and working for large conglomerates didn’t end up having much appeal to me (see #1).
  4. I’ve been taking kick boxing for the last 3-4 months and loving it. 2 hours, 3 times a week. I feel better and I’m pretty sure I actually get more work done because of it.
  5. The best book I read recently was East of Eden by John Steinbeck.

I think I’m not going to feel obligated to tag anyone else right now because I’m pretty sure everyone else has been tagged. If you haven’t been tagged and want to be, let me know… :-)

Javapolis: XFire talk, Atomikos JTA, Belgian Fries…

Thursday, December 14th, 2006

Am still at Javapolis right now. So far it has been a great conference. I unfortunately encountered a nasty cold so I haven’t been able to have as much fun or get as much work done as I would like, but such is life. I did however get the chance to speak today. Alex Russell of Dojo fame cancelled and Stephan Janssen kindly asked me to fill in. I gave a talk on XFire web services, how to build services, and common web service challenges that developers run into (i.e. security, versioning, testing, etc). They’re putting up a website called Parleys that has all the videos on it, so in the future you’ll be able to watch it online yourself if you weren’t here (although I’ll undoubtedly cringe at seeing me talk).
One of the cool things I learned at Javapolis is that Atomikos just open sourced (ASLv2) their JTA TransactionEssentials product. This means quality JTA for free!

The Javapolis organizers ordered two large trucks to serve out Belgian fries today (although Wikipedia says the Belgian claim to fries is unsubstantiated). Imagine more fries than you’ve ever seen before and double it. They were quite good too. I had ketchup with them, but it had some curry in it, so it was more like BBQ.

To geeks who wear a tucked in shirt and no belt

Wednesday, December 13th, 2006

For goodness sakes, wear a belt.

Javapolis 2006

Sunday, December 10th, 2006

I arrived in Antwerp today for Javapolis this week. I’ve never been to Javapolis and am excited as I hear it is a really great conference.  I’m also excited because there will be a plethora of Belgian beer – the best kind of beer there is.

If you’re here as well, let’s meet up. Email me at dan AT envoisolutions.com or call +1 616-971-2053. (Never tried putting the ol’ phone # on the blog before. We’ll see how this works…)

Resource vs. Service Oriented Data Design

Thursday, December 7th, 2006

While I’ve been touting the benefits of CXF’s RESTful HTTP binding a lot lately, I don’t know that its RESTful enough. One area we haven’t even touched yet is linkability. In my examples I’ve been using a CustomerService which gets/adds/updates/deletes customers. I’ll continue this trend here as well as I look at how I would design my data structures differently for services and resources.

Service Oriented Data Design

While there are many ways to design this, I’m going to chose one that highlights the differences best. Here is what I might design my Order and Customer objects to be:

<element name="Customer">
<complexType>
<sequence>
<element name="Id" type="xsd:int"/>
<element name="Name" type="xsd:string"/>
</sequence>
</complexType>
<element>

The important part to highlight here is the customer id. It allows me to reference/retreive/update/delete a customers in various operations. In RPC terms: getCustomer(”1″) or RemoveCustomer(”3″).

Resource Oriented Data Design

With HTTP we really don’t have any operations per se, but we do have URIs. And most likely we’re going to have a resource for reach customer and order. The question is - do we even need to share an ID any more? I’m not sure I really see any point. This leaves us with:

<element name="Customer">
<complexType>
<sequence>
<element name="Resource" type="xsd:anyURI"/>
<element name="Name" type="xsd:string"/>
</sequence>
</complexType>
<element>

Or a possibly better version would use an xlink:href type (someone should create an xlink schema type - I haven’t seen any around…). Additionally when I access the /customers resource, I don’t think I really want to return collection of all the s. I want to return links to them:

<Customers>
<Customer xlink:href="http://acme.com/customers/1" mce_href="http://acme.com/customers/1" />
<Customer xlink:href="http://acme.com/customers/2" mce_href="http://acme.com/customers/2" />
</Customers>

There are plenty of other differences too, but I think this will do for now.

Supporting Resource Oriented Data Design at a Client/Server Level
Minor difference? I don’t think so. Both SOA and ROA end up having the same functionality. But there are differences in maintainability, versioning and other aspects. At this point though I’m more interested in how implementing linkability would look from a CXF point of view. If you’re going to truly support resource data design it deeply effects the APIs as now we are concerned with both constructing and using URIs.

From the client side of things, I don’t know how many options we have. Abdera did a good job creating a client API that is similar to what I might do:

public interface Client {
ClientResponse get(String uri);
ClientResponse delete(String uri);
ClientResponse put(String uri, Base/InputStream/RequestEntity input);
ClientResponse post(String uri, Base/InputStream/RequestEntity input);
...
}

I personally might change that to include some nice generics, but that is beside the point. One can see how with this type of an API I can easily do CRUD type operations on my customers:

Customers[] customers = client.get(”/customers”);
Customer c = customer[0];
client.delete(c.getResource());

On the server side things get a little more tricky. Now I have to worry about URI creation.

Customer getCustomer(String id) {
String uri = URIContext.createURI("/customers/" + id)
Customer c = createCustomer(id);
c.setResource(uri);
return c;
}

Or we could have a slightly more RESTy version which instead parses the URI:

Customer get(String uri) {
String id = parseId(uri);
Customer c = createCustomer(id);
c.setResource(uri);
return c;
}

As you can see this would be quite different from how I might create a database model. Its not key based, its URI based. This means that from the outset of creating my service, I’m forced to create a mapping between the two concepts. One of the things I like about XFire is that I can quickly prototype a service and have a .NET client running with it in 5 minutes. This is partly because of WSDL but also because I tend to use ID based data models internally and that maps well to an operation/message oriented view of the world.

I’ve been thinking about how to automate linkability so a developer doesn’t have to think too much about it. But I’m not sure that the annotation or convention based route of mapping operations and schemas for services can achieve linkability. We can certainly do simple things with annotations/conventions like the mapping of an operation to a URI/verb combo. Going further probably requires a different way of building up resources though (I’m open to ideas if you have any).

Closing Thoughts

After writing this down, I can see why WSDL/SOAP are pretty popular. The concepts of operations, or distributed objects if you’re cynical, map directly to modes of development that most developers are very familiar with. If you’re going for a true resource oriented architecture, it is a bit of a mental shift (not a bad one, just a shift). And people are reluctant to shift. Hence my obsession with finding ways to do this right which are natural to developers.

Why I bought a Lenovo T60

Tuesday, December 5th, 2006

OK, I’m only going to explain this once for all the people who continually ask me why not a Mac. I ordered a T60 with a Core 2 Duo, 1400×1050 screen, 2 GB ram, etc…

  • Integrated Verizon Wireless card (highspeed wireless everywhere is life changing)
  • 1400 x 1050 screen (14% more real estate than the MacBook Pro at higher DPI)
  • 3 year onsite warranty
  • 9 cell battery that lasts nearly 6 hours
  • 5 lbs - ok just over 5…
  • Has a Core 2 Duo
  • Can power dual monitors or a 30″ LCD
  • Runs Windows well (I’m really not as annoyed by Windows as most people are. I’m much more annoyed by Linux. OS X is better, but not life changing. All the applications are the exact same: Eclipse, Word, Firefox, Trillium vs Adium, etc. I don’t really see why the OS matters that much to everyone. Applications are what matter.)

Cons:

  • No DVI connector built in. Bought a dock though that has a DVI port and takes PCI cards so I can keep my dual monitors. Still thinking about order a 30″ LCD though…
  • Not trendy or cool (never been very good at that anyway)

Where its at - I’ve got two idempotent resources and a microphone

Tuesday, December 5th, 2006

Jim: Is there any better indication that REST is where it’s at? If REST wasn’t important, would they even care… and would we?Are we just in a temporary REST hype phase? Or should SOAP move over now and cede ground to HTTP?

I’m not sure yet. Both will probably survive. However, I am convinced that RESTful systems and projects haven’t received enough attention. I would not be surprised to see a similar scenario with REST/HTTP and SOAP as Spring and J2EE. Vendors go design complex system. Simple system gains popularity. Vendors end up supporting simple system.

I’m not sure how much I care though about the outcome as I’m having too much fun playing with HTTP and RESTful APIs!

(For those of you left wondering about the title, its a cheesy reference to a Beck song)

CXF’s HTTP Binding not RESTy enough for Sanjiva?

Sunday, December 3rd, 2006

The other day Sanjiva made a few comments about the CXF REST support. Glad to see its getting noticed! But I’d also like to add a few corrections:

What Dan is working on for CXF is what Axis2 has: support for the WSDL 2.0 HTTP binding. (That in itself is kinda interesting since he previously claimed that what Axis2 had was “ugly”.)

AFAIK Axis2 does not support the full WSDL 2.0 HTTP binding concepts, which is part of the reason I called it ugly. First, it doesn’t handle PUT and DELETE, it only supports GET and POST operations. Second, and more importantly, it doesn’t support using URI templates. Both those concepts are core parts of the WSDL2 HTTP binding, so I’m not sure how he can state that Axis2 has implemented it.

Further on:

Adding a few annotations to a Java class does not suddenly make that class which was offering a service into a resource: Its just a service with a nice HTTP binding. 

Not true. I would phrase things this way: CXF lets you design your resources however you want. Those resources can the be backed by an operation - just like they might be backed by a file system. We also allow you to map to different verbs for adding, deleting, and updating. The annotations don’t make your service RESTy, but they do enable you to create a REST style architecture with HTTP.

The wonder of conventions: CXF REST services get easier

Sunday, December 3rd, 2006

One of the things I hear often from the Ruby fan boys and girls is the wonders of conventions. A while back I posted a bit on CXF’s new found REST support using annotations. But, given any class which does CRUD operations, there are a lot of similarities, so shouldn’t we be able to employ some conventions as well?. The latest code in CXF’s SVN takes a cue from the Ruby community and knows how to turn CRUD operations into resources automatically.

Its a bit hard to write the rules in narrative form, so I’ll stick to examples. Rest assured though, its documented in the javadoc and soon to be in the user’s guide (no pun intended).

Example 1: Collection<Person> getPeople() is mapped to an HTTP GET on /people

That’s straightforward enough. We see “get”, we map it to a GET operation. Then people is extracted from the operation name and turned into a simple URI.

Example 2: Person getPerson(id) is mapped to an HTTP GET on /people/{id}.

Here we’re again extracting a resource name from the operation, but you’ll notice we’re pluralizing it. When I said taking a cue from Ruby, I meant it literally. I ported Ruby’s ActiveSupport inflection code to Java. It is able to take most English words and pluralize them. Pluralizing “person” to “people” becomes as easy as new EnglishInflector().pluralizer(”person”). You can also add your own singular to plural mappings if it isn’t covered.

All the parameters from the operation get appended to the resource name. If there were two parameters, “bit” and “bob” it would become /people/{bit}/{bob}. CXF will only map bit and bob though if they’re XML schema primitives (int, string, dateTime, etc).

Example 3: void addPerson(Person person) is mapped to an HTTP POST on /people.

We’re recognizing the “add” here as a “POST” operation. “create” is also acceptable. And again some pluralizer magic to map the add to /people.

Example 4: void updatePerson(long id, Person person) is mapped to an HTTP PUT on /people/{id}.

The same rules here as #2 except we’re mapping “update” operations to PUTs.

Example 5: void deletePerson(long id) is mapped to an HTTP DELETE on /people/{id}

The same rules here as #2 and #4 except we’re looking for “delete” and “remove” in the operation and mapping it to an HTTP DELETE.

While this isn’t revolutionary by any means, I think its a nice simple step to make the creation of REST style HTTP services easier. I hope it will enable more in the future.

P.S. if you are looking for a Java pluralizer, be sure to check out the one in CXF’s SVN. This whole thing would’ve taken about 10 minutes if I had it around before.

CXF Feathercast, Release update…

Friday, December 1st, 2006

For all the podcasters out there, the feathercasters recently put up an interview of me at ApacheCon regarding CXF. In it I talk a bit about the history of CXF, the status, and where we’re headed with the project.

Speaking of CXF - we’re working on getting M1 out still. The current hold up us trying to meet the Apache Incubator requirements. Specifically we referred to CXF as “Apache CXF” not “Apache Incubator CXF”, so now we need to cut another release… The joys of incubating.

Update: After a question from someone about the above and what might seem like my dislike of the ASF, I would like to clarify. The Apache Incubator and its rules are there to prevent abuse of foundation. Requiring that the project be referred to as “Apache Incubator Foo” is done so that people can’t just jump on the Apache bandwagon. This is a Good Thing. My gripe above was really targeted at two things. First, personal disappointment that I missed the reference in our release notes and didn’t correct it. Second, that even though we had the best intentions, it is the letter of the law that often counts at the end of the day (for good reason in this case).