Skip to content

Commit

Permalink
ILinkableObjectWithNewProperties now receives notifications when a
Browse files Browse the repository at this point in the history
session state contains properties that no longer exist in the current
implementation.
  • Loading branch information
adufilie committed Jun 17, 2015
1 parent affd31d commit 458c153
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 4 additions & 7 deletions WeaveAPI/src/weave/api/core/ILinkableObjectWithNewProperties.as
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
package weave.api.core
{
/**
* Implement this interface to detect when properties are missing from a full session state.
* Implement this interface to detect when a full session state is missing properties or a session state contains extra properties.
*/
public interface ILinkableObjectWithNewProperties extends ILinkableObject
{
/**
* This function will be called by SessionManager.setSessionState()
* to give this object a chance to determine if a missing property
* should be derived using backwards compatibility code for old
* session states from when the property did not exist.
* This function will be called by SessionManager.setSessionState() when a full session state is missing properties or a session state contains extra properties.
* @param newState The new session state for this object.
* @param missingProperty The name of the missing property.
* @param missingProperty The name of the property, whether it is missing from the newState or this ILinkableObject.
*/
function handleMissingSessionStateProperty(newState:Object, missingProperty:String):void;
function handleMissingSessionStateProperty(newState:Object, property:String):void;
}
}
11 changes: 8 additions & 3 deletions WeaveCore/src/weave/core/SessionManager.as
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ package weave.core
setSessionState(property, newState[name], removeMissingDynamicObjects);
}

// handle properties appearing in session state that do not appear in the linkableObject
if (linkableObject is ILinkableObjectWithNewProperties)
for each (name in newState)
if (!deprecatedLookup.hasOwnProperty(name))
(linkableObject as ILinkableObjectWithNewProperties).handleMissingSessionStateProperty(newState, name);

// handle properties missing from absolute session state
if (foundMissingProperty)
for each (name in classNameToSessionedPropertyNames[classQName])
Expand Down Expand Up @@ -580,7 +586,7 @@ package weave.core
*/
private const classNameToDeprecatedSetterNames:Object = new Object();
/**
* This maps a qualified class name to an Object mapping deprecated sessioned property names to true.
* This maps a qualified class name to an Object mapping sessioned property names to booleans indicating if they are implemented as deprecated getters.
*/
private const classNameToDeprecatedGetterLookup:Object = new Object();

Expand Down Expand Up @@ -615,8 +621,7 @@ package weave.core
}
else if (ClassUtils.classImplements(variable.type, ILinkableObjectQualifiedClassName))
{
if (deprecated)
deprecatedGetterLookup[variable.name] = true;
deprecatedGetterLookup[variable.name] = deprecated;
propertyNames.push(variable.name);
}
}
Expand Down

0 comments on commit 458c153

Please sign in to comment.