Thursday, November 22, 2007

Web Start On Steroids - POJO Application Server


A POJO Application Server on the surface feels very much like Web Start, and its often confused with WebStart the well known Java launcher.

When one witnesses an application starting remotely, its easy to mistakenly assume it is Web Starting, after all when a program pops up out of a browser, it just looks like, well, a program, however the mechanism is very different.

As you know a POJO Application Server hosts entire Java applications, and for the purposes of this article we going to assume, that out there, there is a POJO Application Server, and its hosting a java application. 

We going to concentrate on how this Web Start on Steroids illusion is being
created.

Imagine for a moment you writing a plain old Java program somewhere, and you decide you want to launch a remote class sitting on a POJO Application server.


//load a class instance FROM  the POJO Application Server

Class uiApp = vessel.
getRemoteClass("the.remote.class.path.to.say.the.UI"); 

if(uiApp != null){

I_UI i_UI = (I_UI)vessel.newInst(uiApp);
i_UI.start();

}
That literally is the code. 

If this is pointing at a Swing UI class on the POJO Application Server, it will jump out of this application that we writing, and run.

Same effect, but its really "Web Starting", from a few lines of code in your application. 

It does not work at Jar level, it will only get the classes necessary to run the remote class, in this (your) application.

So when it starts up a remote UI class, it gives the illusion of Web Starting, but its actually really just allowing one to pull down classes from a remote server application. 

If we took this little bit of code and put it on the traditional WebStart... it would download very quickly, and then start that UI from the POJO server, and users wouldn't know the difference.

But that doesnt explain why the samples that come with a POJO Application Server start so fast. 

On a LAN, in most cases, from the time one says, go, its little more than a few seconds before the application is running.

There's another trick that POJO Application Servers use, look at this code.

//load a class instance ON the POJO Application Server

I_RemApp i_remApp = (I_RemApp )vessel.
loadRemoteClassInst(I_RemApp
.class, ""the.remote.class.path.to.say.the dB.Pool");

i_remApp.runSomeMethod();

Again, this is literally what the code looks like.

As you can see we pointing it at a dB pool on the remote POJO Application
Server, and we call methods as usual.

Nothing remarkable really, except that this class, even though we using it in
our application, is not running here, its running on the POJO Application
Server.

It was never downloaded, when we call a method, we actually calling the method
on the remote POJO Application Server.

The reason it starts so quick, is because only the UI classes are running in this
application. 

Developers write little programs like the one above, to start the UI side, here,
and they leave the other classes running on the POJO server.

This is why it gives the illusion of Web Start on Steroids.

Incidentally you now also know half the API calls on a POJO Application Server,
an why, even though remote users run the applications, they never leave the
server.

http://coolharbor.100free.com/index.htm

0 comments: