コード例 #1
0
 @Override
 public void modified(ScalarEvent e) {
   EventAttributeContext localAttributeContext = e.getAttributeContext(AttributeScope.LOCAL);
   if (localAttributeContext.getAttribute(AK_MODIFIYING_EXECUTED) == null) {
     return;
   }
   FrozenLazyInitializerImpl declaring = FrozenLazyInitializerImpl.this;
   if (e.getProperty() == declaring.objectModelMetadata.getEntityIdProperty()) {
     try {
       declaring.disableSetTargetIdentifier = true;
       try {
         declaring.setIdentifier((Serializable) e.getScalar(PropertyVersion.ATTACH));
       } finally {
         declaring.disableSetTargetIdentifier = false;
       }
     } finally {
       FrozenContext<?> ctx =
           (FrozenContext<?>) localAttributeContext.getAttribute(AK_FROZENCONTEXT);
       FrozenContext.resumeFreezing(ctx);
     }
   }
   ScalarEvent dispatchedEvent = e.getDispathcedEvent(true);
   if (dispatchedEvent != null) {
     declaring.executeModified(dispatchedEvent);
   }
 }
コード例 #2
0
 @SuppressWarnings("unchecked")
 @Override
 public void modifying(ScalarEvent e) {
   FrozenLazyInitializerImpl declaring = FrozenLazyInitializerImpl.this;
   if (!declaring.disableTargetListener) {
     ObjectModelFactory<ObjectModel> omFactory = declaring.omFactory;
     LazyInitializer rawLazyInitializer = declaring.lazyInitializer;
     EventAttributeContext localAttributeContext = e.getAttributeContext(AttributeScope.LOCAL);
     if (rawLazyInitializer.isUninitialized()
         || omFactory.get(rawLazyInitializer.getImplementation()) != e.getSource()) {
       ((ObjectModel) e.getSource()).removeScalarListener(this);
       return;
     }
     localAttributeContext.addAttribute(AK_MODIFIYING_EXECUTED, true);
     if (e.getProperty() == declaring.objectModelMetadata.getEntityIdProperty()) {
       FrozenContext<Object> ctx = (FrozenContext<Object>) declaring.idFrozenContext;
       localAttributeContext.addAttribute(AK_FROZENCONTEXT, ctx);
       FrozenContext.suspendFreezing(ctx, declaring.owner);
     }
     ScalarListener scalarListener = declaring.scalarListener;
     if (scalarListener != null) {
       declaring.executeModifying(e.dispatch(declaring.omFactory.get(declaring.owner)));
     }
   }
 }