@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);
   }
 }
 @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)));
     }
   }
 }
 protected void raiseModifying(ScalarEvent e) throws Throwable {
   ScalarListener scalarListener = this.scalarListener;
   if (scalarListener != null) {
     e.getAttributeContext(AttributeScope.LOCAL).addAttribute(AK_SCALAR_LISTENER, scalarListener);
     scalarListener.modifying(e);
   }
 }
 protected void raiseModified(ScalarEvent e) throws Throwable {
   ScalarListener scalarListener =
       (ScalarListener)
           e.getAttributeContext(AttributeScope.LOCAL).removeAttribute(AK_SCALAR_LISTENER);
   if (scalarListener != null) {
     scalarListener.modified(e);
   }
 }