Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class Management

  1. Object
  2. Management

ImplementsHttpServer.Handler

The server’s management endpoints: health for the load balancer, metrics for a scraper, and the jobs and managed beans for an operator.

  GET  /manage/health          public; 503 while draining
  GET  /manage/metrics         every metric, as JSON
  GET  /manage/prometheus      every metric, in the Prometheus text format
  GET  /manage/jobs            the scheduled jobs and their last runs
  GET  /manage/managed         the managed beans, with their attributes' values
  POST /manage/managed/{bean}/{operation}   calls an operation; body: arguments

Off by default outside a development profile; cn1.management.enabled turns it on or off explicitly, and cn1.management.path moves it. Everything but health needs Authorization: Bearer . Without a token, a development profile serves the read-only views to anyone who can reach the port – a laptop – and no profile serves an operation, since an operation changes the running server.

Fields

public static final String ENABLED = "cn1.management.enabled"
public static final String PATH = "cn1.management.path"
public static final String TOKEN = "cn1.management.token"

Methods

public static Management fromConfig(Config config) throws IOExceptionThe endpoints this configuration asks for, or null when they are off.
public static List describeBeans(List all)Each of all – a server’s managed beans, from Backend.getManagedBeans – with its attributes’ current values and its operations.
public static Object invoke(List all, String objectName, String operation, Map arguments) throws Exception
public HttpServer.Response handle(HttpServer.Request request) throws Exception

Inherited methods

Field details

ENABLED

public static final String ENABLED = "cn1.management.enabled"

PATH

public static final String PATH = "cn1.management.path"

TOKEN

public static final String TOKEN = "cn1.management.token"

Method details

fromConfig

public static Management fromConfig(Config config) throws IOException
The endpoints this configuration asks for, or null when they are off.

Throws

IOException
when they are on outside development with no token, which would publish the server’s internals to anyone

describeBeans

public static List describeBeans(List all)
Each of all – a server’s managed beans, from Backend.getManagedBeans – with its attributes’ current values and its operations.

invoke

public static Object invoke(List all, String objectName, String operation, Map arguments) throws Exception

Throws

Exception

handle

public HttpServer.Response handle(HttpServer.Request request) throws Exception

Throws

Exception