GlassFish Embedded API

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    GlassFish Embedded API - Presentation Transcript

    1. Embedded GlassFish Byron Nevins, November 6, 2008
    2. 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
    3. 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/
    4. 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
    5. 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
    6. 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.
    7. 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!
    8. 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(\"Got an Exception: \" + 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
    9. 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 \"%CP%\" com.yourCompany.Main %* endlocal
    10. 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();
    11. 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.
    12. 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
    13. 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/

    + pelegripelegri, 2 years ago

    custom

    2422 views, 0 favs, 0 embeds more stats

    An overview of the GlassFish Embedded API

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2422
      • 2422 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 44
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories