Creating a State Policy Contribution
Creating a State Policy Contribution
Each State Policy aware Creating a State Policy aware dialog, Creating a State Policy aware editor, section, page, and Creating a State Policy aware action must be mapped to a State Policies through a State Policy Contribution.
Make sure that you have Creating a State Policy extension point in the plugin.
A State Policy should live in the plugin most appropriate for the code that the policy is using to determine state. For example, all State Policies relating to Change Sets are in the com.elasticpath.cmclient.changeset plugin. Multiple plugins can contribute policies to a particular StatePolicyTarget. The extension point framework enables this without any dependency coupling between plugins.
In the Commerce Manager plugin's plugin.xml file, add a statePolicyContribution element for each StatePolicyTarget that you need to map to a State Policy.
The following table shows the attributes that must be configured on the statePolicyContribution.
targetId | The target ID of the StatePolicyTarget object as returned by its getTargetIdentifier method. |
---|---|
statePolicy | The fully qualified class name of the State Policy. |
priority | The priority. This value is used by the StatePolicyResolver to determine the order in which State Policy Contributions are applied. |
A State Policy can be applied to multiple targets and multiple State Policies can apply to the same target. If there is a conflict between policies, the behavior is determined by the plugin's Creating a State Policy aware UI plugin class. For the DefaultStatePolicyResolver, the contribution with the highest priority generally takes precedence.
The following example, shows State Policy Contributions mapped to a dialog, an action, and an editor.
<extension point="com.elasticpath.cmclient.catalog.statePolicy"> ... <statePolicyContribution priority="10" statePolicy="com.elasticpath.cmclient.catalog.policy.EditVirtualCatalogAuthorizationStatePolicy" targetId="virualCatalogDialogEditableTarget"> </statePolicyContribution> <statePolicyContribution priority="10" statePolicy="com.elasticpath.cmclient.catalog.policy.EditVirtualCatalogAuthorizationStatePolicy" targetId="editCatalogCategoryAction"> </statePolicyContribution> <statePolicyContribution priority="10" statePolicy="com.elasticpath.cmclient.catalog.policy.CategoryAuthorizationStatePolicy" targetId="categoryEditor"> </statePolicyContribution> <extension>