Skip to content

openjax/esc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESC (Embedded Servlet Container)

Build Status Coverage Status Javadocs Released Version Snapshot Version

Introduction

OpenJAX ESC (Embedded Servlet Container) is a conveneince wrapper of the Jetty Servlet Container, which provides helpful patterns to developers that desire a lightweight embedded server solution.

Simple API for Embedded Servlet Container Initialization

OpenJAX ESC (Embedded Servlet Container) is created to take full advantage of the javax.servlet.annotation.* annotations defined in the Java Servlet v3 Specification of 2009. Designed specifically to avoid non-cohesive config files, OpenJAX ESC (Embedded Servlet Container) creates a direct and easy to understand embedded wrapper of the Jetty Servlet Container. OpenJAX ESC (Embedded Servlet Container) provides a simple API to initialize a Servlet Container in a JVM, significantly reducing the headache most people have when attempting to accomplish the same with Jetty's raw APIs.

Significantly Reduces Boilerplate Code

OpenJAX ESC (Embedded Servlet Container) is intended to reduce the number of lines of code dedicated to the initialization of the server, therefore reducing the space of possible errors, and thus allowing the developer to move to his next task, confidently assured the server will start.

Getting Started

Prerequisites

  • Java 8 - The minimum required JDK version.
  • Maven - The dependency management system.

Example

  1. Next, add the org.openjax:embedded-server dependency to the POM.

    <dependency>
      <groupId>org.openjax.esc</groupId>
      <artifactId>jetty-9</artifactId>
      <version>1.0.0</version>
    </dependency>
  2. Make App extend org.openjax.embeddedserver.EmbeddedJetty9, and add a constructor.

    public class Server extends EmbeddedJetty9 {
      public Server(int port) {
        super(port);
      }
    }
  3. Add the server initialization code in Server#main().

    public static void main(String[] args) {
      Server server = new Server(8080);
      server.start();
      server.join();
    }
  4. Run App.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.