REST ArchitectureArticle Link |
![]() |
This article describes how the CDO REST service is divided into bundles, how requests use repository sessions, and how graph reads, commits, and transports fit into the existing CDO server lifecycle. Deployment choices are covered in the Operator's Guide; endpoint paths and JSON schemas are documented by the REST API Reference.
The REST feature is an optional extension of the CDO server. The transport-neutral org.eclipse.emf.cdo.server.rest bundle owns the request and response contracts, service, dispatcher, revision graph processing, JSON processing, OpenAPI document, and repository configuration extension. It depends on the CDO server, Net4j utility, and Jackson Core bundles; it has no Jetty, Jakarta Servlet, or Javax Servlet references. The existing CDO server bundle has no REST dependency.
The org.eclipse.emf.cdo.server.rest.jetty bundle supplies a Jetty Core handler and an optional standalone server. The org.eclipse.emf.cdo.server.rest.servlet.jakarta bundle supplies a thin Jakarta Servlet adapter for a host Servlet container. The adapters depend on the REST core and on their respective host APIs; neither adapter depends on the other. Feature installation and Maven artifact coordinates are covered in the Operator's Guide. The standalone Jetty server can additionally include explicitly configured static resource contexts in its Jetty handler collection; those public contexts are outside the transport-neutral REST service and do not inherit repository authentication or object permissions. See the Operator's Guide for configuration.
A service resolves route aliases through its configured IRepositoryProvider. The built-in ContainerRepositoryProvider spans its managed container, whereas the XML extension creates a provider containing only its configured aliases. A dynamic provider must make concurrent lookups safe. Provider selection and repository exposure are described in the Operator's Guide.
The dispatcher creates one long-lived, protocol-less internal session and one view-ID allocator for each repository instance it uses. Contexts are created lazily, and different aliases for the same repository share a context. Each request owns its view or transaction, revision state, and StoreThreadLocal accessor. Reads do not open a view or transaction unless needed; writes use a fresh ordinary transaction. The allocator reuses positive IDs but never reuses view or transaction objects.
A request lease prevents the REST context itself from disposing its session while that request is using it. The repository has independent ownership of its SessionManager; repository shutdown can deactivate that manager and invalidate a leased session. Shutdown does not wait for HTTP requests to finish. REST-created protocol-less sessions use a per-thread user ID holder, so concurrent HTTP worker threads do not overwrite one another's authenticated identities. Each request restores its previous thread-local identity while releasing its StoreThreadLocal scope. The Operator's Guide explains repository exposure, per-alias authentication, and additional network controls.
Graph reads resolve revisions through the repository's CDORevisionManager request API. This reuses the canonical revision cache, store-backed revision loader, branch manager, and package registry. The serializer reads revision values and CDO IDs directly; it does not create client sessions, views, EObjects, ResourceSets, or EMF resources. Requested list ranges are loaded through the repository's chunk-loading methods before they are emitted, so CDORevisionUtil.UNLOADED and other partial-list state do not appear in the response.
Each revision is checked through the shared session's permission manager at the selected branch point before its features are loaded or traversed. A NONE permission yields a reduced representation: denied features and ordinary metadata are omitted, while CDO resource path features remain available for namespace navigation. The effective permission can be requested as optional metadata. Permission decisions are request-scoped and are never stored on shared canonical revisions, so different users can receive different projections of one cached revision. Identity retention reuses security state but does not cache authentication decisions or bypass permission-cache invalidation.
For a revision that uses EMF containment proxies for cross-resource containment, the direct resource association and the logical containing object are independent: both resource and container metadata can be present. This reflects the CDO revision fields and does not attempt to reproduce EObject.eResource() behavior. The REST API Reference documents the serialized metadata fields. Audit snapshot behavior and historical-read availability are described in the Operator's Guide.
Model attribute values use Ecore's data-type conversion rules, including registered conversions for custom EDataTypes. Serialized forms and precision rules are defined in the REST API Reference.
Responses are streamed with Jackson Core after a bounded revision preflight. The REST API Reference defines graph projection and response shape; service limit configuration is covered in the Operator's Guide.
REST modifications operate on private copies of affected revisions; canonical revisions in the repository cache are never edited. Revision comparison produces the ordinary CDO deltas. New objects are created by the repository revision factory with temporary CDO IDs, and the service prepares an InternalCommitContext for submission through InternalRepository.commit. The request's effective user ID is captured by the ordinary commit context before asynchronous store work begins. The normal commit path remains responsible for timestamps, store transactions, ID allocation and mapping, conflict detection, write handlers, structural checks, auditing, branching, and commit notifications. REST does not write through a store accessor directly.
The REST processor completes feature validation and EMF-style opposite and containment maintenance before the commit context receives its deltas. A client can refer to objects later in the same batch because batch-local IDs are reserved before links are applied. New objects that remain after the batch must be attached to a CDO resource. CDO resource-node and store checks remain responsible for namespace uniqueness; REST checks path segments and lets the repository enforce resource names. Changes to namespace nodes clear the repository's resource-path cache through normal commit notifications.
Removing a containment edge follows normal CDO transaction processing. A descendant moved elsewhere before its former ancestor is detached remains attached, and incoming references to detached objects follow the repository's configured referential-integrity behavior. Reparenting updates resource membership and writable EOpposites in the same batch. A new object detached again before commit is omitted from the commit's new-object and detached-object data. Client-supplied expectedVersions add object-version preconditions to normal conflict detection, including for namespace and opposite revisions changed indirectly by an operation. Application-specific validation remains available through the repository's commit handlers.
List delta comparison runs against private revision copies because the list analyzer uses its origin list as working storage. Only touched features are compared, so an unrelated partial list need not be loaded. Invalid operations reject the batch before commit, and a repository rollback leaves no partial batch visible. REST does not bypass relationship maintenance, containment validation, conflict checks, or ordinary repository commit processing. User-facing operation details and commit preconditions are defined by the REST API Reference.
Both transport adapters call the same CDORestService, so routing, query parsing, JSON processing, error handling, and revision graph behavior remain in the REST core. The Jakarta Servlet adapter is mounted by its host and owns no listener, connector, thread pool, TLS, authentication, or container lifecycle. It uses the HttpServlet request and response APIs available in Servlet 6.0; the bundle imports the jakarta.servlet packages in the [6.0,7.0) range. It copies the host request's authenticated Principal into the transport-neutral request so the built-in principal authenticator can use a trusted identity without trusting arbitrary headers. The workspace integration suite has sent real HTTP requests through Jetty EE 11 with Servlet 6.1 and compared its responses with the native Jetty handler.
CDORestJettyHandler is a blocking Jetty Core handler and does not own its server. It can be placed beneath a customer-selected ContextHandler alongside other handlers. The standalone CDORestJettyServer owns and stops only the server instance it creates. Synchronous revision and JSON work is declared blocking to Jetty, and the request callback completes after the final response write. If writing fails after the response is committed, the callback fails instead of appending a second Problem Details document.
The REST core contributes a RepositoryConfigurator.TreeExtension; managed-container factories create the configured transports, and the Jetty bundle registers its standalone server through AnnotationFactory. The extension registers each service during XML configuration, before repository activation, so a transport startup failure is reported as a configuration failure. Managed-container shutdown removes its listeners and stops the service and its transport.
HTTP errors use RFC 9457 Problem Details with safe client-visible details and no implementation stack trace. After a streamed response is committed, a later failure closes the response rather than appending a second JSON document. Error fields and status codes are listed in the REST API Reference.