Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.errai.demo.grocery.client.shared;
 
A translator that receives JPA entity lifecycle events and refires them as CDI events.

Ideally there would be no need for this class: Errai's EntityManager could just fire these qualified CDI events when it's firing the less-usable-from-CDI JPA events.

Author(s):
jfuerth
public class EventTranslator {
  private static EventTranslator INSTANCE;
  private void initInstance() {
     = this;
  }
  
  // ========= Item ==========
  
  private @Inject @New Event<ItemnewItemEvent;
  void fireNewItemEvent(Item i) {
    .fire(i);
  }
  void fireUpdatedItemEvent(Item i) {
  }
  void fireRemovedItemEvent(Item i) {
  }
  public static class ItemLifecycleListener {
    @PostPersist
    private void onPostPersist(Item i) {
    }
    @PostUpdate
    private void onPostUpdate(Item i) {
    }
    
    @PostRemove
    private void onPostRemove(Item i) {
    }
  }
New to GrepCode? Check out our FAQ X