Angry Bill

tech talk radio

Archive for October, 2007

Anybody miss VB?

Posted by billburke on October 31, 2007

Was browsing TSS today and came upon this silly post on Is Ruby the new Visual Basic? Its statements like these by the Ruby community that make me think they get how to do guerilla marketing. Make shocking, controversial statements to make noise. Marc was a master of it. Well, I’ve said it before, if Ruby becomes mainstream, it will be time for me to hang things and change my career or send the wife back to work and become Mr. Mom. Anyways…

Does anybody miss VB? Anybody miss the productivity we had in writing rich, functional, user interfaces in a crazy short amount of time? I sure do. I always despised web apps. Always felt that web apps, and this whole webflow bullshit, were a backward step for the industry and have killed productivity. Its why I’ve stuck to the server side the past 11 years and why I have zero interest in Seam beyond its innovative component model.

One of my most fondest memories was back in 1995 when I worked at Capital One.  Java had just came out and we were developing a prototype, “heavy” applet user interface.  There were no authoring tools back then to create the same rich GUIs I was used to with Visual Basic.  Still, the internet was just coming of age back then, and I was able to find a tool that could generate Java SWT code from Visual Basic, text-saved, screen metadata.  So, I mocked up the screens and application flow through Visual Basic, then ran the Java code generator on the VB files to generate my Java app.  Took Java, what? another 5 years to have even something as close to VB?  Now, the Ajax craze, and still we have crap on the web app side of things…Sad, so sad…

Posted in flame bait | 7 Comments »

Java Developer’s Day: Krakow, Poland

Posted by billburke on October 30, 2007

About two months ago I received an email from Andrej Targosz asking if I would like to present at Java Developer’s Day in Krakow, Poland. Being of Polish decent (yes, Burke is Irish, but my grandmother is a full blooded Pole), I really wanted to go just to see the country. The fact that I would be speaking in front of about 400 Polish Java developers was also a huge plus. Jonas Boner, a long time adversary in the AOP space was slated to give a talk. Me and him always had gotten along really well, and it would be good to seem him. The JBoss guys that run JBoss.org live in Warsaw and decided they’d come down. The lead of JBoss Business Activity Framework, Maciej Machulak another Pole, was also invited to talk about his project. Considering how I have blogged about his stuff recently, it would be really cool to meet him in person. Besides, when JBoss guys get together, it’s always a party no matter where in the world we’re from.

PROIDEA

First, I want to give kudos to PROIDEA, the organizers of the conference. Besides organizing a professional, well-run conference, they went above and beyond the call of duty and made my stay truly special. They picked me up at the airport and even though the conference was held outside of the city , they set me up at a nice apartment right in the city’s center. When Anna Kolodziejczyk, one of the conference’s key organizers, heard that other JBossians from Warsaw were coming, she scheduled and booked their train for them. She even gave up her weekend to show me and the other JBossians around Krakow. Andrej Targosz, the head of PROIDEA, got up at the early hour of 4:00 am to drive me to the airport Monday morning. Finally, I missed my daughter’s birthday to attend the conference. To make up for it they sent me home with a traditional Polish doll and a stuffed animal of the city’s mascot, the Krakow dragon.  I can’t thank Anna and Andrej enough for such a great trip.

Day One

I arrived on Thursday morning. After a nap, Andrej and Anna picked me up for dinner and to meet one of the sponsor’s of the conference, DRQ. Besides talking business, tech, and the general discussion that people from different countries always make, I was introduced to some tasty Polish food: their traditional Polish soup (Help me out guys! I can’t remember the name to save my life), and a sweet, hot, red and spicy wine(come on Poles, give me the name). I ended up ordering those two things any time I went out to dinner the whole trip. The DRQ guys made me feel special by giving me a gift of a painting of Krakow’s city center as well as a copy of my O’Reilly EJB 3.0 book translated into polish. I could not believe my book had been translated. They told me that the Polish publisher donated 40 copies of the Polish version of my book to the conference. Man, my 92 old grandmother is gonna freak when she sees it!

Day Two

The second day was the actual conference. I was first up and gave a talk, of course, about EJB 3.0 and covered both its integration with JPA and how to use EJB 3.0 interceptors. I didn’t get to see the 2nd by DRQ’s, Artur Basiura, because PROIDEA was having some online magazine (I don’t remember their name) do video interviews of each presenter. Jonas Boner gave a nice talk on Terracotta’s product. He always gives a great presentation and it was interesting to see how Terracotta stacked up with JBoss Cache and JBoss POJO Cache. I didn’t get to see Dariusz Zbik, of Software Mind’s presentation as PROIDEA wanted me to sign the 40 copies of my book they were giving away. It would have been difficult anyways as I believe his presentation was entirely in Polish.

In the afternoon I had a one-on-one meeting with some of the developers of DRQ, one of the conference’s sponsor. The meeting lasted a few hours in which DRQ drilled me for information about JBoss, open source, and the general state of Java. You can pretty much gauge the talent of a developer by the quality of questions they throw at you. From that I could tell, DRQ had some pretty good engineers. Being a JBoss user, it was also cool to learn what pieces of JBoss they were using to solve their customer needs.

After meeting with DRQ I rushed to see Maciej’s presentation on JBoss Business Activity Framework. Being lazy, I had only looked at the basic examples of his project and didn’t dive down into the gory details. His presentation filled in the gaps for me. One cool thing I learned was that his framework turns every transactional event into a callback. A bunch of ideas are brewing in my head around this that I hope to blog about later.

Lastly, I was able to see the last presenter of the day, Jacek Laskowski, give a presentation in Polish about Geronimo 2. He was probably the most energetic presenter of the conference. One funny thing he did was that he was wearing 5 different t-shirts. Whenever he changed subject, he changed the t-shirt he was wearing which had the audience roaring in laughter. He had the audience pretty captivated. I will give him one critism though. He talked way too much about us. I counted about 30-35 times he said the word JBoss. Why are Geronimo contributors so obsessed with us? If you’re giving a talk, yeah, maybe you might want to mention who your competitors are, but if you talk about your main competitor continuously throughout the presentation, its just free marketing for them and detracts from your project. Geir Magnusson made the same mistake a few years ago when I saw him give a speech on Geronimo. I was able to shake hands with Jacek after the talk and I thanked him for mentioning us so many times.

After the conference, I hung out with the JBoss guys and their wives and girlfriends in the Jewish sector of Krakow. I experienced what they called Polish fast food (guys name please again!) and had something that looked like pizza on a half loaf of soft bread, but it was much more tastier and satisfying. We had an early night because I was tired from the long day and they had all gotten up at around 4am to take their train to Krakow from Warsaw.

The Weekend

The rest of the weekend was sight-seeing. Since the JBoss guys were staying a few minutes from me, Anna, one of the conference organizers I talked about above, picked me up to meet them at the Wieliczka Salt Mine near Krakow. There was a time miscommunication and the JBoss guys actually got there an hour before we did and did the tour without us. The ironic thing was they ended up going to the English tour and I ended up going to the Polish one. The Wieliczka Salt Mines were really cool. These 900 year old mines had beautiful statues carved right out of the stone and a lot of windy passages that reminded me of the Lord of the Rings. The prettiest part was the Chapel of Saint Kinga which was again, carved right out of the stone. Afterwards, Anna dropped me off with the JBoss guys and they took me out to a another traditional Polish dinner where I ate too much. Afterwards we went to a cool bar in the Jewish sector of Krakow and had kamikaze shots and a bunch of beer. Later we went back to the place they were staying and I was introduced to Polish Vodka. *sarcasm* Thanks guys! *sarcasm*. The night ended with Tomek (a JBossian) and I getting into a heated, Vodka-induced argument which we laughed about heartily the next day.

On Sunday, again Anna took some time out of her weekend to show me and the JBossians around a little. In the late morning she and and one of her friends picked me up and took me to the flea market in Krakow. American antique collectors would have drooled over all the old stuff that was there. After also going to the beautiful, and sad, Jewish cemetery there, we met up with the JBoss guys for lunch which followed with a tour of Krakow’s castle. I truly liked Krakow. It was a beautiful city. I hope to take the wife there someday when our kids our older and we can just dump them off at their grandparents for a week or so.

WOW! Hope this wasn’t too much information. JDD Krakow was a great trip and I was honored that PROIDEA pegged me as a speaker. If I have something interesting to talk about I hope they ask me back next year.

 

Posted in java | 7 Comments »

The rise of meta-annotations

Posted by billburke on October 22, 2007

In reading lately about the new Web Beans specification, I started to realize how much meta-annotations change things. What are meta-annotations? Meta-annotations are simply annotations that annotate other annotations. How could they be used?

Shorthand

Remember a few blogs back when I criticized the @HttpMethod annotation for JSR-311? I said I’d rather have a typesafe annotation represent GET, POST, etc… than a String parameter to @HttpMethod. Marc Hadely, the spec lead, had an idea to allow @HttpMethod to be a meta-annotation stead:

@HttpMethod("GET")
public @interface GET {}

You could apply @HttpMethod to any annotation and it would be triggered by indirection. The idea being, that if HTTP added methods (like WebDav), then they could easily be defined using @HttpMethod as a meta-annotation. They didn’t like my idea of combining @Get with @UriTemplate, but, what if you took meta-annotations even further? …….

Behavior composition

Hmmm, can you annotate an annotation parameter? I tried it out, and you can. Now, what if we also allowed @UriTemplate to be a meta-annotation on a annotation parameter? Then I could have the @GET(”/foo/bar”) REST annotation I always dreamed of:

@HttpMethod("GET")
public @interface GET {
   @UriTemplate String value();
}

The idea would be that @UriTemplate, empty, on an annotations parameter would trigger the extra @UriTemplate behavior when my custom @Get method was applied. So what’s my point here? Maybe this could be used to get rid of annotation creep. Maybe people could use this as a mechanism to define their own idioms and bind their idioms to various competing component models? Just something to think about…

Meta-annotations and AOP

During the EJB 3.0 jsr of EE 5, Gavin wanted to add the ability of allowing @Interceptors to be a meta-annotations. This would allow you to have user-defined annotations that triggered behavior. Take the JBoss Business Activity Framework. The implementation of it could easily be done within EJB 3.0 interceptors. The problem is that to apply BA interceptors in the current EJB 3.0 specification you’d have to bind them with an ugly @Interceptors annotation on the bean class or with XML within ejb-jar.xml. Wouldn’t it be cool if @Interceptors was a meta-annotation? Then you could do something as simple as:

import javax.interceptor.Interceptors;

@Interceptors(org.jboss.ba.BAInterceptor.class)
public @interface BACompensatedBy {
   public String value();
...
}

If the EJB container could resolve @Interceptors as a meta-annotation, then just using and applying the @BACompensatedBy annotation would be enough to trigger the behavior. Gavin, Seam, and Web Beans took this idea further, by defining a @InterceptorBindingType meta-annotation.

@InterceptorBindingType
public @interface BACompensatedBy {
   public String value();
   ...
}

You would then bind an interceptor class by apply the @BACompensatedAnnotation to your actual interceptor class

@BACompensatedBy @Interceptor
public class BAInterceptor {
   @AroundInvoke
   public Object registerCompensation(InvocationContext inv) throws Exception {...}
}

If you think about it, this could have a profound impact on AOP in that pointcut expressions begin to only be used in edge cases. If you’re implementing aspect-oriented annotations, no quirky, unreadable pointcut expressions are needed. Just use the binding annotations. If you’re using pointcuts to define integration points into your application, instead, remove these in favor of simple annotations that you move around as you refactor your application.

Seems to me that meta-annotations have a lot of potential.  Wouldn’t it be cool if all Java EE annotations were allowed to be meta-annotations?  Just another thought.  If you know any other uses, let me know here. Thanks.

Oh, and BTW:

GO SOX!

Posted in aop, java | 2 Comments »

Client driven business activity

Posted by billburke on October 15, 2007

In my previous blog, Distributed Compensation with REST and jBPM, I talked about removing complexity from both the distributed protocol and the server by forcing (or enabling, depending on your perspective) the client to handle things like business activity and compensating transactions. I asked the question, where does this leave WS-BA or more importantly, JBoss’s Business Activity Framework? It could easily still be used in a one process, web application. Many web applications are long running transactions that require compensation. But, I still think JBoss’s Business Activity Framework could be useful to help orchestrate distributed services, even restful ones, if we make compensation metadata available to the client so a local-only business activity coordinator could do its work locally. This would give us the decoupling benefit of BA, but would also allow us to keep our remote services stateless (and restful). The idea would be to move the BA annotations from the bean class, to the business interface:

public interface TravelAgent {
	@BACompensatedBy(value="cancel")
        @BAResult("reservationNumber")
        public int book(int room);

        public void cancel(@BAParam("reservationNumber") int reserverationNumber);
}

A client-side smart proxy could hide the interaction with the local activity coordinator. Another idea would be for the business process engine to introspect service references to see if they are annotated with compensation metadata, and interact with the coordinator themselves. A nice side effect of putting the metadata within the interface is that your service becomes self documenting. The user of this service knows exactly what’s going on by looking at the code.

You could combine this annotation-driven approach with the restful client-side framework I suggested in my comments on JSR-311.

public interface TravelAgent {
	@BACompensatedBy(value="cancel")
        @BAResult("$r.getId()")
        @UriTemplate("/hotel/reservations")
        @HttpMethod("POST")
        @Location("/hotel/reservations/$r.id")
        public Reservation book(@QueryParam("room") int room);

        @UriTemplate("/hotel/reservations/{reservationNumber}")
        @HttpMethod("DELETE")
        public void cancel(@BAParam("reservationNumber")  @UriParam("reservationNumber") int reserverationNumber);
}

This could make it fairly easy and metadata driven to have restful services interact with business activity.

In Java-to-Java calls, for example a remote or local EJB invocation, you wouldn’t necessarily need an interface-driven approach. The JBoss EJB 3.0 implementation, for instance, allows you to define both client-side and server side interceptors. At deployment time, the EJB container could scan the bean class for BA metadata, create a client interceptor initialized with this meta information, and attach the client interceptor to the proxy that is published to clients.

I think client driven conversations where the client holds all state makes for better written distributed services as they can be written in a more stateless, scalable manner. This doesn’t mean that you’d be able to apply this pattern to all scenarios. That’s why I think it might be interesting to make this approach configurable. The client must drive the compensation, the server must be allowed to participate in resource registration, or even a configuration of the client can decide whether it wants drive the coordination or not are all valid scenarios. Anyways, if you experiment with any of these patterns let me know. It would be cool to hear some real, live user experience instead of just guessing on whether or not this would be a good approach.

Posted in REST, Webservices, transactions | 3 Comments »

JSR 311, JAX-RS: Comment and suggestions

Posted by billburke on October 1, 2007

Since I’m so RESTless lately I started thinking about what JBoss could do to help with this effort. We’re involved with JSR-311, which is defining a server-side framework for REST web services, so I decided to contact Heiko Braun, our representative on this specification. I got a copy of the latest draft and dived in. Sometimes the rules of the JCP prevent you from talking about a specification publicly (please correct me if I’m wrong), so I wasn’t sure I could blog about this specification. But, since Brian Leonard has blogged about 311, then I guess I can too.

I don’t want to get into too much detail on 311. Instead please read Brian’s blog and follow the additional links he provides. 311 does seem like it is just standardizing the REST framework Sun has already written. I will though provide example code so that I can reference it later in this blog.

public class Shopping {
   @HttpMethod("GET")
   @UriTemplate("/shopping/orders")
   @ProduceMime("text/xml")
   public String getAllOrders(@QueryParam("expand") boolean expand) {...}

   @HttpMethod("POST")
   @UriTemplate("/shopping/orders")
   @ConsumeMime("text/xml")
   public String buy(Document order) {...}

   @HttpMethod("GET")
   @UriTemplate("/shopping/orders/{id}")
   @ProduceMime("text/xml")
   public String getOrder(@UriParam("id") int orderNum) {...}

   @HttpMethod("DELETE")
   @UriTemplate("/shopping/orders/{id}")
   public void deleteOrder(@UriParam("id") int orderNum) {...}
}

The spec allows you to map http header entries, query parameters, and individual elements within a URI to a method invocation and its parameters and return types. You can also specify what MIME types a method produces and consumes. The spec also provides you with the ability to define factories that can map representations to and from Java objects.

Change suggestions

After reading the specification and browing the Sun REST framework documentation, I have a few suggestions I’d like to make to JSR 311.

Remove magic methods

It seems like @HttpMethod can be placed without a http method identifier on a Java method and the HTTP method type inferred through the Java method name.

@HttpMethod String getOrders()

In this example, HTTP GET would be used because getOrders() begins with the string ‘get’. I never liked the idea of magic method names. They are too fragile and IMO, just bad programming practice. Instead let’s……..

Annotation refactoring of @HttpMethod

Annotation frameworks should be as tiny and concise as possible. Avoid verbosity at all costs. I’d like to see @HttpMethod replace with a more concrete set of http annotations with the additional ability of being able to define a uri template embedded within these applications. So, instead of @javax.ws.rest.HttpMethod (or whatever the package name will be), let’s instead have individual Get, Put, Post, Delete, and Options annotations under the package @javax.ws.rest.httpmethod:

public @interface Get {

   String value() default "";

}

The value() of Get, Post, Delete, etc. would be an optional uri template. So, instead of the verbose:

   @HttpMethod("GET")
   @UriTemplate("/shopping/orders/{id}")
   @ProduceMime("text/xml")
   public String getOrder(@UriParam("id") int orderNum) {...}

We would get:

   @Get("/shopping/orders/{id}")
   @ProduceMime("text/xml")
   public String getOrder(@UriParam("id") int orderNum) {...}

Reduces one line of typing and also, IMO, makes things easier to read.

Allow annotations on an interface instead

RESTful classes should be allowed to declare their REST annotations on the methods of an interface instead of on the class methods. IMO, this is a better way of isolating the published interface of a service. Doing so would also allow the EJB specification to adopt REST and be able to publish remote, local, and restful interfaces to the outside world. Another interesting side affect of this is….

How about a client side framework?

Another interesting side affect of being able to apply REST annotations to an interface is that this interface could be re-used by a client-side framework to generate a proxy that could invoke on REST web services. The client-side programmer could use the same annotations to describe many REST web services that may or may not be using the server-side implementation of 311 or even Java at all! Doesn’t seem like much more effort to define this client-side API.

@Location annotation?

One common pattern I’ve seen in the REST articles and books I have read is that when you have a service method that creates a new object or queries for an existing object, and Location header should be sent back to the client containing the URI the resource is locatable. The 311 spec seems to support this by allowing the user to return a spec-define Response class. What if instead, we provided the ability to map a return value to a Location header?

@Post("/shopping/orders")
@Location("/shopping/orders/{$r}")
public int buy(Document order) {...}

The $r would represent the string representation of the returned value of the buy() method. The client would receive an empty response with a Location header pointing to the new resource created by the buy() method. We could get even funkier in the @Location annotation and allow Unified EL expressions.

@Post("/shopping/orders")
@Location("/shopping/orders/{$r.getId()}")
public Order buy(Document order) {...}

This kind of flexibility could allow one object to be used both RESTfully and locally.

Security?

Another thing I see missing is security hooks. For instance, how about an annotation specifiying whether the resource should be accessed over HTTPS or not? How about an annotation that allows you to plug in an authentication mechanism? IMO, 311 shouldn’t be diving into defining security protocols, but should at least think about providing metadata that allows you to plug in your own implementation. Then again, maybe authentication is best left to being implemented in servlet filters. I don’t know…

XML Descriptor?

There are some bigots out there that despise annotations. An XML descriptor should be created that can define this type of metadata. It should follow the style of other EE components so that we can do things like integrating JAX-RS with EJB.

EJB bridge

The 311 specification does talk about how JAX-RS interacts in a servlet environment. I’d also like to see some work done so that EJBs can become restful as well. This will probably require some work around define lifecycle and creating an annotation like @Restful to ping the container that it needs to perform restful bindings. This would also require work with the EJB 3.1 JSR to expose JAX-RS XML descriptors within EJB 3.1. Red hat would be happy to drive this in the EJB 3.1 expert group.

More to come

I’m seriously thinking about implementing 311 with the changes I’ve suggested here and integrating it with our EJB3 implementation. Hopefully I have the time. Maybe somebody in the community would be interested? I’d be happy to help as long as the individual showed initiative and ability to work on their own. I’ll also talk to Heiko more on what he thinks should be massaged in the specification and blog about them here.

Posted in JAX-RS, REST, Webservices, jboss | 11 Comments »