Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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.

License

NotificationsYou must be signed in to change notification settings

StubbornJava/StubbornJava

Repository files navigation

ReleaseFollow @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 toGitLab

Quick Example (full exampleSimple REST server in Undertow)

publicstaticvoidcreateUser(HttpServerExchangeexchange) {UseruserInput =userRequests.user(exchange);Useruser =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);}publicstaticvoidgetUser(HttpServerExchangeexchange) {Stringemail =userRequests.email(exchange);Useruser =userDao.get(email);if (null ==user) {ApiHandlers.notFound(exchange,String.format("User %s not found.",email));return;    }Exchange.body().sendJson(exchange,user);}publicstaticfinalRoutingHandlerROUTES =newRoutingHandler()    .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));publicstaticfinalHttpHandlerROOT =CustomHandlers.exception(EXCEPTION_THROWER)    .addExceptionHandler(ApiException.class,ApiHandlers::handleApiException)    .addExceptionHandler(Throwable.class,ApiHandlers::serverError);publicstaticvoidmain(String[]args) {SimpleServerserver =SimpleServer.simpleServer(Middleware.common(ROOT));server.start();}

Suggest a Topic

Check outissues 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

Aguide 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

HTML / CSS Themes and Templates for rapid prototyping

Libraries

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

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

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.

Metrics (Dropwizard Metrics, Grafana, Graphite)

OkHttp for HTTP Client

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

Sites Built With This Method

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp