|
Added by Joachim Haagen Skeie
While JEE Application Servers definately serves its purpose there are times where a simple Servlet Container will do the job just fine. In fact for a very large proportion of JEE Java applications being developed today, a Servlet Container is all that is needed. Once your application hits production features such as easy deployment, quick startup times, migration between development, system/functional testing, acceptance testing, performance testing, regression testing and finally through to production becomes more important. This migration needs to be as pain free and automated as possible! Add to that the aspect of controlling the startup, shutdown and the available features of the container and the result might just be writing an application with an embedded Servlet Container. Benefits of embedding JettyIn an embedded configuration, your application is started through a simple public static void main(String[] args) method. This method is responsible for setting up the environment variables (everything from the applications port number to other webservice endpoint URLS) before starting the Servlet Container (Jetty's Server class). As hard as that sounds it can be a rather trivial tasks if you use the tools available in the Java Toolbox:
Maven project structureNormally with a development project based on Maven the source code is split into multiple modules (Maven Projects). A general modularization of project would be to split the application into a data access layer, a domain layer and a Web (GUI) layer. ((Schetch)) The Appassembler plugin will need its own Maven Project to adhere to Mavens goal of "One artifact per POM". Dissecting the parts before assemblyI will try to go through each part of the assembly process in just enough details to be useful for this articles purpose before going through the actual assembly process. I will assume you are already familiar with Maven and Spring. AppassemblerAppassembler is a maven plugin that will assemble your applications dependencies as well as generating scripts to execute the application in Windows, Unix, Linux and Macintosh environments. The dependencies are included in a separate "repo" directory that is structured much in the same way as the central maven repository. When building the application, Appassembler will put all necessary files inside the "target/appassembler" directory. Assembly PluginThis Maven plugin is used to generate a .zip file distribution (other formats are supported as well) file that contains the output from Appassembler. SpringI will assume basic Spring knowledge throughout this article, but I will go through how to configure Spring to utilize Java Properties to configure and set up the applications environment. JettyJetty will be used as the Servlet Container. One of Jettys major strengths is its great embeddability support. So, instead of having to deploy the finished application to an Application Server or a Servlet Containter, its possible to gain full control of the execution of the application. "Some assembly Required"Post Assembly - Configuration through jetty.xml and config.propertiess |
|
||||||||
|
|||||||||
|
Recently Updated
|
|||||||||
Popular Labels
No labels match these criteria.
|
|||||||||
Archive Links |
|||||||||