Class CDORestService
java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.lifecycle.Lifecycle
org.eclipse.emf.cdo.server.rest.CDORestService
- All Implemented Interfaces:
org.eclipse.net4j.util.event.INotifier, org.eclipse.net4j.util.event.INotifier.INotifier2, org.eclipse.net4j.util.lifecycle.IDeactivateable, org.eclipse.net4j.util.lifecycle.ILifecycle, org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivation
public final class CDORestService
extends org.eclipse.net4j.util.lifecycle.Lifecycle
The embeddable entry point for the versioned CDO graph REST API. It dispatches transport-neutral requests through an
IRepositoryProvider, which explicitly controls the repository names and aliases exposed to REST callers.
The service does not authenticate HTTP callers or enforce CDO authorization; operators are responsible for suitable
network and HTTP access protection.
Activation makes REST requests available, starts transports added with addTransport(CDORestTransport), and
creates long-lived internal repository contexts as repositories are first requested. Requests through a
customer-owned transport require an activated service; activate the service without adding an owned transport, then
call service(CDORestRequest, CDORestResponse) for each request.
- Author:
- Eike Stepper
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.event.Notifier.CancelationNested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle
org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivationNested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier
org.eclipse.net4j.util.event.INotifier.INotifier2 -
Field Summary
Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
USE_LABEL -
Constructor Summary
ConstructorsConstructorDescriptionCDORestService(Map<String, IRepository> repositories) Creates a REST service for an explicit alias-to-repository mapping.CDORestService(Map<String, IRepository> repositories, CDORestConfiguration configuration) Creates a REST service for an explicit alias-to-repository mapping with the supplied configuration.CDORestService(IRepositoryProvider repositoryProvider) Creates a REST service that resolves repository routes through the supplied provider.CDORestService(IRepositoryProvider repositoryProvider, CDORestConfiguration configuration) Creates a REST service with an explicit configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTransport(CDORestTransport transport) Adds a transport that follows this service's lifecycle.protected voidprotected voidReturns the repository provider used for REST lookup and optional name enumeration.voidservice(CDORestRequest request, CDORestResponse response) Handles one request synchronously.Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeActivate, doBeforeDeactivate, doCancelActivation, dump, getLifecycleState, isActive, isDeferredActivation, toStringMethods inherited from class org.eclipse.net4j.util.event.Notifier
addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.net4j.util.event.INotifier
addListener, getListeners, hasListeners, removeListener
-
Constructor Details
-
CDORestService
Creates a REST service for an explicit alias-to-repository mapping. The mapping is copied at construction time, and subsequent changes to the caller's map cannot alter repository exposure. The service uses the effective defaults from a newCDORestConfiguration.- Parameters:
repositories- REST-visible names mapped to active CDO repositories; names must contain only letters, digits, dots, underscores, and hyphens- Throws:
IllegalArgumentException- if a repository name is not a valid route segmentNullPointerException- if the map, a name, or a repository isnull
-
CDORestService
Creates a REST service that resolves repository routes through the supplied provider. An enumerable provider may expose one or more aliases through the repository listing endpoint. A provider that does not implement name enumeration can still resolve direct repository routes, but the listing endpoint reports that enumeration is unsupported. Dynamic providers are consulted for each request and must make their lookup operations safe for concurrent calls. The service uses the effective defaults from a newCDORestConfiguration.- Parameters:
repositoryProvider- the provider used for direct repository lookup and optional name enumeration- Throws:
IllegalArgumentException- if an initially enumerated name is not a valid REST route segmentNullPointerException- if the provider isnull
-
CDORestService
Creates a REST service with an explicit configuration. The service copies it during construction, so later changes to the supplied instance do not affect the service.- Parameters:
repositoryProvider- the provider used for direct repository lookup and optional name enumerationconfiguration- the configuration to copy for this service- Throws:
IllegalArgumentException- if an initially enumerated name is not a valid REST route segmentNullPointerException- if the provider or configuration isnull
-
CDORestService
Creates a REST service for an explicit alias-to-repository mapping with the supplied configuration. The mapping is copied at construction time, and later changes to the caller's map cannot alter repository exposure.- Parameters:
repositories- REST-visible names mapped to CDO repositoriesconfiguration- the configuration to copy for this service- Throws:
IllegalArgumentException- if a repository name is not a valid route segmentNullPointerException- if the map, configuration, a name, or a repository isnull
-
-
Method Details
-
getRepositoryProvider
Returns the repository provider used for REST lookup and optional name enumeration.- Returns:
- the configured repository provider
-
addTransport
Adds a transport that follows this service's lifecycle. Configure it before activating the service; the service starts and stops every added transport.- Parameters:
transport- the transport to start and stop with this service- Throws:
IllegalStateException- if this service has already been activatedNullPointerException- if the transport isnull
-
service
Handles one request synchronously. JSON responses are streamed to the supplied output stream. If the transport has already committed a response when serialization fails, the exception is propagated and no second document is appended. The request and response streams remain owned by the surrounding HTTP adapter.- Parameters:
request- the normalized request relative to the configured mount pointresponse- the transport response adapter- Throws:
IOException- if request parsing or response streaming fails
-
doActivate
-
doDeactivate
-