Package com.sap.cds.services
Interface EventContext
- All Known Subinterfaces:
ActionAccessEventContext
,ApplicationPreparedEventContext
,ApplicationStoppedEventContext
,CalcWhereConditionEventContext
,CdsCreateEventContext
,CdsDeleteEventContext
,CdsReadEventContext
,CdsUpdateEventContext
,CdsUpsertEventContext
,CloudEventMessageEventContext
,ConfigChangeLogContext
,DataAccessLogContext
,DataModificationLogContext
,DependenciesEventContext
,DraftCancelEventContext
,DraftCreateEventContext
,DraftEditEventContext
,DraftGcEventContext
,DraftNewEventContext
,DraftPatchEventContext
,DraftPrepareEventContext
,DraftSaveEventContext
,EntityAccessEventContext
,ErrorResponseEventContext
,FunctionAccessEventContext
,GetRestrictionEventContext
,MessagingErrorEventContext
,ModelChangedEventContext
,OutboxMessageEventContext
,PdfExportEventContext
,ReadProviderTenantEventContext
,ReadTenantsEventContext
,SecurityLogContext
,ServiceAccessEventContext
,SubscribeEventContext
,TopicMessageEventContext
,UnsubscribeEventContext
,UpgradeEventContext
public interface EventContext
The
It gives access to objects defined by the global context of the event, for example the
Most importantly it gives access to the information about the actual event (
The
EventContext
provides information about the event that is emitted via Service.emit(EventContext)
.
It summarizes all information required by the handlers
implementing the event and required by the framework to process the emitting of the event.
It gives access to objects defined by the global context of the event, for example the
CdsModel
or the ServiceCatalog
.
Furthermore it gives access to objects which are request-bound, like for example the UserInfo
.
Most importantly it gives access to the information about the actual event (
getEvent()
) and the targeted service (getService()
) and entity (getTarget()
).
The
EventContext
interface is the super-interface of more specialized EventContext
interfaces. Examples for these are CdsReadEventContext
or CdsCreateEventContext
.
The generic interface provides access to all input and output parameters of an event via the get(String)
and put(String, Object)
methods.
However the key and type of these parameters has to be known by the implementation. When using the specialized interfaces this is taken care of.
The as(Class)
method can be used to overlay an existing generic EventContext
with a more specialized EventContext
.-
Method Summary
Modifier and TypeMethodDescription<T extends EventContext>
TOverlays an existingEventContext
with a specialized EventContext interface (for exampleCdsReadEventContext
orCdsCreateEventContext
) The specialized EventContext provides typed access to the input and output parameters of the event.static <T extends EventContext>
TCreates a new specializedEventContext
of concrete typeT
static EventContext
Creates a newEventContext
Returns an input or output parameter, which was stored under the given key.Returns the underlyingCdsRuntime
.getEvent()
com.sap.cds.reflect.CdsModel
getModel()
Returns the tenant-specificCdsModel
.Returns theService
(Consumption API) of the service, targeted by theEventContext
.Returns theServiceCatalog
, populated with all availableService
instances.com.sap.cds.reflect.CdsEntity
Returns the Reflection APICdsEntity
, for which theEventContext
was created.boolean
keySet()
Returns an unmodifiableset
containing the keys of all parameters.void
Stores an input or output parameter under a given key Whenever possible it is preferred to use specialized EventContext interfaces to guarantee correct and typed access.void
Marks theEventContext
as completed.
-
Method Details
-
create
Creates a newEventContext
- Parameters:
event
- the name of the evententityName
- the name of the entity- Returns:
- the
EventContext
-
create
Creates a new specializedEventContext
of concrete typeT
- Type Parameters:
T
- the specializedEventContext
type- Parameters:
clazz
- theClass
of the specializedEventContext
typeentityName
- the name of the entity- Returns:
- the specialized
EventContext
-
getCdsRuntime
CdsRuntime getCdsRuntime()Returns the underlyingCdsRuntime
.- Returns:
- The
CdsRuntime
instance.
-
getModel
com.sap.cds.reflect.CdsModel getModel()Returns the tenant-specificCdsModel
. The tenant is determined based on the request-context and the tenant information available inUserInfo
. If no tenant is specified, or if no tenant-specific model exists, the base model is returned.- Returns:
- the (tenant-specific)
CdsModel
-
getServiceCatalog
ServiceCatalog getServiceCatalog()Returns theServiceCatalog
, populated with all availableService
instances.- Returns:
- the
ServiceCatalog
-
getParameterInfo
ParameterInfo getParameterInfo()- Returns:
- the request-dependent
ParameterInfo
-
getUserInfo
UserInfo getUserInfo()- Returns:
- the request-dependent
UserInfo
-
getAuthenticationInfo
AuthenticationInfo getAuthenticationInfo()- Returns:
- the request-dependent
AuthenticationInfo
-
getFeatureTogglesInfo
FeatureTogglesInfo getFeatureTogglesInfo()- Returns:
- the request-dependent
FeatureTogglesInfo
-
getMessages
Messages getMessages()- Returns:
- the
Messages
container for this request
-
getChangeSetContext
ChangeSetContext getChangeSetContext()- Returns:
- the currently active
ChangeSetContext
-
getService
Service getService()Returns theService
(Consumption API) of the service, targeted by theEventContext
. This is the service, on which theService.emit(EventContext)
method (or specialized Consumption API) was called.- Returns:
- the
Service
(Consumption API) of the service, targeted by theEventContext
.
-
getEvent
String getEvent()- Returns:
- the name of the emitted event
-
getTarget
com.sap.cds.reflect.CdsEntity getTarget()Returns the Reflection APICdsEntity
, for which theEventContext
was created. If theEventContext
was created without any entity information from theCdsModel
,null
will be returned.- Returns:
- the
CdsEntity
, ornull
if theEventContext
was created without entity information.
-
as
Overlays an existingEventContext
with a specialized EventContext interface (for exampleCdsReadEventContext
orCdsCreateEventContext
) The specialized EventContext provides typed access to the input and output parameters of the event. It operates directly on the originalEventContext
. Therefore changes performed on the specialized EventContext instance, returned by this method, are written through to the original instance. In the same way changes to the originalEventContext
affect the specialized EventContext instance, returned by this method.- Type Parameters:
T
- the type of the specialized EventContext- Parameters:
clazz
- The interface representing the specialized EventContext- Returns:
- an instance of the specialized EventContext, providing typed access to this
EventContext
instance
-
get
Returns an input or output parameter, which was stored under the given key. Whenever possible it is preferred to use specialized EventContext interfaces to guarantee correct and typed access.- Parameters:
key
- the key of the parameter- Returns:
- the parameter,
null
if there was no value stored under the given key.
-
put
Stores an input or output parameter under a given key Whenever possible it is preferred to use specialized EventContext interfaces to guarantee correct and typed access.- Parameters:
key
- the key of the parametervalue
- the parameter value
-
keySet
Returns an unmodifiableset
containing the keys of all parameters.- Returns:
- an unmodifiable
set
containing the keys of all parameters. - Since:
- 1.17.0
- See Also:
-
setCompleted
void setCompleted()Marks theEventContext
as completed. As soon as aEventContext
is completed, theService.emit(EventContext)
processing phases BEFORE and ON are finished. Setting anEventContext
to completed, which is already completed has no effect. -
isCompleted
boolean isCompleted()- Returns:
- true, if
setCompleted()
was called at least once.
-