Scattered War in Embedded GlassFish

Embedded GlassFish project has been making steady progress since Kohsuke and Arun blogged about it. Byron has been working actively on this project. If you missed those earlier announcements, here is the scoop....

You can now start GlassFish within an existing JVM. How cool is that?

Development Status
The promoted builds started to show up lately. I took the latest promoted build (b02) and played with it. The latest APIs source are available here.

ScatteredWar
One of the new interesting feature is scattered war where a war file can be literally scattered. One can provide path to the resources, web.xml, and classes. This can come in handy during development where user may not have the classes, resources, etc. packaged as a war file. Here is the constructor signature of the class.

public ScatteredWar (String name, File resources, File webXml, Collection<URL> classes);

I wrote a very simple class to test the scattered war feature.

import java.io.File; import java.net.URL; import java.util.ArrayList; import org.glassfish.embed.Server; import org.glassfish.embed.ScatteredWar; public class ScatteredTest { public static void main(String[] args) throws Exception { // show usage if (args.length != 4) { System.out.println("%java SimpleTest <name> <resources> <web-xml> <classes>"); return; } // embedded GlassFish server object on port 8080 Server glassfish = new Server(8080); File res = new File(args[1]); File webXml = new File(args[2]); File classes = new File(args[3]); // class path urls ArrayList<URL> cp = new ArrayList<URL>(); cp.add(classes.toURL()); // construct the scattered war ScatteredWar sWar = new ScatteredWar(args[0], res, webXml, cp); // deploy scattered war glassfish.deploy(sWar); } }

I ran the test client using the following...

java -cp .:glassfish-embedded-all-v3-prelude-2.jar ScatteredTest hello /Users/nazrul/scattered/resources/ /Users/nazrul/scattered/WEB-INF/web.xml /Users/nazrul/scattered/classes/

The server started quickly on my two year old MacBook Pro (2.16 GHz Intel Core Duo with 1 GB memory).

INFO: GlassFish v3 Prelude startup time : Embedded (411ms) startup services (564ms) total (975ms)

On the browser, I logged on to the application context root, localhost:8080/hello, and the application loaded as expected.

I am looking forward to the future builds of Embedded GlassFish.

References

Comments:

Nice blog!

Posted by Byron Nevins on October 30, 2008 at 03:20 PM PDT #

Thanks for the post Nazrul. I think we'll be amazed at what people will do with the embedded API.
No scattered war in here but a real-world app: http://blogs.sun.com/alexismp/entry/bundling_glassfish_v3_prelude_xwiki1
EHCache Server and Nuxeo WebEngine both use GlassFish Embedded too.

Posted by Alexis MP on October 30, 2008 at 04:41 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Ramblings about GlassFish

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today