coreRuntime/src/sc/sync/SyncManager.java
public void addPreviousValue(Object obj, InstInfo ii, String propName, Object val, boolean addToInitialLayer) {
         if (ii == null) {
            System.err.println("*** No sync inst registered for: " + DynUtil.getInstanceName(obj));
            return;
         }
         HashMap<String,Object> prevMap = ii.previousValues;
         HashMap<String,Object> initMap = ii.initialValues;

         Object savedVal = copyMutableValue(val);

         // Make a copy of the initial values first time the previous value is set.  As an optimization, we share the initialValues map as the first map for previous values, then do a copy-on-write when the previous value is first changed.
         if (initMap != null && initMap == prevMap && !initialSync) {
            initMap = (HashMap<String,Object>) initMap.clone();
            ii.initialValues = initMap;
         }
         if (prevMap == null) {
            prevMap = new HashMap<String,Object>();
            ii.previousValues = prevMap;
            // The first layer of changes gets saved in the initialValues map.
            if (initMap == null)
               ii.initialValues = prevMap;
         }
         Object old = prevMap.put(propName,savedVal);
         if (verboseValues) {
            String updateType = prevMap == initMap ? "initial" : "original";
            if (old == null)
               System.out.println("Sync " + updateType + " value: " + DynUtil.getInstanceName(obj) + "." + propName + " = " + DynUtil.getInstanceName(val));
            else if (!DynUtil.equalObjects(val, old))
               System.out.println("Sync updating " + updateType + " value: " + DynUtil.getInstanceName(obj) + "." + propName + " = " + DynUtil.getInstanceName(val) + " (from=" + DynUtil.getInstanceName(old) + ")");
         }

         // If ii.inherited is true, we've been propagated this event from a parent context.  Do not record it in the initial layer in this case since the initial layer is already inherited.
         if (!addToInitialLayer || ii.inherited)
            return;

         SyncProperties syncProps = ii.props == null ? getSyncPropertiesForInst(obj) : ii.props;
         if (syncProps == null)
            return;
         int syncFlags = syncProps.getSyncFlags(propName);
         if (syncFlags == -1)
            return;

         SyncState state = getSyncState();
         if (state == SyncState.Disabled)
            return;
         // Needs to be added as a change to the initialSyncLayer, it is maintained on the client and server but for
         // different purposes.
         // For the server (recordInitial=true), this records all changes so we can do an accurate "refresh" using the initial layer.
         // For the client (recordInitial = false), includes changes required to reset the server's session when it is lost.
         // It's not all state since the server can reproduce much of the state that it sends to the client initially.
         // It does include changes made on the client - i.e. those made with SyncState.RecordingChanges.
         // It also includes properties explicitly marked as 'reset state'. That must be set manually to include properties
         // the server needs returned to it, typically properties it sets in response to some button clicked in the UI
         // where the client change does not include all of the info produced by the operation.
         if ((recordInitial || state == SyncState.InitializingLocal) || (state != SyncState.Initializing && state != SyncState.ApplyingChanges) || (ii.resetState && ((syncFlags & SyncPropOptions.SYNC_RESET_STATE) != 0)))
            initialSyncLayer.addChangedValue(obj, propName, val, recordInitial && state == SyncState.ApplyingChanges);
      }
/**
       * Records the value that represents the last synchronized state from the remote process.  When you start a new
       * operation, the previous value also stores the unchanged value or original. Normally the previous value is maintained
       * automatically.   It's a cache of the old version basically and updated when a property change event is received.
       * It knows the context - are we apply changes from the server or recording new changes and updates the previous value accordingly.
       * There are some situations when you might update the previous value directly.  For example, you generate the
       * body of a parent tag which includes the child tag's startTagTxt and InnerHTML properties.  Once the parent's body
       * is received on the remote side, the children's values will updated implicitly.  We need to update the previous
       * value so we know when to send over changes.
       */
Records the value that represents the last synchronized state from the remote process.  When you start a new
operation, the previous value also stores the unchanged value or original. Normally the previous value is maintained
automatically.   It's a cache of the old version basically and updated when a property change event is received.
It knows the context - are we apply changes from the server or recording new changes and updates the previous value accordingly.
There are some situations when you might update the previous value directly.  For example, you generate the
body of a parent tag which includes the child tag's startTagTxt and InnerHTML properties.  Once the parent's body
is received on the remote side, the children's values will updated implicitly.  We need to update the previous
value so we know when to send over changes.
Records the value that represents the last synchronized state from the remote process . When you start a new operation the previous value also stores the unchanged value or original . Normally the previous value is maintained automatically . It ' s a cache of the old version basically and updated when a property change event is received . It knows the context - are we apply changes from the server or recording new changes and updates the previous value accordingly . There are some situations when you might update the previous value directly . For example you generate the body of a parent tag which includes the child tag ' s startTagTxt and InnerHTML properties . Once the parent ' s body is received on the remote side the children ' s values will updated implicitly . We need to update the previous value so we know when to send over changes .
public void addPreviousValue(Object obj, InstInfo ii, String propName, Object val, boolean addToInitialLayer) {
         if (ii == null) {
            System.err.println("*** No sync inst registered for: " + DynUtil.getInstanceName(obj));
            return;
         }
         HashMap<String,Object> prevMap = ii.previousValues;
         HashMap<String,Object> initMap = ii.initialValues;
         Object savedVal = copyMutableValue(val);
         if (initMap != null && initMap == prevMap && !initialSync) {
            initMap = (HashMap<String,Object>) initMap.clone();
            ii.initialValues = initMap;
         }
         if (prevMap == null) {
            prevMap = new HashMap<String,Object>();
            ii.previousValues = prevMap;
            if (initMap == null)
               ii.initialValues = prevMap;
         }
         Object old = prevMap.put(propName,savedVal);
         if (verboseValues) {
            String updateType = prevMap == initMap ? "initial" : "original";
            if (old == null)
               System.out.println("Sync " + updateType + " value: " + DynUtil.getInstanceName(obj) + "." + propName + " = " + DynUtil.getInstanceName(val));
            else if (!DynUtil.equalObjects(val, old))
               System.out.println("Sync updating " + updateType + " value: " + DynUtil.getInstanceName(obj) + "." + propName + " = " + DynUtil.getInstanceName(val) + " (from=" + DynUtil.getInstanceName(old) + ")");
         }
         if (!addToInitialLayer || ii.inherited)
            return;
         SyncProperties syncProps = ii.props == null ? getSyncPropertiesForInst(obj) : ii.props;
         if (syncProps == null)
            return;
         int syncFlags = syncProps.getSyncFlags(propName);
         if (syncFlags == -1)
            return;
         SyncState state = getSyncState();
         if (state == SyncState.Disabled)
            return;
         if ((recordInitial || state == SyncState.InitializingLocal) || (state != SyncState.Initializing && state != SyncState.ApplyingChanges) || (ii.resetState && ((syncFlags & SyncPropOptions.SYNC_RESET_STATE) != 0)))
            initialSyncLayer.addChangedValue(obj, propName, val, recordInitial && state == SyncState.ApplyingChanges);
      }
public void addPreviousValue ( Object obj , InstInfo ii , String propName , Object val , boolean addToInitialLayer ) { if ( ii == null ) { System . err . println ( "*** No sync inst registered for: " + DynUtil . getInstanceName ( obj ) ) ; return ; } HashMap < String , Object > prevMap = ii . previousValues ; HashMap < String , Object > initMap = ii . initialValues ; Object savedVal = copyMutableValue ( val ) ; if ( initMap != null && initMap == prevMap && ! initialSync ) { initMap = ( HashMap < String , Object > ) initMap . clone ( ) ; ii . initialValues = initMap ; } if ( prevMap == null ) { prevMap = new HashMap < String , Object > ( ) ; ii . previousValues = prevMap ; if ( initMap == null ) ii . initialValues = prevMap ; } Object old = prevMap . put ( propName , savedVal ) ; if ( verboseValues ) { String updateType = prevMap == initMap ? "initial" : "original" ; if ( old == null ) System . out . println ( "Sync " + updateType + " value: " + DynUtil . getInstanceName ( obj ) + "." + propName + " = " + DynUtil . getInstanceName ( val ) ) ; else if ( ! DynUtil . equalObjects ( val , old ) ) System . out . println ( "Sync updating " + updateType + " value: " + DynUtil . getInstanceName ( obj ) + "." + propName + " = " + DynUtil . getInstanceName ( val ) + " (from=" + DynUtil . getInstanceName ( old ) + ")" ) ; } if ( ! addToInitialLayer || ii . inherited ) return ; SyncProperties syncProps = ii . props == null ? getSyncPropertiesForInst ( obj ) : ii . props ; if ( syncProps == null ) return ; int syncFlags = syncProps . getSyncFlags ( propName ) ; if ( syncFlags == - 1 ) return ; SyncState state = getSyncState ( ) ; if ( state == SyncState . Disabled ) return ; if ( ( recordInitial || state == SyncState . InitializingLocal ) || ( state != SyncState . Initializing && state != SyncState . ApplyingChanges ) || ( ii . resetState && ( ( syncFlags & SyncPropOptions . SYNC_RESET_STATE ) != 0 ) ) ) initialSyncLayer . addChangedValue ( obj , propName , val , recordInitial && state == SyncState . ApplyingChanges ) ; }
Records the value that represents the last synchronized state from the remote process.
Records the value that represents the last synchronized state from the remote process .
// Make a copy of the initial values first time the previous value is set.  As an optimization, we share the initialValues map as the first map for previous values, then do a copy-on-write when the previous value is first changed. // The first layer of changes gets saved in the initialValues map. // If ii.inherited is true, we've been propagated this event from a parent context.  Do not record it in the initial layer in this case since the initial layer is already inherited. // Needs to be added as a change to the initialSyncLayer, it is maintained on the client and server but for // different purposes. // For the server (recordInitial=true), this records all changes so we can do an accurate "refresh" using the initial layer. // For the client (recordInitial = false), includes changes required to reset the server's session when it is lost. // It's not all state since the server can reproduce much of the state that it sends to the client initially. // It does include changes made on the client - i.e. those made with SyncState.RecordingChanges. // It also includes properties explicitly marked as 'reset state'. That must be set manually to include properties // the server needs returned to it, typically properties it sets in response to some button clicked in the UI // where the client change does not include all of the info produced by the operation.