Interface Callbacks<BeanType>

All Known Implementing Classes:
AbstractCallbacks

public interface Callbacks<BeanType>
Callbacks are hooks that are being called when beans are manipulated through the GenericQueryManager or other query managers that are based on it. They can either be implemented directly by implementing this interface, or they can be provided by a bean by implementing the CallbacksProvider interface.

This can for example be used to delete associated and dependent objects when delete is called (by implementing beforeDelete(int)), or to clear a cache when an object has been modified (by implementing afterSave(Object, boolean) and afterDelete(int, boolean)).

The return value of callbacks can be used to cancel actions. When the before* callbacks return false, the associated actions are cancelled. When the after* callbacks return false, the execution of the action is interrupted at that step and no further callbacks will be called.

Since:
1.0
See Also:
  • Method Details

    • beforeValidate

      boolean beforeValidate(BeanType object)
      Parameters:
      object - the bean instance that will be validated
      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • beforeInsert

      boolean beforeInsert(BeanType object)
      Is called before GenericQueryManager.insert(Object), or in the beginning of GenericQueryManager.save(Object) if a new bean is being saved.
      Parameters:
      object - the bean instance that will be inserted
      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • beforeDelete

      boolean beforeDelete(int objectId)
      Parameters:
      objectId - the id of the bean that will be deleted
      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • beforeSave

      boolean beforeSave(BeanType object)
      Parameters:
      object - the bean instance that will be saved
      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • beforeUpdate

      boolean beforeUpdate(BeanType object)
      Is called before GenericQueryManager.update(Object), or in the beginning of GenericQueryManager.save(Object) if an existing bean is being saved.
      Parameters:
      object - the bean instance that will be updated
      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • afterValidate

      boolean afterValidate(BeanType object)
      Parameters:
      object - the bean instance that was validated
      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • afterInsert

      boolean afterInsert(BeanType object, boolean success)
      Is called after GenericQueryManager.insert(Object), or at the end of GenericQueryManager.save(Object) if a new bean was saved.
      Parameters:
      object - the bean instance that was inserted
      success - true if the insert was successful; or

      false otherwise

      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • afterDelete

      boolean afterDelete(int objectId, boolean success)
      Parameters:
      objectId - the id of the bean instance that was deleted
      success - true if the delete was successful; or

      false otherwise

      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • afterSave

      boolean afterSave(BeanType object, boolean success)
      Parameters:
      object - the bean instance that was saved
      success - true if the save was successful; or

      false otherwise

      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • afterUpdate

      boolean afterUpdate(BeanType object, boolean success)
      Is called after GenericQueryManager.update(Object), or at the end of GenericQueryManager.save(Object) if an existing bean was saved.
      Parameters:
      object - the bean instance that was updated
      success - true if the update was successful; or

      false otherwise

      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0
    • afterRestore

      boolean afterRestore(BeanType object)
      Parameters:
      object - the bean instance that was restored
      Returns:
      true if the execution should continue as normal; or

      false if the execution should be interrupted

      Since:
      1.0