You can leverage your experience and knowledge about the GlassFish command line tool,  asadmin, with Embedded GlassFish servers.

Here is a use case:

You want an  Embedded GlassFish server that uses a JavaDB database.  You need to setup a few things in the server configuration.  You can do this configuration in your code every time you start using the CommandExecutor.  Another possibility is to do the following:

  1. start the Embedded GlassFish server -- making sure autodelete is off
  2. Run asadmin commands for configurationmbedded GlassFish server
  3. Stop the Embedded GlassFish server
  4. Always set the install-root to the root of the generated file system from steps 1,2.

Here is how to run asadmin in Embedded GlassFish (embedded.jar is the Embedded GlassFish all-in-one jar file that you have downloaded or built)

Windows:

java -cp final.jar com.sun.enterprise.admin.cli.AsadminMain %*

*NIX:

java -cp final.jar com.sun.enterprise.admin.cli.AsadminMain $*


Comments:

I wonder whether I can use this to write unit tests for EJBs..

Posted by blah on July 14, 2009 at 03:32 AM PDT #

For EJB testing, GlassFish v3 implements the now standard EJBContainer.createEJBContainer() API. You'll need to have glassfish/lib/embedded/glassfish-embedded-static-shell.jar in your classpath (or a bunch of maven dependencies). See http://blogs.sun.com/kensaks/entry/embeddable_ejb for an intro.

Posted by Alexis MP on September 23, 2009 at 11:51 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by codeplumber