Interface InterceptorContext
- All Known Implementing Classes:
DefaultModelServiceInterceptorContext,InterceptorContextAdapter
public interface InterceptorContext
Context provided to all
Every instance of
For instances of
For instances of
Interceptor instances. Provides information about other models in the current context
as well as useful utility methods. Every instance of
InterceptorContext has a default operation for elements registered with
registerElement(java.lang.Object, java.lang.Object) or
registerElement(java.lang.Object). For instances of
InterceptorContext that are passed to interceptors during
ModelService.save(java.lang.Object) and
ModelService.saveAll() the default operation is
PersistenceOperation.SAVE. For instances of
InterceptorContext that are passed to interceptors during
ModelService.remove(Object) and
ModelService.removeAll(java.util.Collection) the default operation is
PersistenceOperation.DELETE.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents a transient storage for a singleInterceptorContext. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated, for removal: This API element is subject to removal in a future version.booleancontains(Object model, PersistenceOperation operation) Checks is the given model is already registered in this InterceptorContext with the given operation.booleanDeprecated, for removal: This API element is subject to removal in a future version.since ages - usegetElementsRegisteredFor(PersistenceOperation)getAttribute(String key) getDirtyAttributes(Object model) Returns a map with all modified attribute qualifiers for the given model.getElementsRegisteredFor(PersistenceOperation operation) Deprecated, for removal: This API element is subject to removal in a future version.since agesReturns theInterceptorContext.TransientStoragewhich can be used to share attributes among all interceptors involved in theModelServiceoperation.booleanisModified(Object model) booleanisModified(Object model, String attribute) booleanTells if the model has been created and has not been saved yet.booleanvoidregisterElement(Object model) Register the givenmodelto this InterceptorContext using the InterceptorContext's default operation.voidregisterElement(Object model, Object source) Deprecated, for removal: This API element is subject to removal in a future version.voidregisterElementFor(Object model, PersistenceOperation operation) Register the givenmodelto this InterceptorContext using the given operation.voidsetAttribute(String key, Object value)
-
Method Details
-
getSource
Deprecated, for removal: This API element is subject to removal in a future version.since ages- Parameters:
model- passed in- Returns:
- source for model 'cached' into context instance, see also
DefaultModelService.get(Object)
-
getAllRegisteredElements
Deprecated, for removal: This API element is subject to removal in a future version.since ages - usegetElementsRegisteredFor(PersistenceOperation)- Returns:
- unmodifiable set of models registered using the default operation
-
getElementsRegisteredFor
- Returns:
- unmodifiable set of models registered for the given operation
-
registerElement
Deprecated, for removal: This API element is subject to removal in a future version.Register the givenmodelto this InterceptorContext using the InterceptorContext's default operation.- Parameters:
model- the model to be registered.source- the source of the model (optional)
-
registerElement
Register the givenmodelto this InterceptorContext using the InterceptorContext's default operation.- Parameters:
model- the model to be registered.
-
registerElementFor
Register the givenmodelto this InterceptorContext using the given operation.- Parameters:
model- the model to be registered.operation- the operation to be performed with the given model
-
contains
Deprecated, for removal: This API element is subject to removal in a future version.since ages - usecontains(java.lang.Object, PersistenceOperation)Checks is the given model is already registered in this InterceptorContext with the default operation.- Parameters:
model- model instance to be searched for- Returns:
- true if context interceptor contains model
-
contains
Checks is the given model is already registered in this InterceptorContext with the given operation.- Parameters:
model- model instance to be searched foroperation- the operation to be searched for- Returns:
- true if context interceptor contains model
-
isNew
Tells if the model has been created and has not been saved yet.- Parameters:
model- model instance to be searched for- Returns:
- result of the
ModelConverter.isNew(Object)for registered model converter for passed model
-
exists
- Parameters:
model- model instance to be searched for- Returns:
- result of the
ModelConverter.exists(Object)for registered model converter for passed model
-
isModified
- Parameters:
model- model instance to be searched for- Returns:
- result of the
ModelConverter.isModified(Object)for registered model converter for passed model
-
isModified
- Parameters:
model- model instance to be searched forattribute- attribute name to be searched for- Returns:
- result of the
ModelConverter.isModified(Object, String)for registered model converter for passed model , attribute
-
isRemoved
- Parameters:
model- model instance to be searched for- Returns:
- result of the
ModelConverter.isRemoved(Object)for registered model converter for passed model
-
getModelService
ModelService getModelService()- Returns:
- model service instance for context instance
-
getAttribute
- Parameters:
key- attribute name- Returns:
- attribute for key
-
setAttribute
- Parameters:
key- attribute namevalue- attribute passed into context
-
getDirtyAttributes
Returns a map with all modified attribute qualifiers for the given model. The keys are all localized and non-localized attribute qualifier which were modified. If the map value isnullthe key is a non-localized attribute qualifier else the map value contains the locale in which language the localized attribute was modified.- Parameters:
model- the new (not saved) model- Returns:
- a map with all modified attribute qualifier.
-
getTransientStorage
InterceptorContext.TransientStorage getTransientStorage()Returns theInterceptorContext.TransientStoragewhich can be used to share attributes among all interceptors involved in theModelServiceoperation.- Returns:
- a storage attached to this
InterceptorContext
-
contains(java.lang.Object, PersistenceOperation)