The Source for Java Technology Collaboration
User: Password:



Felipe Leme

Felipe Leme's Blog

SOIA - Specfiy Once, Implement Anywhere

Posted by felipeal on June 23, 2005 at 06:36 AM | Comments (1)

Have you ever wondered how hard would it be to switch the implementation for a JCP-based technology? Theoretically, it should be easy as changing the skin of your MP3 player. Unfortunately, that has not being the case for most of the J2EE technologies, specially EJBs.

Last Monday I finished the JSF port of the application we are usign for our BOF at JavaOne. Our originally plan was to port an existing webapp to different MVC frameworks, including JSF RI and MyFaces. As the clock was ticking (our presentation is a week away and we are departuring today) and I hadn't even finished the JSF RI version, we pratically gave up the MyFaces port.

Anyway, last night I decided to give it a try while watching a soccer game (that's one of the best uses of a laptop system :-). And how wasn't my surprise to finish the job just before the half time (and that becuase most of time was spent downloading the software!): all that it took to switch RI for MyFaces was to add a few lines on web.xml and replace half a dozen jars!

That's right: no changes on JSPs, backing-beans or even faces-config.xml; just add a listener on the deployment descriptor (and replace the jars, of course) and you're done!br>
Still don't believe me? Well, take a look on the diff between the 2 projects then:

[felipeal@localhost webapps]$ diff -r jsf-project myfaces-project
Only in myfaces-project/WEB-INF/lib: commons-el.jar
Only in myfaces-project/WEB-INF/lib: commons-validator.jar
Only in myfaces-project/WEB-INF/lib: myfaces.jar
Only in jsf-project/WEB-INF/lib: jsf-api.jar
Only in jsf-project/WEB-INF/lib: jsf-impl.jar
Only in jsf-project/WEB-INF/lib: jstl.jar
Only in jsf-project/WEB-INF/lib: standard.jar
diff -r jsf-project/WEB-INF/web.xml myfaces-project/WEB-INF/web.xml
27a28,33
>
>
>  
>    org.apache.myfaces.webapp.StartupServletContextListener
>  
>

Of course, we have to take in account that our application was very simple: just 3 JSP pages and 2 backing beans. Still, the transition from one implementation to another was very smooth, much more than we predicted.

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • I made the switch on my web app almost a year ago. I too was completely amazed. Back then, it took about a day because MyFaces didn't properly parse the web.xml, and I had to fix that bug (go open source!). However, that paled in comparison to the problems we were having with the RI.

    Now, of course, both sides of the fence behave very nearly according to the specification. I think in about 2 years, this can be a .NET-killing technology.

    Posted by: heaththegreat on June 25, 2005 at 07:34 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds