Verify servlet service properties
2 files changed
tree: 4c7bb5b3c9af0033070596792bd1edcdb5b82503
  1. src/
  2. .gitignore
  3. pom.xml

Sling Capabilities Module

The servlet provided by this module allows for creating Capabilities HTTP endpoints on a Sling instance: Resources that provide information on which services are available, version levels etc.

For now, a single type of endpoint is provided: all Resources which have the sling/capabilities resource type will return the same set of Capabilities, generated by aggregating the output of all active CapabilitiesSource services.

This can be easily expanded to multiple sets of Capabilities if needed later on, by changing the code to use service properties to group or tag the CapabilitiesSource services.

These capabilities are not the same as OSGi capabilities: they can be application-related, indicate the availability of external services, etc.

CapabilitiesSource services

The tests provide simple CapabilitiesSource examples, that API is as follows:

public interface CapabilitiesSource {

    /** @return the namespace to use to group our capabilities.
     *  That name must be unique in a given Sling instance.
    String getNamespace();

    /** @return zero to N capabilities, each being represented by
     *      a key/value pair.
     * @throws Exception if the capabilities could not be computed.
    Map<String, Object> getCapabilities() throws Exception;

CapabilitiesServlet output

The CapabilitiesServlet produces output as in the example below, where two CapabilitiesSource services are available:

$ curl -s -u admin:admin http://localhost:8080/tmp/cap.json | jq .
  "": {
    "": {
      "": "org.apache.felix.framework",
      "framework.bundle.version": "5.6.10"
    "": {
      "java.specification.version": "1.8",
      "java.vm.version": "25.171-b11",
      "java.vm.vendor": "Oracle Corporation"