@SuppressWarnings({"unchecked", "rawtypes"})
 @Override
 public void setIdentifier(Serializable id) {
   FrozenContext<Serializable> ctx = (FrozenContext) this.idFrozenContext;
   FrozenContext.suspendFreezing(ctx, this.owner);
   try {
     this.setRawIdentifier(id);
   } finally {
     FrozenContext.resumeFreezing(ctx);
   }
 }
 @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)));
     }
   }
 }
Ejemplo n.º 4
0
  public void setFirstName(String firstName) {

    FrozenContext<FullName> ctx = this.firstNameFrozenContext;

    /*
     * Before modification, remove the current object from the all the
     * hash-tables and red-black-trees retained by this.firstNameFrozenContext
     */
    FrozenContext.suspendFreezing(ctx, this);
    try {
      this.firstName = firstName;
    } finally {
      /*
       * After modification, add the current object into the all the
       * hash-tables and red-black-trees retained by this.firstNameFrozenContext
       * AGAIN!
       */
      FrozenContext.resumeFreezing(ctx);
    }
  }
Ejemplo n.º 5
0
 @Override
 public void unfreeze(FullName obj, FrozenContext<FullName> ctx) {
   obj.firstNameFrozenContext = FrozenContext.remove(obj.firstNameFrozenContext, ctx);
   obj.lastNameFrozenContext = FrozenContext.remove(obj.lastNameFrozenContext, ctx);
 }
Ejemplo n.º 6
0
 @Override
 public void freeze(FullName obj, FrozenContext<FullName> ctx) {
   obj.lastNameFrozenContext = FrozenContext.combine(obj.lastNameFrozenContext, ctx);
 }
 @SuppressWarnings({"unchecked", "rawtypes"})
 @Override
 public void unfreezeIdentifier(FrozenContext<?> ctx) {
   this.idFrozenContext =
       FrozenContext.remove((FrozenContext) this.idFrozenContext, (FrozenContext) ctx);
 }