Overview | Package | Class | Tree | Deprecated | Index | Help
| bea Systems, Inc.
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package examples.businesspolicy

BusinessPolicy Example shows the use of Theory Center's BusinessPolicy eBusiness Smart Components.

See:
Description

Class Summary
AprilFoolsDiscountPolicy | This class is a custom item pricing calculation policy.
BusinessPolicyExample | This example demonstrates the concept of "Pluggable Methods", better known as policies.
SeniorCitizenDiscountPolicy | This class is a custom item pricing calculation policy.

## Package examples.businesspolicy Description

BusinessPolicy Example shows the use of Theory Center's BusinessPolicy eBusiness Smart Components.

This example demonstrates:

- How to use eBusiness Smart Components
- How to add a default Policy to an Item using eBSC BusinessPolic
- How to use a non-default policy to change the price of an item

ItemPriceCalculationPolicy and BusinessPolicy

This example shows the use of theory.smart.ebusiness.item.ItemPriceCalculationPolicy which is an extension to theory.smart.foundation.BusinessPolicy. A BusinessPolicy consists of rules and regulations, specific to your business. These rules can be encapsulated into a component and then added to a eBSC such as an Item.

This example demonstrates the concept of "Pluggable Methods", better known as policies. When you create your components, you will realize that many times you want to alter the component behaviour based on external conditions that you can not evaluate at development time. Reusability, extensibility and rapid development and enhancement are typical problems that can be solved using policies. BusinessPolicy is Theory Center's implementation of the Policy and Strategy design patterns. Using this concepts allows you to replace the default policy at runtime. The policy is stored as a property for the item. In this example we will use an item component. The item component has a pricing policy. The item's price is calculated based on a given quantity and the pricing policy. You can replace the pricing policy to alter the way the price is calculated for the item. This means that you can modify the behaviour of the item by plugging in a method that calculates the price the way you want If you do not provide a pricing policy, a default policy will be used. The example creates an item. It Then, sets the SeniorCitizenDiscountPolicy as the default pricing policy for the item. Then, the item's price is calculated using the default policy. Finally, it modifies the item's quantity and once again, calculates the price; this time using the AprilFoolsDiscountPolicy policy. To better understand this example it would be great if you go through the Axiom example first.

The concept is also used in our BuyBeans.com online store where different pricing policies of BuyBeans are used for calculating the prices of examples.buybeans.item.BeanieBaby, examples.buybeans.item.CoffeeBean, and examples.buybeans.item.JellyBean components. They use BeanieBabyPricePolicy, CoffeeBeanPricePolicy, and JellyBeanPricePolicy respectively.

BusinessPolicy Example

The BusinessPolicy example application performs the following steps:

1. Find or create or an Item component
2. Set the Item's Quantity.
3. Add the SeniorCitizenDiscountPolicy to the Item as the default pricing policy and change the Item's price.
4. Change the Item's Quantity.
5. Change the item's price using the AprilFoolsDiscountPolicy.

To get the most out of this example, first read through `BusinessPolicyExample.java`. Then you can build it and run it.

Please note: to build and run, you must have the following in your CLASSPATH:

1) smart-generator.jar (..\theorycenter\smart-generator.jar), axiom-foundation.jar (..\theorycenter\lib\axiom-foundation.jar), and ebusiness.jar (..\theorycenter\lib\ebusiness.jar) .

2) Application Server classes (default classpath required by Weblogic)

The fastest way to run any of the examples is by using the scripts provided in ..\theorycenter\*.bat

Overview | Package | Class | Tree | Deprecated | Index | Help
| bea Systems, Inc.
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

© Copyright 2000 bea Systems, Inc. All rights reserved.