Thursday, June 23, 2011

Hot Deploy & F5/Refresh-Driven Web Application Development Are Ancient Compared to Eclipse RAP!


Most web applications developer would be very familiar with F5/Refresh-Driven development. You know, make a little change and press F5 in the web browser and you can view the updated page. This was the good old PHP days.

Java EE web application developers used to not that lucky. While some changes like JSP pages, JSF facelets, etc. take effect immediately (and thus, "refresh-driven"), in some cases they have to "redeploy". This usually means developer changes a Java class backing bean or an "important" file like web.xml. Redeploy means undeploying the web app from the Java EE container or application server, then redeploying the web app or WAR again. IDEs like the excellent Eclipse IDE Indigo (yay!) automate this but a redeploy can take anything between a few seconds to... minutes! I think typical web apps would deploy in about 20-30 seconds so that is painful.

JRebel from ZeroTurnaround (which just won the Most Innovative Java Technology in JAX Innovation Awards 2011, congratulations guys!) really helps here, by allowing most common changes to not cause a full redeploy, but just... hot deploy! It's like JSP/JSF but for the rest of Java app, Spring beans, etc. JRebel is a commercial plug-in but is definitely worth it.

But I'd argue Eclipse RAP should won the Most Innovative Java Technology title... Here's why!

(Eclipse Rich Ajax Platform/RAP is framework to develop AJAX-powered web applications easily based on Eclipse RCP programming model, see Eclipse Rich Client Platform (2nd Edition) for more information.)

I've just noticed something today. I know I should've noticed this long ago, but when you launch an Eclipse RAP rich internet application from Eclipse IDE using Debug (F11 key), ALL your code changes take effect immediately! No exceptions!

No need to even refresh the web browser!

Change the code for a menu item or a view or an action, save the .java file, go to the browser and click it... your new code is there!

"No refresh? But how can it be!"

Part of the magic is due to OSGi Dynamic Module System, that is brilliantly integrated as part of the Eclipse platform itself.

So when you save a Java file, Eclipse IDE will compile your class (and only your class, due to incremental builder feature, so it's very fast!), then update the OSGi bundle or Eclipse plug-in in the Eclipse RAP application. And only your bundle/plug-in is updated/refreshed in the application, so again, even if it's a different process it's also very fast. The whole process typically takes less than a second on a typical developer workstation, even on moderately complex apps! Most of the time the process is already done before you have a chance to hit Alt+Tab. ;-)

The other part of the magic is even though Eclipse RAP application comes with full AJAX features by default (it's not an option, it's actually a requirement), most of the business logic is server-side Java. So even if the most of the render JavaScript/HTML presentation layer in the web browser, when you perform an action for example by clicking a menu item, this will trigger a server request...

Which means your updated code! Yay! :)

Also important feature of Eclipse RAP is that for background/long-running jobs or "server push" operations, Eclipse RAP supports several approaches: Eclipse Jobs API or session-long UICallback.

This is pretty much automatic if you're already an Eclipse RCP programmer utilizing Jobs API. There's no need to do workarounds and hacks like traditional AJAX web development or learn yet another new API (and programming model) just for server push.

To learn more about Eclipse platform programming, I highly recommend Eclipse Rich Client Platform (2nd Edition). It's really good for learning Eclipse RCP/RAP development, most of the things that apply to RCP also applies to RAP. In fact, you can single-source an application to two target platforms (RCP for desktop, RAP for web) simultaneously. :-)


  1. Nice post.

    One comment on how hotswapping of code works during debugging. It is actually much more fine grained than you described and doesn't rely on OSGi bundles at all. The magic is part of the Java Development Tools (JDT) and relies on debugging support built directly into the JVM. I believe the updates are done on individual methods, but it might be all the way down to the statement level. There are limitations, especially with anonymous inner classes, but as you have said most of the time it works great.

  2. There are a couple of fine points:

    1. Not all Java VMs support all kinds of code changes. The Sun VM HotSpot, for example, can't cope with new methods, fields and classes.

    2. This fails if you have data in the instances. Code replacement can't (for obvious reasons) change the instances. So if you add a new field,
    it will be null for all existing instances.

  3. Thank you for giving me such a good chance, let me be able to read this essay so good of a son, thank you very much.A reservoir of innovation. Reaped from the most popular designers and the new prominent. You are invited to be impressed with Amber’s selection of wedding dresses 2012, by virtue of an incredible amount of self-motivated ideas that sparkling around. Have a digging-out on our span-new designer lace wedding dress that are tagged into distinctive genre and style simple wedding dresses.

  4. Concise package money, bare nothing, but it is a brand of coat of paint material light, the super invincible joker, very street van Cambridge satchel bag.
    Bag bag tassel part is made of genuine leather oh, very thick soft, package itself is the quality of the skin of PU, quality is good. Much super tassel walking around up born swaying posture, very attract eyeball oh.

    Europe and a bag of wind, appearance is very simple, less is more big oh. Bag body skeleton complex moment modelling, a bit cool taste.
    Give people a feeling of very warm is the purpose of Cambridge satchels, this season it continued the popular bright colour elements, such as pink fluro and yellow fluro. It is so fashion and beautiful. You can also embossing your names on your bag, you will like it very much.

  5. With the correct WOW Gold guide for your World of Warcraft character, you will be well on your way in getting your character the gold it needs to become successful in the game. Remain cognizant that these guides do not provide a means to skirt around the general procedure to make gold. It will only tell you how you can make gold much more efficiently while playing the game.

  6. The enhancements in know-how have produced motor vehicle maintenance and restore less complicated for your normal renault can clip Joe as well as the hardcore mechanic. Nowadays you don't need a drop of instruments plus a long Sunday afternoon to simply tinker and correct your vehicle.

  7. Thank you for the info. It sounds pretty user friendly. I guess I’ll pick one up for fun. thank u

    Web Development New Jersey

  8. Welcome to mmoggg website to buy WoW Gold Kaufen, offer a lot, of course, Diablo 3 Gold or Cheap Diablo 3 Gold and RS Gold, to be purchased at any time, at any time shipment, and look forward to your visit!

  9. Adobe Acrobat 9 Download is a platform for viewing, creating, manipulating and managing files in Adobe's PDF format.
    In PWA, tasks marked as inactive in Microsoft Project Professional 2010 Download are Read-Only.

  10. if you're already an Eclipse RCP programmer utilizing Jobs API. There's no need to do workarounds and hacks like traditional AJAX web development or learn yet another new API
    WOW Gold
    Gold Kaufen für World of Warcraft

  11. Thanks you sob

  12. The whole process typically takes less than a second on a typical developer workstation, even on moderately complex apps! Most of the time the process is already done before you have a chance to hit Alt+Tab. ;-)

  13. Nice article, thanks for the information. It's very complete information. I will bookmark for next reference
    jaring futsal | jaring golf | jaring pengaman proyek |
    jaring pengaman bangunan | jaring pengaman gedung


  14. Your blog is nice. Your sharing information are all awesome. All information is relevant. Your data are relevant for visitors. Your blog provide the accurate and update information to the clients.

    Website Development | Affordable Website Development | Website Development Costs | Proffessional Website Development | Website Development Consultant