static Persistable persistenceCapableFor(InstanceLifecycleEvent event) { return (Persistable)event.getSource(); }
/** * Returns the persistent instance involved in the event. * * @return The persistent instance involved in the event, or null if there * was none. * * @see "Section 12.15, Java Data Objects 2.0 Specification" */ public Object getPersistentInstance() { switch (getEventType()) { case DETACH: return target == null ? getSource() // preDetach: source is persistent instance : getTarget(); // postDetach: target is persistent instance case ATTACH: return target == null ? null // preAttach: no persistent instance yet : getSource(); // postAttach: source is persistent instance } // for all other events, source is persistent instance return getSource(); }
/** * Returns the persistent instance involved in the event. * * @return The persistent instance involved in the event, or null if there * was none. * * @see "Section 12.15, Java Data Objects 2.0 Specification" */ public Object getPersistentInstance() { switch (getEventType()) { case DETACH: return target == null ? getSource() // preDetach: source is persistent instance : getTarget(); // postDetach: target is persistent instance case ATTACH: return target == null ? null // preAttach: no persistent instance yet : getSource(); // postAttach: source is persistent instance } // for all other events, source is persistent instance return getSource(); }
/** * Returns the detached instance involved in the event. * * @return The detached instance involved in the event, or null if there was none. * * @see "Section 12.15, Java Data Objects 2.0 Specification" */ public Object getDetachedInstance() { switch (getEventType()) { case DETACH: return target == null ? null // preDetach: no detached instance yet : getSource(); // postDetach: source is detached instance case ATTACH: return target == null ? getSource() // preAttach: source is detached instance : getTarget(); // postAttach: target is detached instance } // for all other events, there is no detached instance return null; }
/** * Returns the detached instance involved in the event. * * @return The detached instance involved in the event, or null if there was none. * * @see "Section 12.15, Java Data Objects 2.0 Specification" */ public Object getDetachedInstance() { switch (getEventType()) { case DETACH: return target == null ? null // preDetach: no detached instance yet : getSource(); // postDetach: source is detached instance case ATTACH: return target == null ? getSource() // preAttach: source is detached instance : getTarget(); // postAttach: target is detached instance } // for all other events, there is no detached instance return null; }
public void postStore( InstanceLifecycleEvent evt ) { PersistenceCapable obj = ( (PersistenceCapable) evt.getSource() ); if ( obj instanceof Role ) { listener.rbacRoleSaved( (Role) obj ); } else if ( obj instanceof Permission ) { listener.rbacPermissionSaved( (Permission) obj ); } }
public void postDelete( InstanceLifecycleEvent evt ) { PersistenceCapable obj = ( (PersistenceCapable) evt.getSource() ); if ( obj == null ) { // Do not track null objects. // These events are typically a product of an internal lifecycle event. return; } if ( obj instanceof Role ) { listener.rbacRoleRemoved( (Role) obj ); } else if ( obj instanceof Permission ) { listener.rbacPermissionRemoved( (Permission) obj ); } }
private void checkCall(ZooInstanceEvent expected, Object pc) { assertTrue(calls.size() > 0); Pair p = calls.get(0); //System.out.println("calls:" + calls.size() + " " + p.e.getPersistentInstance()); //System.out.println("calls:" + p.type + " " + p.e.getPersistentInstance().getClass()); assertEquals(expected, p.type); assertEquals(TestClass.class, p.e.getSource().getClass()); assertTrue(pc == p.e.getPersistentInstance()); calls.remove(0); }