IPolicyFeature Interface Overview
When you initially apply an information management policy to an item, policy features must often perform certain operations to initialize the feature's policy enforcement on that item. This initialization can include the following actions:
Creating a column on the item's list. For example, the Expiration policy feature creates a new column, named ExpireDate, on items to which you apply it.
Registering for events on the item's list.
Performing some work on the item. For example, the Expiration policy feature computes the initial value of the ExpireDate column on items to which you apply it.
In addition to installing a valid Policy Feature Definition, each policy feature must also contain a class that implements the IPolicyFeature interface. This interface enables Office SharePoint Server 2007 to call the code needed to perform any initiation work the policy feature needs, as well as code to perform any tasks when a policy item that is associated with the policy feature is added, deleted, or changed for a content type.
Office SharePoint Server 2007 calls the appropriate method when policy items are added, deleted, or changed for a content type.
The IPolicyFeature interface contains the following methods.
Called by Office SharePoint Server 2007 when a user changes the custom settings on a specific policy item associated with the policy feature.
Called by Office SharePoint Server 2007 when a user changes the server farm-level settings for a policy feature.
Called by Office SharePoint Server 2007 when a policy changes. Changes include editing the policy currently assigned to the list, or assigning a different policy to the list.
If a policy feature returns false, Office SharePoint Server 2007 does not process the remaining items. This optimization prevents Office SharePoint Server 2007 from iterating through all the items on a list for policy features that are not involved with processing the item.
Called by Office SharePoint Server 2007 on list items that are no longer subject to the specified policy. This method lets you specify item level un-registration that needs to be performed when the policy is removed from an item.
Called by Office SharePoint Server 2007 when a user adds a new policy item to a policy. This method performs any required initiation work for the policy feature, such as adding specific columns to the content type, or registering for events.
Called by Office SharePoint Server 2007 when an existing policy item is removed from a policy.
When you add a policy item to a policy, Office SharePoint Server 2007 calls the Register method of the associated policy feature to perform any required initiation work.
Similarly, if you delete a policy item from a policy, Office SharePoint Server 2007 calls the UnRegister method of the associated policy feature to perform any needed cleanup work.
When a policy changes, Office SharePoint Server 2007 calls the ProcessListItem method for each policy feature that changed. If the policy feature has not changed, Office SharePoint Server 2007 does not call any of its methods.
For example, suppose your policy for a given content type contains one policy feature, Bar Codes, and you then add a policy item for the Expiration policy feature. Office SharePoint Server 2007 calls the Register method of the Expiration policy feature to initialize the feature on each item that is assigned to that content type. However, because the policy item for the Bar Codes policy feature has not changed within the policy, Office SharePoint Server 2007 does not call the ProcessListItem method of that policy feature.