Annotation Interface StoreReturn


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface StoreReturn
An around annotation for methods which simplifies storing objects in an associated Store Manager.

This annotation will wrap the decorated method to ensure thread isolation.

You can store a Method return statement.

A method such as this:

 @StoreReturn
 protected Customer updateCustomer(String id, CustomerSave customerSave) {
     Customer c = data().getCustomers().get(id);
     if (c != null) {
         c.setFirstName(customerSave.getFirstName());
         c.setLastName(customerSave.getLastName());
         return c;
     }
     return null;
 }
 

Becomes

 protected Customer updateCustomer(String id, CustomerSave customerSave) {
     XThreads.executeSynchronized(() -> {
         Customer c = data().getCustomers().get(id);
         if (c != null) {
             c.setFirstName(customerSave.getFirstName());
             c.setLastName(customerSave.getLastName());
             embeddedStorageManager.store(c);
             return c;
         }
         return null;
     }
 }
 
Since:
1.0.0
Author:
Sergio del Amo
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The optional name qualifier of the Storage Manager to use.
    The Storing strategy.
  • Element Details

    • name

      @AliasFor(member="value") String name
      The optional name qualifier of the Storage Manager to use. If your application only have a MicroStream instance, this is not required
      Returns:
      The name qualifier of the Storage Manager to use.
      Default:
      ""
    • strategy

      StoringStrategy strategy
      The Storing strategy. Defaults to Lazy.
      Returns:
      Storing Strategy;
      Default:
      LAZY