Module io.avaje.jex
Package io.avaje.jex

Class Jex

java.lang.Object
io.avaje.jex.Jex

public class Jex
extends Object
Create configure and start Jex.


     final Jex.Server app = Jex.create()
       .routing(routing -> routing
         .get("/", ctx -> ctx.text("hello world"))
         .get("/one", ctx -> ctx.text("one"))
       .port(8080)
       .start();

     app.shutdown();

 
  • Field Details

  • Method Details

    • create

      public static Jex create()
      Create Jex to configure with routes etc before starting.
    • attribute

      public <T> Jex attribute​(Class<T> cls, T instance)
      Set a custom attribute that can be used by an implementation.
    • attribute

      public <T> T attribute​(Class<T> cls)
      Return a custom attribute.
    • errorHandling

      public Jex errorHandling​(ErrorHandling.Service service)
      Configure error handlers.
    • errorHandling

      public ErrorHandling errorHandling()
      Return the Error handler to add error handlers.
    • serverConfig

      public ServerConfig serverConfig()
      Return the server specific configuration.
    • serverConfig

      public Jex serverConfig​(ServerConfig serverConfig)
      Set the server specific configuration.
    • routing

      public Jex routing​(Routing.Service routes)
      Add routes and handlers to the routing.
    • routing

      public Jex routing​(Collection<Routing.Service> routes)
      Add many routes and handlers to the routing.
    • routing

      public Routing routing()
      Return the Routing to configure.
    • accessManager

      public Jex accessManager​(AccessManager accessManager)
      Set the AccessManager.
    • jsonService

      public Jex jsonService​(JsonService jsonService)
      Set the JsonService.
    • plugin

      public Jex plugin​(Plugin plugin)
      Add Plugin functionality.
    • configureWith

      public Jex configureWith​(io.avaje.inject.BeanScope beanScope)
      Configure given the dependency injection scope from avaje-inject.
      Parameters:
      beanScope - The scope potentially containing Handlers, AccessManager, Plugins etc.
    • configure

      public Jex configure​(Consumer<Jex> configure)
      Configure via a lambda taking the jex instance.
    • exception

      public <T extends Exception> Jex exception​(Class<T> exceptionClass, ExceptionHandler<T> handler)
      Add an exception handler for the given exception type.
    • port

      public Jex port​(int port)
      Set the port to use.
    • context

      public Jex context​(String contextPath)
      Set the context path.
    • staticFiles

      public StaticFileConfig staticFiles()
      Return the static file configuration.
    • register

      public Jex register​(TemplateRender renderer, String... extensions)
      Explicitly register a template renderer.

      Note that if not explicitly registered TemplateRender's can be automatically registered via ServiceLoader just by including them to the class path.

      Parameters:
      renderer - The template renderer to register
      extensions - The extensions the renderer is used for
    • start

      public Jex.Server start()
      Start the server.
    • lifecycle

      public AppLifecycle lifecycle()
      Return the application lifecycle support.