Start from behavior that needs independent testing or ownership, such as content lookup or an external API call. A bundle boundary and a service boundary are related decisions, but they do not need to be identical.
AEM OSGi Service Architecture: Boundaries, Configuration and Testability.
A maintainable AEM component should not own every integration decision it triggers. This representative architecture separates Sling presentation models from Java service contracts, with OSGi configuration and dependency behavior treated as part of the application design.
Representative engineering design, not a verified client delivery record. Implementation steps and validation checks describe the proposed approach; no measured results are claimed.
Place business behavior behind explicit interfaces
Hidden dependencies make components difficult to change
When a model owns request parsing, repository access, remote calls and error mapping, changes become hard to isolate. Configuration assumptions can also remain invisible until a service fails to activate in another environment.
Keep presentation, orchestration and integration distinct
Use Sling Models for presentation-facing data, application services for use-case behavior and adapters for external dependencies. Declare OSGi references and configuration expectations explicitly rather than locating dependencies ad hoc.
Make dependency and configuration behavior testable
Define interface inputs, outputs and failure semantics before binding an implementation. Validate required configuration and handle lifecycle changes deliberately, without storing request-specific state in shared service instances.
- Keep external client details behind a replaceable adapter.
- Review required versus optional references against actual fallback behavior.
- Test service logic separately from model adaptation and runtime activation.
Use an optional dependency only when degraded behavior is defined
An optional reference avoids one activation constraint but moves responsibility into application logic. Define what callers receive when the dependency is unavailable rather than silently returning incomplete data.
More abstractions can also obscure behavior
Not every method needs a service interface. Introduce boundaries where they isolate a real dependency, business contract or lifecycle concern, and keep simple transformations easy to follow.
Check both isolated behavior and OSGi activation
Unit tests and container-level verification answer different questions.
- Test dependency failure and configuration edge cases through the interface.
- Verify expected reference and activation behavior on the target AEM baseline.
- Exercise Sling adaptation with representative request and resource inputs.
A service contract includes failure behavior
Readable interfaces describe what happens when configuration or dependencies are absent. That clarity supports upgrades and diagnostics without turning this page into either an upgrade guide or an incident playbook.
Technical references
These sources document product behavior. The design and validation approach above are engineering proposals, not claims made by the vendors.
Working through a similar platform problem?
This representative case study explores technical trade-offs and architectural decisions for a specific engineering scenario. If you are planning a similar migration, modernization, or integration, let's discuss the engineering approach.
Start a conversation