enkan circleci

An explicit and simple Java framework


Enkan(円環) is a microframework implemented middleware pattern like ring or connect.



  • Minimal (Simple made easy)
  • Ease of development
  • Ease of operation


  • Middleware pattern
  • No configuration files
  • Avoid blackbox
  • Less annotations
  • Less library dependencies
  • Single instance (Middlewares and compoments, controller)

Ease of development

  • Faster startup (Preventing to scan classes)
  • Reloading classes without restarting JVM
  • Trace execution of middlewares
  • Alert misconfiguration

Ease of operation

  • Starting server is fast. (~3 seconds)
  • Resetting application is very fast. (~1 seconds)
  • Run-time change predicates of middleware on the REPL


  • Java8
  • Java EE 7 Specification


  • Service Unavailable
  • Session
  • Flash
  • Cookie
  • Parsing parameters
  • Trace log
  • Populating form (kotowari)
  • JSR-303 Validation (kotowari)
  • Routing like Rails (kotowari)
  • Injecting components to a controller (kotowari)


  • HikariCP
  • Flyway
  • Freemarker
  • Jetty
  • Undertow
  • Doma2

Using enkan and kotowari, your code is following

public class ExampleController {
    private TemplateEngineComponent templateEngine;

    private DomaDaoProvider daoProvider;

    public HttpResponse index(ExampleForm form) {
        CustomerDao customerDao = daoProvider.get(CustomerDao.class);
        Customer customer = customerDao.selectById(form.getId());
        return templateEngine.render("example",
                "customer", customer);

Get started

Add sonatype snapshots repository to your pom.xml




Enkan system is consist of components. Component is a singleton instance sharing data between requests.

    "doma", new DomaProvider(),
    "flyway", new FlywayMigration(),
    "template", new FreemarkerComponent(),
    "datasource", new HikariCPComponent(OptionMap.of("uri", "jdbc:h2:mem:test")),
    "app", new ApplicationComponent("kotowari.example.MyApplicationFactory"),
    "http", builder(new JettyComponent())
        .set(JettyComponent::setPort, Env.getInt("PORT", 3000))
    component("app").using("template", "doma", "datasource"),


An application has a stack of middlewares. A middleware is a single instance. By use method, the middleware is used by application.

app.use(ANY("/secret"), new AuthenticateMiddleware());


Enkan system is operated by a REPL interface.

  • Start a server REPL> /start [pool-1-thread-1] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-0 - is starting. [pool-1-thread-1] INFO org.flywaydb.core.internal.util.VersionPrinter - Flyway 3.2.1 by Boxfuse [pool-1-thread-1] INFO org.flywaydb.core.internal.dbsupport.DbSupportFactory - Database: jdbc:h2:mem:test (H2 1.4) [pool-1-thread-1] INFO org.flywaydb.core.internal.command.DbValidate - Validated 1 migration (execution time 00:00.019s) [pool-1-thread-1] INFO org.flywaydb.core.internal.metadatatable.MetaDataTableImpl - Creating Metadata table: "PUBLIC"."schema_version" [pool-1-thread-1] INFO org.flywaydb.core.internal.command.DbMigrate - Current version of schema "PUBLIC": << Empty Schema >> [pool-1-thread-1] INFO org.flywaydb.core.internal.command.DbMigrate - Migrating schema "PUBLIC" to version 1 - CreateCustomer [pool-1-thread-1] INFO org.flywaydb.core.internal.command.DbMigrate - Successfully applied 1 migration to schema "PUBLIC" (execution time 00:00.059s). 2 02, 2016 7:58:35 午後 org.hibernate.validator.internal.util.Version <clinit> INFO: HV000001: Hibernate Validator 5.2.2.Final [pool-1-thread-1] INFO org.eclipse.jetty.util.log - Logging initialized @2688228ms [pool-1-thread-1] INFO org.eclipse.jetty.server.Server - jetty-9.3.5.v20151012 REPL> [pool-1-thread-1] INFO org.eclipse.jetty.server.ServerConnector - Started [email protected]{HTTP/1.1,[http/1.1]}{} [pool-1-thread-1] INFO org.eclipse.jetty.server.Server - Started @2688295ms
  • Stop a server
  • Reload an application
  • Show routing information REPL> /routes app GET / {controller=class kotowari.example.controller.ExampleController, action=index} GET /m1 {controller=class kotowari.example.controller.ExampleController, action=method1} GET /m2 {controller=class kotowari.example.controller.ExampleController, action=method2} GET /m3 {controller=class kotowari.example.controller.ExampleController, action=method3} GET /m4 {controller=class kotowari.example.controller.ExampleController, action=method4} POST /login {controller=class kotowari.example.controller.LoginController, action=login}
  • Show middleware stack REPL> /middleware app list ANY defaultCharset ([email protected]) NONE serviceUnavailable ([email protected]) ANY stacktrace ([email protected]) ANY trace ([email protected]) ANY contentType ([email protected]) ANY httpStatusCat ([email protected]) ANY params ([email protected]) ANY normalization ([email protected]) ANY cookies ([email protected]) ANY session ([email protected]) ANY resource ([email protected]) ANY routing ([email protected]) ANY domaTransaction ([email protected]) ANY form ([email protected]) ANY validateForm ([email protected]) ANY htmlRenderer ([email protected]) ANY controllerInvoker ([email protected])
  • Rewrite a predicate of middleware REPL> /middleware app predicate serviceUnavailable ANY REPL> /middleware app list ANY defaultCharset ([email protected]) ANY serviceUnavailable ([email protected]) ANY stacktrace ([email protected])

Enkan REPL can attach to a running process.

enkan> /connect 35677
Connected to server (port = 35677)
  • TODO: Migrate to JShell.


Kotowari is a web routing framework on Enkan.

It’s rails-like syntax in the routing definition.

Routes routes = Routes.define(r -> {
    r.get("/").to(ExampleController.class, "index");
    r.get("/m1").to(ExampleController.class, "method1");
    r.get("/m2").to(ExampleController.class, "method2");
    r.get("/m3").to(ExampleController.class, "method3");
    r.get("/m4").to(ExampleController.class, "method4");
    r.post("/login").to(LoginController.class, "login");

Related Repositories



An explicit and simple Java framework ...



An inhouse app server for both iOS and Android. ...

Top Contributors

kawasima 223kazuki backpaper0 uggds hatappo tenten0213 hotchemi toastkidjp nakamura-to pochi disc99 seki-seki siosio


-   v0.1.0 zip tar