Interface InterceptorContext
-
- All Known Implementing Classes:
DefaultModelServiceInterceptorContext,InterceptorContextAdapter
public interface InterceptorContextContext provided to allInterceptorinstances. Provides information about other models in the current context as well as useful utility methods.
Every instance ofInterceptorContexthas a default operation for elements registered withregisterElement(java.lang.Object, java.lang.Object)orregisterElement(java.lang.Object).
For instances ofInterceptorContextthat are passed to interceptors duringModelService.save(java.lang.Object)andModelService.saveAll()the default operation isPersistenceOperation.SAVE.
For instances ofInterceptorContextthat are passed to interceptors duringModelService.remove(Object)andModelService.removeAll(java.util.Collection)the default operation isPersistenceOperation.DELETE.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description booleancontains(java.lang.Object model)Deprecated.since ages - usecontains(java.lang.Object, PersistenceOperation)booleancontains(java.lang.Object model, PersistenceOperation operation)Checks is the given model is already registered in this InterceptorContext with the given operation.booleanexists(java.lang.Object model)java.util.Set<java.lang.Object>getAllRegisteredElements()Deprecated.since ages - usegetElementsRegisteredFor(PersistenceOperation)java.lang.ObjectgetAttribute(java.lang.String key)java.util.Map<java.lang.String,java.util.Set<java.util.Locale>>getDirtyAttributes(java.lang.Object model)Returns a map with all modified attribute qualifiers for the given model.java.util.Set<java.lang.Object>getElementsRegisteredFor(PersistenceOperation operation)ModelServicegetModelService()java.lang.ObjectgetSource(java.lang.Object model)Deprecated.since agesbooleanisModified(java.lang.Object model)booleanisModified(java.lang.Object model, java.lang.String attribute)booleanisNew(java.lang.Object model)Tells if the model has been created and has not been saved yet.booleanisRemoved(java.lang.Object model)voidregisterElement(java.lang.Object model)Register the givenmodelto this InterceptorContext using the InterceptorContext's default operation.voidregisterElement(java.lang.Object model, java.lang.Object source)Deprecated.voidregisterElementFor(java.lang.Object model, PersistenceOperation operation)Register the givenmodelto this InterceptorContext using the given operation.voidsetAttribute(java.lang.String key, java.lang.Object value)
-
-
-
Method Detail
-
getSource
@Deprecated java.lang.Object getSource(java.lang.Object model)
Deprecated.since ages- Parameters:
model- passed in- Returns:
- source for model 'cached' into context instance, see also
DefaultModelService.get(Object)
-
getAllRegisteredElements
@Deprecated java.util.Set<java.lang.Object> getAllRegisteredElements()
Deprecated.since ages - usegetElementsRegisteredFor(PersistenceOperation)- Returns:
- unmodifiable set of models registered using the default operation
-
getElementsRegisteredFor
java.util.Set<java.lang.Object> getElementsRegisteredFor(PersistenceOperation operation)
- Returns:
- unmodifiable set of models registered for the given operation
-
registerElement
@Deprecated void registerElement(java.lang.Object model, java.lang.Object source)Deprecated.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
void registerElement(java.lang.Object model)
Register the givenmodelto this InterceptorContext using the InterceptorContext's default operation.- Parameters:
model- the model to be registered.
-
registerElementFor
void registerElementFor(java.lang.Object model, PersistenceOperation operation)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 boolean contains(java.lang.Object model)
Deprecated.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
boolean contains(java.lang.Object model, PersistenceOperation operation)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
boolean isNew(java.lang.Object model)
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
boolean exists(java.lang.Object model)
- Parameters:
model- model instance to be searched for- Returns:
- result of the
ModelConverter.exists(Object)for registered model converter for passed model
-
isModified
boolean isModified(java.lang.Object model)
- Parameters:
model- model instance to be searched for- Returns:
- result of the
ModelConverter.isModified(Object)for registered model converter for passed model
-
isModified
boolean isModified(java.lang.Object model, java.lang.String attribute)- 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
boolean isRemoved(java.lang.Object model)
- 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
java.lang.Object getAttribute(java.lang.String key)
- Parameters:
key- attribute name- Returns:
- attribute for key
-
setAttribute
void setAttribute(java.lang.String key, java.lang.Object value)- Parameters:
key- attribute namevalue- attribute passed into context
-
getDirtyAttributes
java.util.Map<java.lang.String,java.util.Set<java.util.Locale>> getDirtyAttributes(java.lang.Object model)
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.
-
-