Interface InterceptorContext

All Known Implementing Classes:
DefaultModelServiceInterceptorContext, InterceptorContextAdapter

public interface InterceptorContext
Context provided to all 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.
  • Method Details

    • getSource

      @Deprecated(since="ages", forRemoval=true) Object getSource(Object model)
      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(since="ages", forRemoval=true) Set<Object> getAllRegisteredElements()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      unmodifiable set of models registered using the default operation
    • getElementsRegisteredFor

      Set<Object> getElementsRegisteredFor(PersistenceOperation operation)
      Returns:
      unmodifiable set of models registered for the given operation
    • registerElement

      @Deprecated(since="ages", forRemoval=true) void registerElement(Object model, Object source)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Register the given model to 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(Object model)
      Register the given model to this InterceptorContext using the InterceptorContext's default operation.
      Parameters:
      model - the model to be registered.
    • registerElementFor

      void registerElementFor(Object model, PersistenceOperation operation)
      Register the given model to 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(since="ages", forRemoval=true) boolean contains(Object model)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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(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 for
      operation - the operation to be searched for
      Returns:
      true if context interceptor contains model
    • isNew

      boolean isNew(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(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(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(Object model, String attribute)
      Parameters:
      model - model instance to be searched for
      attribute - 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(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

      Object getAttribute(String key)
      Parameters:
      key - attribute name
      Returns:
      attribute for key
    • setAttribute

      void setAttribute(String key, Object value)
      Parameters:
      key - attribute name
      value - attribute passed into context
    • getDirtyAttributes

      Map<String,Set<Locale>> getDirtyAttributes(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 is null the 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

      Returns the InterceptorContext.TransientStorage which can be used to share attributes among all interceptors involved in the ModelService operation.
      Returns:
      a storage attached to this InterceptorContext