GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - StubbornJava/StubbornJava: Unconventional Java code for building web servers / services without a framework. Think dropwizard but as a seed project instead of a framework. If this project had a theme it would be break the rules but be mindful of your decisions.

BranchesTags
Open more actions menu

Latest commit

 

History

541 Commits
541 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
ansible
ansible
 
 
docker
docker
 
 
gradle
gradle
 
 
k8s/chart
k8s/chart
 
 
stubbornjava-cms-server
stubbornjava-cms-server
 
 
stubbornjava-common
stubbornjava-common
 
 
stubbornjava-examples
stubbornjava-examples
 
 
stubbornjava-undertow
stubbornjava-undertow
 
 
stubbornjava-webapp
stubbornjava-webapp
 
 
terraform
terraform
 
 
.gitignore
.gitignore
 
 
Jenkinsfile
Jenkinsfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Release Follow @StubbornJava

StubbornJava

https://www.stubbornjava.com/

This is very much a work in progress and in the early stages. No code will be pushed to maven central or supported in any way currently. Feel free to clone and install locally. The website is built using all the methods described on the site and in the examples. There is no backing blog framework.

Potentially moving to GitLab

Quick Example (full example Simple REST server in Undertow)

public static void createUser(HttpServerExchange exchange) {
    User userInput = userRequests.user(exchange);
    User user = userDao.create(userInput.getEmail(), userInput.getRoles());
    if (null == user) {
        ApiHandlers.badRequest(exchange, String.format("User %s already exists.", userInput.getEmail()));
        return;
    }
    exchange.setStatusCode(StatusCodes.CREATED);
    Exchange.body().sendJson(exchange, user);
}

public static void getUser(HttpServerExchange exchange) {
    String email = userRequests.email(exchange);
    User user = userDao.get(email);
    if (null == user) {
        ApiHandlers.notFound(exchange, String.format("User %s not found.", email));
        return;
    }
    Exchange.body().sendJson(exchange, user);
}
    
public static final RoutingHandler ROUTES = new RoutingHandler()
    .get("/users/{email}", timed("getUser", UserRoutes::getUser))
    .post("/users", timed("createUser", UserRoutes::createUser))
    .get("/metrics", timed("metrics", CustomHandlers::metrics))
    .get("/health", timed("health", CustomHandlers::health))
    .setFallbackHandler(timed("notFound", RoutingHandlers::notFoundHandler));

public static final HttpHandler ROOT = CustomHandlers.exception(EXCEPTION_THROWER)
    .addExceptionHandler(ApiException.class, ApiHandlers::handleApiException)
    .addExceptionHandler(Throwable.class, ApiHandlers::serverError);

public static void main(String[] args) {
    SimpleServer server = SimpleServer.simpleServer(Middleware.common(ROOT));
    server.start();
}

Suggest a Topic

Check out issues to suggest topics, bug fixes, errors, or vote on issues. Reactions / comments may influence the order topics are added but no guarantees. Several topics will not be accepted here such as larger frameworks (Spring, Play, Jersey ...) as well as dependency injection. We will be more focused on rolling things yourself and solving practical problems. The coding style here may not fit with the norm but it should be very easy to convert any of the classes to be DI friendly.

Getting Started

A guide for building your own minimal embedded Java web server. A simple in order intro to a lot of uses cases for simple web development.

Dev Tools

  • Creating a local development environment with Docker Compose (MySQL, Elasticsearch)
  • Configuring servers with Ansible

HTML / CSS Themes and Templates for rapid prototyping

  • HTML / CSS Themes and Templates

Libraries

SLF4J and Logback for Logging

SLF4J is fairly standard and we chose to use Logback as our underlying implementation.

Typesafe Config For Configuration

Typesafe config is a clean lightweight immutable configuration library. It offers several formats such as .properties, .yml, .json as well as a human friendly json super set. It handles configuration inheritance, includes, data types (string, boolean, int, long, double, durations, arrays, ...), variabe substitution and many more features. Typesafe Config examples

Jackson for JSON

  • Practical Jackson ObjectMapper Configuration
  • Somewhat Deterministic ObjectMapper

Embedded Undertow Web Server

Undertow is a very fast low level non blocking web server written in Java. It is very lightweight and has a very clean API that should be relatively easy for anyone who knows HTTP to pick up. Most custom code will be in the form of an HttpHandler which is a simple interface that can be used in a variety of ways.

  • Writing Custom HttpHandlers
  • Url Routing in Undertow
  • Handling Exceptions in Undertow
  • Creating Middleware in Undertow
  • Simple REST server in Undertow
  • Virtual Hosting in Undertow
  • Webpack and npm with Java
  • Sharing routes and running multiple webservers in a single JVM
  • Configuring Security Headers in Undertow
  • Circuit Breaking HttpHandler
  • Creating a non-blocking delay in the Undertow Web Server for Artificial Latency

Metrics (Dropwizard Metrics, Grafana, Graphite)

  • Monitoring your JVM with Dropwizard Metrics
  • Grafana Cloud Dropwizard Metrics Reporter

OkHttp for HTTP Client

  • OkHttp Example REST client
  • OkHttp Logging Interceptors
  • OkHttpClient Trust All SSL Certificates
  • Web Scraping with OkHttp and jsoup

HikariCP for JDBC Connection Pooling

HikariCP is a very fast lightweight Java connection pool. The API and overall codebase is relatively small (A good thing) and highly optimized. It also does not cut corners for performance like many other Java connection pool implementations.

Uility Classes / Extras

  • Password Hashing with BCrypt
  • XML sitemaps for SEO
  • Lazy loading and caching objects in Java with Guava's Suppliers.memoize
  • Reading File Resources with Guava

Sites Built With This Method

  • StubbornJava
  • QuickDraw
  • DeckHandHQ

About

Unconventional Java code for building web servers / services without a framework. Think dropwizard but as a seed project instead of a framework. If this project had a theme it would be break the rules but be mindful of your decisions.

www.stubbornjava.com

Topics

ansiblecss-themesdropwizarddropwizard-metricsgradlehikaricpjacksonjavajava15jooljooqjsonlogbackokhttp3slf4jterraformundertow

Resources

Readme
MIT license
Activity
Custom properties

Stars

237 stars

Watchers

18 watching

Forks

119 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.