Skip to content

Add ApiExtension ServiceLoader extension point - #236

Merged
jampukka merged 1 commit into
nlsfi:mainfrom
jampukka:core/api-extension
Oct 16, 2026
Merged

jampukka merged 1 commit into
nlsfi:mainfrom
jampukka:core/api-extension

Conversation

@jampukka

Copy link
Copy Markdown
Collaborator

Nothing in the repository implements it yet beyond a test fixture. OGC API - Tiles (later PR) is the first planned consumer. The Features resources are not moved behind it.

  • Extension discovery

    • Found with java.util.ServiceLoader, as OutputFormatFactorySpi
    • A module is enabled by putting its jar on the classpath and configuring it
    • No order is imposed on extensions, since links, conformsTo and collections are unordered in OGC API Features
  • ApiExtensionFactory

    • create(ApiExtensionContext) runs once at startup. Returning null means nothing is configured for it and it is skipped with a log line. Throwing fails startup, so a broken configuration cannot serve a partial API
  • ApiExtensionContext

    • Record of the config parser, config path and feature collections. The first record in hakunapi-core
    • One argument rather than three, so adding something later is not a breaking change for factories (same reason as OutputFormatFactorySpi.create(Map))
  • ApiExtension

    • One instance describes everything the servlet layer publishes for its module: conformance classes, operations, landing page and collection links, non-feature collections, f values and injectables
    • getInjectables() returns the module's own config objects for DI, declared as plain types so core has no DI framework
    • getCollectionIds is separate from getOperations because the OpenAPI generator asks a freshly constructed operation that has no injected state
    • getFormatMediaTypes makes an extension's f values work like f=json. Core's own ids are resolved first and win
    • Shared across requests, so thread-safe. Closeable, closed by the listener with the context
  • CollectionInfo

    • setItemType (new) lets an extension publish a collection that is not a feature collection. The extension builds the whole CollectionInfo, since only it knows the links, extent and item type
  • OpenAPISchemaContributor / OpenAPISchemaContributors

    • Second ServiceLoader SPI, letting an extension describe its own response models without the generator naming them. First non-null answer wins
  • The 400 for an invalid f= now lists every accepted value: metadata formats, configured output formats and extension formats. It previously listed only the metadata formats, so clients matching on the old message text will see a different list.

  • With no extension on the classpath nothing else changes.

@jampukka
jampukka merged commit c48987f into nlsfi:main Oct 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant