![]() |
![]() |
|
|
Developing Applications with WebLogic Components
This topic includes the following sections:
To create a distributed client-server application in Java using BEA's WebLogic Components technology, you must perform the following programming steps:
Note: Refer to our white paper on Modeling with eBSC's.
Note: For aspects of steps 2, 3, and 4, refer to the hands-on technical tutorial.
Note: Refer to information about our BMP deployment sets.
Component Examples
To become better acquainted with the workings of an EJB-based application built using our WebLogic Components, 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 WebLogic Components 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 BEA Axiom package of WebLogic Components.
Class |
Description |
---|---|
Shows how to use BEA's Axiom package of WebLogic Components. |
The Axiom example shows the use of BEA Axiom package of WebLogic Components.
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 Components 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.
Remote Iterators
This example also shows the use of Remote Iterators, one of BEA's collection APIs. You can iterate through a collection both locally and remotely. Locally, the whole collection is sent to you from the server and you can traverse it. This is good for small collections where you need to iterate a lot. For large collections, you can use one or more remote iterators. Remote iterators traverse the collection in the server. That way, you only * bring over the net the values that you need saving bandwidth. They also serve as "bookmarks" on a collection, since they "remember" in what position you leave them.
Axiom Example
The example application performs the following steps:
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.
See above note:To build and run any of these examples, you must have the following in your CLASSPATH:
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 BEA WebLogic Workflow Components.
This example demonstrates:
Class |
Description |
---|---|
Workflow example. |
Package examples.workflow Description
Shows the use of BEA WebLogic Workflow Components.
This example demonstrates:
This example shows the use of a WebLogic Components 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, BEA 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. Please note that the SmartGenerator is NOT included in the WebLogic Components Kit. 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:
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.
See above note:To build and run any of these examples, you must have the following in your CLASSPATH:
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 BEA WebLogic BusinessPolicy Components.
Class |
Description |
---|---|
This class is a custom item pricing calculation policy. |
|
This example demonstrates the concept of "Pluggable Methods", better known as policies. |
|
This class is a custom item pricing calculation policy. |
Package examples.businesspolicy Description
BusinessPolicy Example shows the use of BEA BusinessPolicy WebLogic 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 BEA'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:
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.
See above note:To build and run any of these examples, you must have the following in your CLASSPATH:
Extending
Part of the power of our component suite is that all components are extensible. Through inheritance you can add specialized methods and attributes to WebLogic Components without having to 'reinvent the wheel.'
Package examples.extending
The Extending Example shows you the use of BEA WebLogic AlphaNumericSequencer Components and how to extend WebLogic Components. This example demonstrates:
Interface |
Description |
---|---|
Primary Key = examples.extending.AlphaNumericSequencerExtensionPk |
|
The home interface for the AlphaNumericSequencerExtension entity bean. |
Class |
Description |
---|---|
Primary Key = examples.extending.AlphaNumericSequencerExtensionPk |
|
This is a PrimaryKey for managing the life cycle of a BSC Configurable/Entity bean. |
|
|
|
This example demonstrates extending a WebLogic Components. |
Package examples.extending Description
The Extending Example shows you the use of BEA AlphaNumericSequencer Component and how to extend an Component.
This example demonstrates:
AlphaNumericSequencerExtension Component
The AlphaNumericSequencerExtension extends AlphaNumericSequencer . The AlphaNumericSequencer generates sequential identifiers in a user prescribed format. The user of the class can configure the prefix, suffix, step, and width of these components. The current sequence number is persisted and access to the counter is controlled so that uniqueness can be guaranteed across all users of a given sequencer. It is often used to generate unique keys for entities such as accounts, users, and sessions. The AlphanumericSequencerExtension has a getValue() method that converts returns the counter value in hexadecimal notation
The extending example application performs the following steps:
To get the most out of this example, first read through ExtendingExample.java on our web site. Then you can build it and run it. Other files in this example are: AlphaNumericSequencerExtension.java, AlphaNumericSequencerExtensionHome.java, AlphaNumericSequencerExtensionImpl.java, AlphaNumericSequencerExtensionPk.java
See above note:To build and run any of these examples, you must have the following in your CLASSPATH:
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 Components give you that flexibility.
Package examples.passbyvalue
Shows the use of BEA WebLogic Components' pass-by-value feature. This example demonstrates:
Class |
Description |
---|---|
Pass-by-value example. |
Package examples.passbyvalue Description
Shows the use of BEA WebLogic Components' 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. Thishas 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 Components, 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.
See above note:To build and run any of these examples, you must have the following in your CLASSPATH:
More Information
For further information please see the following:
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|