ServerContext class abstract interface

Represents the runtime environment of a JetLeaf web server.

The ServerContext acts as a shared metadata and configuration holder that governs the lifecycle, attributes, and initialization parameters of a running WebServer instance. It provides unified access to the following:

  • Server-level context path and display metadata
  • Arbitrary application attributes
  • Initialization parameters configured during server bootstrap
  • Registered ApplicationContextInitializer instances

Implementations may represent:

  • Embedded JetLeaf servers (e.g., Jetty, Shelf, or Dart-native)
  • Deployed servlet-style containers (if ported to other runtimes)

Typical Usage

final context = JetLeafServerContext();
print(context.getContextPath()); // e.g. "/api"
context.setAttribute("startedAt", DateTime.now());

Responsibilities

  • Provide access to initialization parameters and system attributes.
  • Serve as a registry for per-server global objects.
  • Offer access to the backing WebServer.
  • Manage ApplicationContextInitializer instances for lifecycle setup.

Implementations are typically discovered and initialized automatically during the JetLeaf web startup phase.

Implementers

Properties

hashCode int
The hash code for this object.
no setterinherited
log → Log
Returns the Log instance bound to this server context.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getAttribute(String name) Object?
Retrieves an arbitrary attribute previously stored in this context.
getAttributeNames() Iterable<String>
Returns the list of all attribute names currently held in the context.
getContextPath() String
Returns the base context path of the server (e.g., /, /api, /admin).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeAttribute(String name) → void
Removes a previously stored attribute.
setAttribute(String name, Object value) → void
Stores a named attribute in the current context.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

WEB_APPLICATION_ATTRIBUTE_NAME String
The attribute name used to store or retrieve the WebApplicationContext from the server or servlet context.
getter/setter pair

Constants

SERVER_CONTEXT_PATH → const String
The default context path used when none is specified.
SERVER_CONTEXT_PATH_PROPERTY_NAME → const String
The property name for configuring the server context path via the environment or application configuration.