lundi novembre 23, 2009
|
GlassFish Embedded Reloaded, an appserver in your pocket It wasn't enough for GlassFish v3 to be broken into 200+ OSGi bundles executable on different OSGi implementations such as Felix or Equinox (or even without OSGi, i.e. in "Static" mode), we also had to make it embeddable (in-process, using an API).
In a previous entry, I discussed GlassFish embedded is in-process integration of the GlassFish v3 features (not just the web container) using an API to start/stop/configure the server and its containers and to deploy/undeploy applications.
While this definition and the use-cases (testing, shipping shrink-wrapped apps, ...) has not changed since GlassFish v3 Prelude which shipped a year ago, the API has substantially evolved (up to promoted build 65 in late September I believe) as you can read below and can now be considered stable. As you'll see later in this post, the deployment can be trivial. An overview of the API
Main classes are :
Update: you'll find the entire API for Java EE 6 and GlassFish v3 here.
The API offer a flexible inner-class Builder pattern :
Let me walk you through a simple example which deploys an existing WAR from a
First the logic :
The startup process :
The deployment :
... and the cleaning up :
The above example is only scratching the surface. You can deploy exploded archives (check out the There are two modes for running GlassFish Embedded :
• implanted: this uses an existing GlassFish installation and requires having • autonomous: for easier distribution an all-in-one JAR file is available in two flavors: full profile (40 MB) and web profile (30 MB). Not bad for a full-blown app server! The complete application+runtime bundle can then be deployed using Maven, an installer (such as IzPack), a jar file (eventually wrapped in an .exe) or even via Java Web Start. Still early daysWhether you're using the implanted or autonomous mode (using the uber-jar), you'll be running the same code, simply using different entry paths. Because of the different packaging and the temporary filesystem layout the autonomous mode uses, differences are always possible. Many issues were fixed in the past couple of months thanks, including some by users themselves. Note that there is no OSGi involved in the embedded mode (I don't think this is a limitation, but it's certainly an important data point). It is much like running in static mode (same classloader hierarchy). There are also some limitations such as TimerEJB not being supported for the time being. But other than that, a non-trivial application like Hudson deploys to GlassFish embedded like a charm. If this sounds interesting to you, please use a recent promoted build (b73 and above) or wait (a few weeks) for the GlassFish v3 final release in December (2009) and certainly ask questions on the USERS mailing list (or forum), and share your experience via blogs, tweets, etc... ( nov. 23 2009, 04:38:56 PM CET ) Permalink Comments [4]
Trackback URL: http://blogs.sun.com/alexismp/entry/glassfish_embedded_reloaded
Post a Comment: |
This is just so awesome.
I can not make unit tests so simple
No more Jetty , yay.
Posted by Richard Kolb on décembre 03, 2009 at 01:56 PM CET #
Jetty is still a nice product, but GlassFish does provide a complete Java EE 6 runtime.
Posted by Alexis MP on décembre 03, 2009 at 03:59 PM CET #
Will the Maven plugin support an embedded glassfish:run goal?
All our development in Maven is based around embedded Jetty via the jetty:run goal, which saves us the time required to build and deploy a WAR.
Without equivalent functionality. GFv3 would not be an option for us.
Posted by jacek on décembre 18, 2009 at 10:52 PM CET #
@jacek, the maven plugin has the following goals:
glassfish:run
glassfish:start
glassfish:deploy
glassfish:undeploy
glassfish:stop
glassfish:admin
Check out http://docs.sun.com/source/821-1208/index.html#gijhs
Posted by Alexis MP on décembre 19, 2009 at 02:17 PM CET #