• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
GlassFish Embedded API
 

GlassFish Embedded API

on

  • 6,926 views

An overview of the GlassFish Embedded API

An overview of the GlassFish Embedded API

Statistics

Views

Total Views
6,926
Views on SlideShare
6,894
Embed Views
32

Actions

Likes
0
Downloads
60
Comments
0

1 Embed 32

http://www.slideshare.net 32

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    GlassFish Embedded API GlassFish Embedded API Presentation Transcript

    • Embedded GlassFish Byron Nevins, November 6, 2008
    • History ● If embedded is so useful – why didn't we offer it in 7, 8, or 9? ● The Launcher was really an integral/ensnarled part of the AppServer. Launcher figured out runtime properties in domain.xml and other config files and then passed this info to the server JVM. ● That has changed. Now the launcher is responsible mainly for setting JVM startup options. GF itself figures out its own configuration. ● As a result the AppServer can be started from any JVM
    • Highlights ● Who? Development: Kohsuke Kawaguchi, Byron Nevins Management: Nazrul Islam ● When? November 6, 2008 ● What? Embedded GlassFish Initial Rollout ● Where? https://embedded-glassfish.dev.java.net/
    • Why? ✔ Very fast startup ✔ No GF installation needed. ✔ Able to run inside of a Maven JVM ✔ Support deployment and running of Web Applications ✔ Allow easy HTTP port setting
    • How? Embedded means that a very special type of GlassFish is run. ● No fancy class loading frameworks are used. ● No GF installation is needed or used ● No persistent Domain is needed or used
    • Use Cases ● Ability to run a web application like a regular java application ● Unit Tests. A servlet can define unit tests that will automatically start an embedded GF, deploy the servlet, run and test the servlet and then shutdown GF. ● Fast Jetty-like development ● Use as a tiny web container. E.g. Hudson ● Large complex testing frameworks do not require a separate AppServer domain to be configured and run.
    • Examples - API A simple Maven project that uses Embedded GlassFish This is needed inside pom.xml of your project: <dependencies> <dependency> <groupId>org.glassfish.embedded</groupId> <artifactId>glassfish-embedded-all</artifactId> <version>3.0-Prelude-SNAPSHOT</version> </dependency> </dependencies> That's all you need in order to use Embedded GlassFish in your code!
    • Examples - API A simple Maven project that uses Embedded GlassFish Now create a main Java class and add this (no error checking for clarity): import org.glassfish.embed.*; public static void Main(String[] myWarFiles) { try { Server myGF = new Server(9999); for(String fname : myWarFiles) myGF.deploy(new File(fname)); myGF.start(); // do stuff here! myGF.stop(); } catch(Exception e) { System.out.println(quot;Got an Exception: quot; + e); } } The Web Applications will be available and listening for HTTP traffic at port 9999 (remove the stop() call of course!) You can look at an actual smoketest that we use that does exactly this: Ref: https://svn.dev.java.net/svn/glassfish-svn/branches/v3_prelude_release/embedded/packager/smoketests
    • Examples - API A non-Maven project that uses Embedded GlassFish In this case you need to get the all-in-one Embedded jar here: Nightly: http://download.java.net/glassfish/v3-prelude/embedded/nightly/ Promoted: http://download.java.net/glassfish/v3-prelude/embedded/promoted/ Let's say you download the latest nightly which is named “latest.jar” You write code exactly as in the previous slide except you need to add latest.jar to the classpath of your Java compiler. You run your code simply by adding latest.jar to the classpath. Here is a simple example Windows script: setlocal set CP=myEmbeddedApp.jar;latest.jar set DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1322 java %DEBUG% -cp quot;%CP%quot; com.yourCompany.Main %* endlocal
    • Examples - API-Helper You can go one level higher than the Embedded GlassFish API. We have a few helper classes that make it even simpler. Sample Code ScatteredWar swar = new ScatteredWar(.....); EmbeddedInfo info = new EmbeddedInfo(); info.addScatteredWar(swar); info.addArchive(new File(“myOtherApp.war”); info.setHttpPort(12345); EmbeddedRunner runner = new EmbeddedRunner(info); runner.run();
    • Examples – No Java Would you like to try Embedded GlassFish but you don't want to write any Java code? No Problem! Say you have downloaded the Embedded GlassFish jar file as “latest.jar” java -jar latest.jar -p 3456 myapp1.war myapp2.war This will start Embedded GlassFish listening at port 3456 with the 2 applications deployed. Java -jar latest.jar –help (or no argument at all) will show helpful information.
    • Schedule Immediate: JDBC/JavaDB support has just been added. An API for configuring JDBC will be in place this week. Support for supplying your own configuration in domain.xml will be added this week. November 14, 2008 Support for ● Servlet 2.5 ● JSP 2.1 ● JSF 1.2 ● JSTL 1.1 ● JPA ● JDBC 4.0
    • References ● The Embedded GlassFish project: https://embedded-glassfish.dev.java.net ● Schedule: http://wiki.java.net/bin/view/Projects/EmbeddedGlassFishSchedule ● Source Code: https://svn.dev.java.net/svn/glassfish-svn/branches/v3_prelude_release/embedded ● Arun Gupta's Blog on Embedded http://weblogs.java.net/blog/arungupta/archive/2008/05/embeddable_glas.html ● API JAVADOC: https://embedded-glassfish.dev.java.net/nonav/gf-embedded-api/apidocs/ ● Build Instructions: http://wiki.java.net/bin/view/Projects/BuildInstructions ● Issue Tracker: https://embedded-glassfish.dev.java.net/servlets/ProjectIssues ● Mailing Lists: https://embedded-glassfish.dev.java.net/servlets/ProjectMailingListList ● Promoted Builds: http://download.java.net/glassfish/v3-prelude/embedded/promoted/ ● Nightly Builds: http://download.java.net/glassfish/v3-prelude/embedded/nightly/