Apache Sling Servlets Resolver

Clone this repo:
  1. 51aba70 Add security section to AGENTS.md by Robert Munteanu · 2 weeks ago master
  2. ef8b36d docs: update AGENTS.md and README.md with new API, structure, and test details (#67) by Carsten Ziegeler · 2 weeks ago
  3. ea344cf docs: add AGENTS.md, CLAUDE.md, and expand README (#66) by Carsten Ziegeler · 2 weeks ago
  4. 465d368 chore(deps): upgrade sling-bundle-parent to version 66 (#65) by Carsten Ziegeler · 3 weeks ago
  5. 652d7e0 SLING-13133 listChildren must be streaming (#64) by Jörg Hoh · 3 weeks ago

Apache Sling

Build Status Test Status Coverage Sonarcloud Status JavaDoc Maven Central servlets License

Apache Sling Servlets Resolver

This module is part of the Apache Sling project.

This OSGi bundle implements Sling's servlet and script resolution services:

  • org.apache.sling.api.servlets.ServletResolver via SlingServletResolver
  • org.apache.sling.api.scripting.SlingScriptResolver via SlingScriptResolverImpl (deprecated API bridge)
  • org.apache.sling.api.servlets.JakartaErrorHandler for error handling using Sling's resolution algorithm

See the servlets and scripts documentation for resolution behavior.

Highlights

  • Supports both javax.servlet (4.x) and jakarta.servlet (6.1) APIs
  • Resolves scripts and servlets across resource-type hierarchies with selector/extension/method matching
  • Mounts OSGi servlet services into the resource tree through dedicated resource providers
  • Tracks bundled scripts contributed through OSGi capabilities (sling.servlet)
  • Maintains servlet/script resolution caches with JMX inspection and cache management support
  • Includes resolver diagnostics through a Felix Web Console plugin
  • Supports optional servlet/script hiding via IgnoredServletResourcePredicate
  • Provides a configurable bundled-script health check (BundledScriptTrackerHC)

Build and test

This module requires Java 17 and uses Maven.

  • Build bundle (skip tests): mvn clean package -DskipTests
  • Run unit tests: mvn test
  • Run full verification (unit + integration tests): mvn verify
  • Run integration tests only: mvn verify -Dsurefire.skip=true
  • Run verification without integration tests: mvn verify -DskipITs
  • Run SpotBugs check: mvn spotbugs:check
  • Run a single unit test class: mvn test -Dtest=ResourceCollectorTest
  • Run a single integration test class: mvn verify -Dit.test=ServletSelectionIT

Project structure

src/main/java/org/apache/sling/servlets/resolver/
  api/
    IgnoredServletResourcePredicate.java
  jmx/
    SlingServletResolverCacheMBean.java
  internal/
    SlingServletResolver.java
    SlingScriptResolverImpl.java
    ResolverConfig.java
    helper/      (resource and location collectors)
    resolution/  (resolver cache implementation)
    resource/    (servlet mounting/resource providers)
    bundle/      (bundled script tracking and servlet wrapper support)
    defaults/    (default and error handler servlets)
    console/     (Web Console diagnostics)

src/test/java/org/apache/sling/servlets/resolver/
  internal/      (unit tests)
  internal/resourcehiding/  (unit tests for hiding predicate behavior)
  it/            (Pax Exam integration tests)
  it/resourcehiding/  (integration tests for hidden servlet fallback behavior)