BEA Logo BEA WLCS Release Release Number

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WLCS Doc Home   |   WLCS Components Developer's Guide   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Component Examples

 

The section contains the following topics:

How to Build and Run the Examples

Foundation and Axiom

Package examples.axiom

Package examples.axiom Description

Belongings and EJBs

The Abstract Factory Pattern

Axiom Example

Workflow

Package examples.workflow Description

Workflow

Workflow Example

BusinessPolicy

Package examples.businesspolicy

Package examples.businesspolicy Description

ItemPriceCalculationPolicy and BusinessPolicy

BusinessPolicy Example

PassByValue

Package examples.passbyvalue

Package examples.passbyvalue Description

Getting and Setting Attributes Using pass-by-value

Pass By Value Example

 


How to Build and Run the Examples

To become better acquainted with the workings of an EJB-based application built using our WebLogic Commerce Server (WLCS), follow these examples.

Note: To build and run any of these examples, you must have the following in your CLASSPATH:

The fastest way to run any of the examples is by using the scripts provided in ...\bin\win32\*.bat or ..\bin\solaris2\*.sh (Found under the WLCS installation directory)

 


Foundation and Axiom

This example demonstrates the core technology: Belongings, Entity Beans, Collections and RemoteIterators.

Package examples.axiom

The Axiom example shows the use of WLCS Axiom package of WebLogic Commerce Server.

Table 5-1 Axiom Package Summary

Class

Description

AxiomExample

Shows how to use the WLCS components Axiom package.

Package examples.axiom Description

The Axiom example shows the use of the WLCS components Axiom package.

This example demonstrates:

Belongings and EJBs

The Axiom package contains light weight components known as belongings, as well as Entity and Session EJB components. Belongings can be aggregated to other components by value. EJBs are used alone or aggregated to other components by reference or value.

The Abstract Factory Pattern

All WebLogic Commerce Server use the abstract factory pattern. The principle is very simple: Don't use new() to create an object, instead, you use Home.create(). The Abstract factory pattern is implemented as the "Home" for EJBs and as a Java class with static methods for Belongings.

Axiom Example

The example application performs the following steps:

  1. Find or create or a Customer component

  2. Create belongings

  3. Add belongings to the Customer

  4. Use a Remote Iterator to iterate through the belongings

  5. Remove the Belongings

To get the most out of this example, first read through AxiomExample.java on our web site. Then you can build it and run it.

Note: Be sure to set your CLASSPATH as described in How to Build and Run the Examples.

 


Workflow

Workfow, eBusinessSession, and eBusinessSessionManager components. The Workflow maintains state for the session and guides the user through the process.

Package examples.workflow

Shows the use of WLCS Workflow components.

This example demonstrates:

Package examples.workflow Description

Shows the use of the WLCS Workflow components.

This example demonstrates:

Workflow

This example shows the use of a WLCS component that has a workflow associated to it. The workflow states and transitions are modeled with Rational Rose. For this examples, we'll use the EBusinessSession Component. This component has a workflow that guides it through the different stages of an online e-business session. If you look at the Rose model file for the ebusiness.session package, you will find that EBusinessSessionWorkflow has a state diagram associated to it. The workflow logic can be implemented in any way you want; however, WLCS provides a reference implementation. For the reference implementation, for each component with the BSC.Workflow stereotype, all the states and transitions in the Rose model are generated into a complete state machine by the SmartGenerator, so you can use it immediately, without any hand-coding of the workflow states or transitions.

In this example, we also use the EBusinessSessionManager and show how a "manager" session bean can simplify the usage of an entity bean

Workflow Example

The workflow example application performs the following steps:

  1. Create a Guest Session component using the EBusinessSessionManager.

  2. Try options such as enroll, cancellEnrollment, becomeGuest, and disableAuthentication. (You can find these transitions in the EBusinessSessionWorkflow state diagram)

  3. Register as a new or Login as an existing Customer

  4. Perform more options (authenticate, and disableAuthentication)

To get the most out of this example, first read through WorkflowExample.java on our web site then you can build it and run it.

Note: Be sure to set your CLASSPATH as described in How to Build and Run the Examples.

 


BusinessPolicy

Pluggable Methods, Strategy Pattern, or Individual Instance Method. No matter what you call it, it is a powerful design tool. This example demonstrates how ConfigurableEntity beans and BusinessPolicy work together to create very flexible solutions.

Package examples.businesspolicy

BusinessPolicy Example shows the use of WLCS WebLogic BusinessPolicy Components.

Table 5-3 BusinessPolicy Package Summary

Class

Description

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

The BusinessPolicy example shows the use of the WLCS BusinessPolicy components.

This example demonstrates:

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 Component 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 the WLCS 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, and calculates the price by using the AprilFoolsDiscountPolicy policy. To better understand this example, first 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 on our web site. Then you can build it and run it.

Note: Be sure to set your CLASSPATH as described in How to Build and Run the Examples.

 


PassByValue

Sometimes it is useful to get or set all of the attributes of an object with a single method call. When dealing with remote objects that are persisted in the database, this results in a tremendous performance gain. BEA's WebLogic Commerce Server components give you that flexibility.

Package examples.passbyvalue

Shows the use of BEA WebLogic Commerce Server components' pass-by-value feature. This example demonstrates:

Package examples.passbyvalue Description

Shows the use of BEA WebLogic Commerce Server' pass-by-value feature.This example demonstrates:

Getting and Setting Attributes Using pass-by-value

This example shows how you can get and set the attributes of an Entity Component by value. What this means is that instead of getting/setting one attribute at a time, you can request that a local copy of all attributes be sent to you directly, in one remote call. You can then read and modify this "Value object" or local copy, and send it back in one remote call. This has tremendous performance advantages compared to accessing one attribute at a time It is also important to be able to set many attributes within a single transaction without having to begin/commit a JTS User Transaction from the client. In short, pass-by-value is really handy! Our implementation is tightly-coupled: that means that at compile time, we enforce type consistency for getting/setting attributes in the value objects. This has an advantage over "parameter sets"and "late-binding" implementations where you pass around a set of name/value pairs: with these approaches, if you change the type of an attribute your client will still compile but crash at runtime. This won't happen using WebLogic Commerce Server, since the value object will change accordingly and the client would not compile if an assignment was illegal. In addition, our value objects are generated by BEA SmartGenerator (based on a UML model), so they don't add any maintenance costs.

Pass By Value Example

The PassByValue example application performs the following steps:

To get the most out of this example, first read through PassByValueExample.java on our web site. Then you can build it and run it.

Note: Be sure to set your CLASSPATH as described in How to Build and Run the Examples.