Do we need complex restful content negotiation?

3 Comments

A couple of weeks ago I finally got down to implementing the JSR-311 Restful web services specification I talked about in a previous blog.  In reading the JSR mail list and looking into HTTP content negotiation, a few questions popped up in regards to the programmatic web.

  • Why would a client ever send more than one Accept header?
  • Why would a client or server ever produce or consume wildcard content types?  i.e. “text/*” or even “*/*”?

I know in theory that the idea is that an application can dynamically search for resources, on the web and just invoke on them.  But when does any real application not have complete determinism?  When you’re writing a distributed application, you research the services you are going to interact with.  What exact data formats do they product?  What exact formats do they consume?  Otherwise its nearly impossible to implement your application.  Coding isn’t guess work.  You’re not going to invoke a service and hope it gives you back something you understand and vice-versa.  So please, somebody, give me real live use cases for this type of complex content negotiation.

Radiohead and Open Source

2 Comments

Let me preface by saying I’m an old man. I have never ripped and burned music CDs. I don’t have any music on my iPod (only TV shows and movies). And if you’ve read Why Angry Bill? you know that I don’t listen to music on the radio. So, if this blog is old news to you, then apologies.

Was on Google news today and saw discussion on the band Radiohead’s attempt to give away a free album with fans deciding how much they wanted to pay (if at all). The article said that only 38% of downloaders decided to pay anything and marked it as a failure. I was scratching my head at this. A failure? A disappointment? Are you bleepin crazy? I don’t know what the ratio is now, I’m out of the loop on such discussions, but pre-acquistion, I know JBoss’s percentage of paying users was something like 5%, and they got 38%? IMO, that’s a huge success! If JBoss had had that ratio of paying users we would have gone public in 2004 instead of getting bought-out in 2006. The article then went on to say that the band must average $1.50 per download to break even (they’re currently averaging $6.50 per download, pretty good margin!).

Most of the articles on the subject questioned whether the Radiohead model would work with smaller bands since Radiohead already had a strong brand and a fanbase of millions. I think the business model could parallel the evolution of an open source business model. Really, all it is is establishing a trademark and cross-selling your ‘free’ offering to what value-add you are selling.

In the beginning of an open source business, your main value-add is usually consulting and training. This is business that brings in easy revenue, but that you can’t scale effectively because of the amount of people that is required to drive this. For the music world, maybe a band could cross-sell on-site gigs. Yeah, maybe this is unrealistic to expect a fan to want to book a particular band, so something more creative is needed. Maybe the music download would require the fan to solely enter in their age and zipcode. Then the band could know where they are popular. For instance, if they were very popular in the Greater Boston area, they could call up nightclubs in the area and say “Hey, 100 people downloaded our album in Boston. There’s a good chance we’d be able to fill the place.” As the band gained a small following, this information could be used to drive up their fee.

Another way JBoss bootstrapped themselves was through documentation sales. At the height of this these sales totally funded the salary of Scott Stark, and subsidized the salaries of me, Dain, and Sacha. For a band, it could be as simple as selling a professional PDF of their song lyrics. Would you be willing to pay $1 for a printable PDF of your favorite band’s song lyrics? Then there is of course always band merchandise of t-shirts, mugs, towels, posters, etc. All this stuff is so easy and cheap to set up to sell online. We did it at JBoss.

The last step in the evolution of an pure open source business is selling subscriptions. This is where I’m at a loss of how a music band could push such an offering. There is always the possibility of going un-pure. Radiohead seems to be doing it by cross-selling their $80 dollar deluxe box set. JBoss did much of the same with JBoss ON. I know other open source companies are taking similar tacts.

All and all, it might be hard to break even on the Radiohead “honesty box” model for small startup bands, but there’s a lot of creative different ways I think bands could make money off of free IP. I really think open source business models could be applied to other forms of IP. It will be interesting to see how this evolves in the music industry and kudos to Radiohead for thinking out of the box.

Brady or Manning?

3 Comments

Its funny reading all these articles on, if you had the 1st pick in the draft and Manning and Brady were available, who would you pick? The answer becomes obvious if you think about it. How many times has Manning melted down in playoff games vs. Brady?

Manning:

  • 2003 AFC Championship game. 3 Interceptions by Ty Law. Need I say more?
  • 2004 AFC Divisional game. 3 points? Even after you got the competition committee to change the rules? You suck Manning.
  • 1st half 2006 AFC Champinship game. Asante Samuel picks off Manning for a touchdown. Looked confused the entire half. Yeah, he had a great 2nd half, but how much of that was a patriots defense lacking its 2 starting safeties and a team that had the flu going around?

Brady:

  • 2005 AFC Divisional against Denver. One loss for a team that didn’t have the talent to do a 3-peat.

Everybody always wondered: what if Brady had the same receivers Manning did? Now we know. Considering only one receiver from 2006 is active from the Pats, Jabar Gaffney, and is a 4th stringer, also considering the Pats #1 receiver has been active on the Redskins a total of 1 game all year, just shows you how good Brady is. and how much better he makes everybody else around him is just astounding.

Then there are the off-the-field intangibles. Manning is in a million commercials. Brady has done only a few, but even then he has had teammates with him to share the limelight (and I assume, the cash). Manning whines like a baby whenever he makes a mistake in a game. Sometimes even blaiming players other than himself. You won’t see Brady doing that. Finally, who can like somebody that is part of an organization that whines to the competition committee to get the rules changed because you got beat so bad in the AFC Championship game?

Really, I can’t wait for tomorrow’s Colts-Pats match up. Good vs. Evil as some people in the media would like to portray it. Hopefully I won’t have to eat any crow over this email.

Edited after game:  See?  Now Peyton knows how it feels to have no receivers and lose by 4 points in a playoff-like game to a team you should have beaten.

Anybody miss VB?

8 Comments

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…

Java Developer’s Day: Krakow, Poland

10 Comments

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.

 

The rise of meta-annotations

2 Comments

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!

Client driven business activity

3 Comments

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.

JSR 311, JAX-RS: Comment and suggestions

12 Comments

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.

Can’t I have an opinion?

6 Comments

I’m annoyed today. Seems my Go Away Ruby blog has some people thinking that I wrote it to discredit Ruby because I believed RoR is a threat to JBoss. Andy Oliver wrote:

“Ruby was his target, probably because of a perceived (though wrongly so in my opinion) threat to JBoss’s still flagship JBossAS.”

Savio recently linked to my blog in this quote:

“If RoR is such a threat, why are other Java app server vendors “doing okay“?”

Does he think I think RoR is a threat as well? This particular Savio quote was referencing a hilarious quote from a Reuter analyst:

“Chowdhry of Global Equities Research said the prospects for JBoss were dim because its software was designed to work with the Java programming language.

He said Java was losing market share as businesses embrace Ruby, a programming language that is easier to use and works with an open-source rival to JBoss known as Ruby on Rails.”

PHP, Perl, and Python have been around as long or longer than Ruby and RoR, have larger libraries, more applications, and a larger user base. So does that mean an even a closer death for Java and JBoss? Heiko Braun had a funny comment on an internal JBoss mail list:

You see Bill what happens when promoting REST?

Seriously guys, can’t I have an opinion on anything? Maybe its just that I don’t like Ruby or RoR, ya think? It can’t be that simple can it? There has to be some JBoss conspiracy. I just have to be one of Rickard’s evil aliens. Or as Bobby Boucher‘s mother would say, “Bill Burke is the devil.”

EJB 3.1: No-interface view feedback

22 Comments

Another new feature that’s being discussed in the EJB 3.1 expert group is the of a no-interface view for session beans. This means that your bean classes do not have to implement and publish an interface.

@Stateless
public class StockTrader {
   public void buy(Stock stock, int quantity) {...}
   public void  sell(Stock stock, int quantity) {...}
}

The default case, with no additional metadata would publish the StockTrader class as a local view on this stateless bean, so, a client would either receive injected or jndi looked up referenced to the StockTrader class.

@ EJB StockTrader trade;

StockTrader trade = (StockTrader)jndi.lookup("StockTrader/local");

The idea behind this new feature is to reduce the number of artifacts needed in simple applications.

Callback/injection issues

The side effect of this new feature is what do we do about public callback and dependency injection methods?

  1. Don’t allow callback methods to be public. Not having callback methods private does make it harder to unit test these type of methods. The SessionSynchronization interface also poses a problem for this approach. Do we not allow SessionSynchronization interface to be placed on no-interface view SFSBs?
  2. Don’t allow DI setter methods to be public. You have the same unit testing issue with this approach as #1.  Also, setter methods would seem very useful as a business method for SFSB and Singleton beans.
  3. Throw an exception if a public callback method is invoked at runtime.
  4. Throw an exception if a public setter method is invoked at runtime. Again, setter methods as part of the business interface would be very useful for SFSBs and singleton beans, but weird for SLSBs. maybe only throw an exception for public setters on SLSBs?
  5. Allow callback methods to be public and callable from the no-interface view
  6. Allow DI setter methods to be public and callable from the no-interface view.  Although very useful for SFSBs and Singletons, would have weird consequences for SLSBs.

Feedback???

Remote no-interface views?

Should we allow remotable no-interface views? IMO, this is bad practice as you making business logic available to a possible untrusted client. Yeah, I know we had this feature in JBoss AOP Remoting, but maybe it is a bad idea? Or should we just let the app developer decide if it is a good idea or not?  Web services already allows a no-interface view, but this view is usually translated to WSDL which is then compiled to a generated Java interface anyways.  A remote view would still be using the business object.

I’m begging for feedback

Any feedback is extremely useful, even a +1, -1 comment.

Older Entries Newer Entries