Tutorials > Contracts > Extend the existing contract model


Invoke the new business policy

This section refers to invoking the new business policy.


Example

After you have created a new business policy and this business policy has been associated with at least one terms and conditions object, update the application logic to invoke the new business policy commands.

Business policy commands are invoked from within controller and task commands. The command factory is used to invoke business policy commands. There are two create methods that can be used to invoke business policy commands. The first is used to invoke a business policy command when there is only one business policy command associated with the business policy. This is shown in the following code snippet:

    CommandFactory createBusinessPolicyCommand(Long policyId);     

The second method is used to invoke a business policy command when there is more than one business policy command associated with the business policy. This is shown in the following code snippet:

    CommandFactory createBusinessPolicyCommand(Long policyId, String cmdInterfaceName);     

In the preceding example, cmdInterfaceName is used to specify the interface name of the business policy command to be created.

The command factory looks up the policy object in the POLICYCMD table to determine the command that implements this policy. It also fetches any default properties from the table and sets them as requestProperties in the business policy command. The following code snippet shows an example of invoking the MyNewBusinessPolicyCmd policy:

    Long tcID;     
    // get the TC ID from the TC access bean
    
    Enumeration policies = new BusinessPolicyAccessBean().findByTC(tcID);     BusinessPolicyAccessBean policy = (BusinessPolicyAccessBean) policies.nextElement();     MyNewBusinessPolicyCmd cmd = (MyNewBusinessPolicyCmd) CommandFactory.createBusinessPolicyCommand(policy.getPolicyIdInEJBType()); 
    cmd.execute();     


Previous topic: Update WebSphere Commerce Accelerator to use the new term and condition


+

Search Tips   |   Advanced Search