The Embedded GlassFish Web Plugin allows you to create an Instant Developer Experience for your web application. In essence, this means that starting development is extremely easy. It also reduces staff turnover costs tremendously, which is especially good news for Open Source projects. Reducing the barriers to entry makes it easier for people to contribute.
Characteristics of an Instant Developer Experience are:
The Instant Developer Experience itself consists of:
mvn glassfish:run
As you can see, it is trivially easy to start development. This is intended. You can see the application working, and correlate what you see with the source code. And the source code is sufficient, as there are no outside dependencies.
Preparing a development environment for an Instant Developer Experience mostly consists of leaving stuff out. This is what you need:
Creating an Instant Developer Experience means that your project sources must be organized a little differently that you're used to. This has little to do with the structure: migrating from Ant to Maven is a lot more work. What we need to do is to make our sources fully self-contained.
This means:
If you're using Maven, the first part is easy: just configure your pom.xml to use the Embedded GlassFish Web Plugin.
The second part is only slightly more difficult, depending on your needs. The most common two services an application depends on are a database (RDBMS) and SMTP server.
For a mailserver, you can use the Wiser Framework from SubEtha SMTP. To use it, your application must only connect to the mailserver to actually send email. Your integration tests then ensure the mailserver is running as needed, so they can examine the mail that was sent. This is the dependency you'll need to add to your pom.xml:
<dependency> <groupId>org.subethamail</groupId> <artifactId>subethasmtp-wiser</artifactId> <version>1.2</version> </dependency>
A database is slightly work. Not setting up the database: that's simply adding dependency to e.g. HsqlDB, and (assuming Maven with the Embedded GlassFish Web Plugin mentioned above), defining a DataSource to a JDBC URL like jdbc:hsqldb:mem:test. The tricky part is ensuring that the database has content after starting the application. For the persistence framework of GlassFish, EclipseLink, there is no ready-made solution yet, but you can create a javax.servlet.ServletContextListener to populate your database. As an added bonus, you can also annotate it with javax.servlet.annotation.WebListener to have GlassFish automatically pick it up to populate your database. This means that the class can be in the test classpath, and it will not be deployed to production.