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.