BEA Logo BEA WebLogic Commerce Server Release 3.1.1

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

 

   WebLogic Commerce Server Doc Home   |   Product Catalog Management   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Using the API to Extend the Product Catalog

 

This chapter describes the various options available for extending, customizing, or writing third-party integrations for the WebLogic Commerce Server product catalog. The catalog defines interfaces for services that are required to access and administer an electronic product catalog. The architecture is built on Java 2 Enterprise Edition (J2EE) standards-based components and BEA WebLogic Server.

In addition an implementation of the services is provided which defines an electronic product catalog that uses JDBC as a persistence mechanism.

Note: The descriptions in this chapter assume that you are an experienced EJB developer.

This topic includes the following sections:

 


Overview of the Product Catalog API

The product catalog API package structure is organized as follows:

com.beasys.commerce.ebusiness.catalog is the main end-user package for Product Catalog development. It contains all the commonly accessed classes for accessing both Product Items and Categories.

com.beasys.commerce.ebusiness.catalog.loader contains the classes necessary to support the command-line Product Catalog database bulk loader, DBLoader. This loader allows you to easily and quickly import data into the Product Catalog from simple character separated value files.

com.beasys.commerce.ebusiness.catalog.pipeline contains all Pipeline Components that facilitate accessing the Product Catalog from JavaServer Pages.

com.beasys.commerce.ebusiness.catalog.service contains the base services on top of which all pluggable Product Catalog services are implemented. Additionally, this packaged contains several sub-packages for managing Product Items and Categories, searching the Product Catalog, and providing custom attribute support.

com.beasys.commerce.ebusiness.catalog.service.category contains the classes that define a pluggable service to manage the Categories and hierarchical structure of the Product Catalog.

com.beasys.commerce.ebusiness.catalog.service.data contains the classes that define a pluggable service to manage the custom attributes for Product Items and Categories within the Product Catalog.

com.beasys.commerce.ebusiness.catalog.service.item contains the classes that define a pluggable service to manage the Product Items within the Product Catalog.

com.beasys.commerce.ebusiness.catalog.service.query contains the classes that define a pluggable service to perform powerful searching of the Product Catalog. The Product Items within the Catalog can be searched using keywords or boolean search expressions across their attributes.

com.beasys.commerce.ebusiness.catalog.sql contains the classes that provide a database persistence model for the Product Catalog. Industry standard JDBC and SQL are used to ensure compatibility with a wide range of databases.

com.beasys.commerce.ebusiness.catalog.util contains the classes that provide utility methods for the Product Catalog.

com.beasys.commerce.ebusiness.catalog.webflow contains all Input Processors that facilitate accessing the Product Catalog from JavaServer Pages.

 


Catalog Architecture and Services

The WebLogic Commerce Server product catalog architecture divides the functionality of the product catalog into five functional areas, each of which requires an implementation of an associated Product Catalog server interface. The five services are:

All services are implemented using J2EE-compliant stateless session EJBs. These EJBs separate the functionality of the catalog into discrete, pluggable components.

Catalog Architecture

Figure 6-1 illustrates the catalog architecture.

Figure 6-1 Product Catalog Architecture

For example, the process of displaying a product item in a user's browser involves the following phases:

  1. The Web browser opens the JavaServer Page (JSP) that is running in an instance of the WebLogic Server.

  2. One or more Catalog Pipeline Components are executed. For example, GetProductItemPC is executed when a user views a product item.

  3. The Pipeline Component finds the CatalogManager stateless session EJB.

  4. The Pipeline Component requests a service from the CatalogManager (such as the service provided by the ProductItemManager) and receives a stateless session EJB that implements the ProductItemManager interface.

  5. The Pipeline Component calls a method on the ProductItemManager interface. For example, getItem( 12345 ) - where 12345 is the unique identifier for a product item, in the form of a Stock Keeping Unit (SKU) number.

  6. The catalog services analyze the incoming request and the in-memory cache. If the request can be satisfied using in-memory cached data, the cached data is returned. Otherwise, a service provider is selected (based upon deployment settings) that can handle the request, and the corresponding method is invoked on the service (which must also implement the ProductItemManager interface). The return value from the service is added to the cache and the return value is propagated back to the Pipeline Component.

  7. The Pipeline Component then adds the result of the Catalog request to the Pipeline Session.

  8. The JSP uses the WebLogic Commerce Server tag libraries to extract the results of the Catalog request from the Pipeline Session and formats the results as HTML.

Catalog Manager

The Catalog Manager will not typically require customization. Its main purpose is to provide a single point of access to the other catalog services. Table 6-1 shows the method summary for the CatalogManager interface.

Table 6-1 Method Summary for the CatalogManager Interface

Return Type

Method Signature

CatalogRequest

createAdminCatalogRequest()

Creates a CatalogRequest with administrative user access permissions.

CatalogRequest

createCatalogRequest()

Creates a CatalogRequest with default user access permissions.

CatalogQueryManager

getCatalogQueryManager(CatalogRequest request)

Returns the CatalogQueryManager catalog service.

CategoryManager

getCategoryManager(CatalogRequest request)

Returns the CategoryManager catalog service.

CustomDataManager

getCustomDataManager(CatalogRequest request)

Returns the CustomDataManager catalog service.

ProductItemManager

getProductItemManager(CatalogRequest request)

Returns the ProductItemManager catalog service.

void

onRemoveItem(CatalogRequest request, CatalogItemKey item)

Callback method.

The JNDI names of the EJBs returned from the CatalogManager methods are defined in the weblogic-ejb-jar.xml deployment descriptor for the CatalogManager, as shown in Listing 6-1.

Note: You can find the ejb-jar.xml and weblogic-ejb-jar.xml deployment descriptor files in the ebusiness.jar file, which is in WL_COMMERCE_HOME\lib.

Listing 6-1 CatalogManager Deployment Descriptor


<weblogic-enterprise-bean>

  <ejb-name>com.beasys.commerce.ebusiness.catalog.CatalogManager</ejb-name>

    <reference-descriptor>

      <ejb-reference-description>

        <ejb-ref-name>ejb/ProductItemManager</ejb-ref-name>

        <jndi-name>

        com.beasys.commerce.ebusiness.catalog.service.item.ProductItemManager

        </jndi-name>

      </ejb-reference-description>

      <ejb-reference-description>

          <ejb-ref-name>ejb/CategoryManager</ejb-ref-name>

          <jndi-name>

          com.beasys.commerce.ebusiness.catalog.service.category.CategoryManager

          </jndi-name>

        </ejb-reference-description>

        <ejb-reference-description>

           <ejb-ref-name>ejb/CatalogQueryManager</ejb-ref-name>

           <jndi-name>

           com.beasys.commerce.ebusiness.catalog.service.query.CatalogQueryManager

           </jndi-name>

         </ejb-reference-description>

         <ejb-reference-description>

           <ejb-ref-name>ejb/CustomDataManager</ejb-ref-name>

           <jndi-name>

            com.beasys.commerce.ebusiness.catalog.service.data.CustomDataManager

           </jndi-name>

         </ejb-reference-description>

         <ejb-reference-description>

           <ejb-ref-name>ejb/CatalogManager</ejb-ref-name>

           <jndi-name>

            com.beasys.commerce.ebusiness.catalog.CatalogManager

           </jndi-name>

         </ejb-reference-description>

      </reference-descriptor>

      <jndi-name>

       com.beasys.commerce.ebusiness.catalog.CatalogManager

      </jndi-name>

</weblogic-enterprise-bean>

Product Item Manager

The Product Item Manager is responsible for creating, getting, updating, and deleting items within the catalog. Table 6-2 shows the method summary for the ProductItemManager interface.

Table 6-2 Method Summary for the ProductItemManager Interface

Return Type

Method Signature

void

createItem(CatalogRequest request, ProductItem product)

Creates a new product item.

ProductItem


getItem(CatalogRequest request, ProductItemKey productKey)

Returns the product item with the specified key.

int


getItemCount(CatalogRequest request)

Returns the number of product items in the product catalog.

ProductItemKey[]


getItemKeys(CatalogRequest request, int beginIndex, int endIndex)

Returns an array over all existing product item keys within the specified ordered range.

ViewIterator


getItems(CatalogRequest request, int viewSize)

Returns a ViewIterator over all existing product items.

ProductItem[]


getItems(CatalogRequest request, ProductItemKey[] productKeys)

Returns the product items with the given product item keys.

java.lang.String[]


getKeywords(CatalogRequest request, ProductItemKey productKey)

Returns the keywords associated with a given product item.

void


setKeywords(CatalogRequest request, ProductItemKey productKey, java.lang.String[] keywords)

Sets the keywords for a given product item.

void


removeItem(CatalogRequest request, ProductItemKey productKey)

Removes a product item.

void


updateItem(CatalogRequest request, ProductItem product)

Updates a product item.

Category Manager

The Category Manager is responsible for managing the hierarchical structure of the electronic product catalog. It defines the interface that allows the hierarchy to be created and modified, as well as the mapping of items into categories to be managed.

Table 6-3 shows the method summary for the CategoryManager interface.

Table 6-3 Method Summary of the CategoryManager Interface

Return Type

Method Signature

void


addItem(CatalogRequest request, CategoryKey categoryKey, ProductItemKey itemKey)

Adds an item to the specified category.

void



createCategory(CatalogRequest request, CategoryKey parentKey, Category category)

Creates a subcategory within the supplied parent category.

Category[]


getAncestors(CatalogRequest request, CategoryKey categoryKey)

Returns the ancestors of the specified category in ascending order.

Category[]


getCategories(CatalogRequest request, CategoryKey[] categoryKeys)

Returns the categories with the given category keys.

ViewIterator


getCategories(CatalogRequest request, int viewSize)

Returns a ViewIterator over all existing categories.

Category


getCategory(CatalogRequest request, CategoryKey categoryKey)

Returns the category with the given category key.

int


getCategoryCount(CatalogRequest request)

Returns the total number of categories in the product catalog.

CategoryKey[]


getCategoryKeys(CatalogRequest request, int beginIndex, int endIndex)

Returns an array of all existing category keys within the specified ordered range.

int



getItemCount(CatalogRequest request, CategoryKey categoryKey)

Returns the number of product items associated with the specified category.

ProductItemKey[]


getItemKeys(CatalogRequest request, CategoryKey categoryKey, int beginIndex, int endIndex)

Returns an array of all product item keys of the specified category within the specified ordered range.

ViewIterator


getItems(CatalogRequest request, CategoryKey categoryKey, int viewSize)

Returns a ViewIterator over all product items of the specified category.

int


getOrphanedItemCount(CatalogRequest request)

Returns the number of orphaned items in the catalog. An orphaned item (uncategorized) is an item that does not belong to any categories.

ProductItemKey[]


getOrphanedItemKeys(CatalogRequest request, int beginIndex, int endIndex)

Returns an array of all existing orphaned item keys within the specified ordered range. An orphaned item (uncategorized) is an item that does not belong to any categories.

ViewIterator


getOrphanedItems(CatalogRequest request, int viewSize)

Returns a ViewIterator over all existing orphaned items. An orphaned item (uncategorized) is an item that does not belong to any categories.

Category


getParent(CatalogRequest request, CategoryKey categoryKey)

Returns the parent of the specified category.

Category


getRootCategory(CatalogRequest request)

Returns the root category.

int


getSiblingCount(CatalogRequest request, CategoryKey categoryKey)

Returns the number of siblings associated with the specified category.

CategoryKey[]


getSiblingKeys(CatalogRequest request, CategoryKey categoryKey, int beginIndex, int endIndex)

Returns an array of all sibling keys of the specified category within the specified ordered range.

ViewIterator


getSiblings(CatalogRequest request, CategoryKey categoryKey, int viewSize)

Returns a ViewIterator over all siblings of the specified category.

ViewIterator


getSubCategories(CatalogRequest request, CategoryKey categoryKey, int viewSize)

Returns a ViewIterator over all subcategories of the specified category.

int


getSubCategoryCount(CatalogRequest request, CategoryKey categoryKey)

Returns the number of subcategories associated with the specified category.

CategoryKey[]


getSubCategoryKeys(CatalogRequest request, CategoryKey categoryKey, int beginIndex, int endIndex)

Returns an array of all sub category keys of the specified category within the specified ordered range.

void


moveCategory(CatalogRequest request, CategoryKey categoryKey, CategoryKey newParentKey)

Moves the specified category under the specified parent.

void


removeCategory(CatalogRequest request, CategoryKey categoryKey)

Removes the specified category.

void


removeItem(CatalogRequest request, CategoryKey categoryKey, ProductItemKey itemKey)

Removes an item from the specified category.

void


updateCategory(CatalogRequest request, Category category)

Updates an existing category.

Custom Data Manager

The Custom Data Manager defines an interface that allows custom attributes (attributes not defined in the ProductItem interface) to be persisted for Product Items. The getProperty and setProperty Configurable Entity methods on Categories and Product Items use the Custom Data Manager service to allow a client to retrieve and set customer attributes.

Table 6-4 shows the method summary for the CustomDataManager interface.

Table 6-4 Method Summary for the CustomDataManager Interface

Return Type

Method Signature

java.util.Map


getProperties(CatalogRequest request, CatalogItemKey itemKey)

Retrieve all the property values.

java.util.Map



getProperties(CatalogRequest request, CatalogItemKey itemKey, java.lang.String namespace)

Retrieve all the property values within a namespace.

java.lang.Object


getProperty(CatalogRequest request, CatalogItemKey itemKey, java.lang.String namespace, java.lang.String key, java.lang.Object defaultValue)

Retrieve the value associated with the named key.

void


removeProperties(CatalogRequest request, CatalogItemKey itemKey)

Remove all the properties for an item.

java.lang.Object


removeProperty(CatalogRequest request, CatalogItemKey itemKey, java.lang.String namespace, java.lang.String key)

Remove the property associated with the named key.

void



setProperty(CatalogRequest request, CatalogItemKey itemKey, java.lang.String namespace, java.lang.String key, java.lang.Object value)

Associate the specified value with the named key.

Catalog Query Manager

The Catalog Query Manager is responsible for searching the Catalog for Product Items. It currently defines two types of catalog search: keyword search and query-based search.

The keyword search is a search of the keywords associated with a product item. Query-based search allows a complex Boolean expression on any of the item attributes to be evaluated.

Table 6-5 shows the method summary for the CatalogQueryManager interface.

Table 6-5 Method Summary for the CatalogQueryManager Interface

Return Type

Method Signature

ProductItemKey[]


search(CatalogRequest request, CatalogQuery query)

Returns the keys of product items that met the criteria of the supplied catalog query object.

ViewIterator


search(CatalogRequest request, CatalogQuery query, int viewSize)

Returns a ViewIterator over all product items that met the criteria of the supplied catalog query object.

For related information, see the section Query-based Search Syntax.

 


The Catalog Cache

The catalog architecture includes a powerful caching mechanism for items and categories within the product catalog. Integrators can choose between integrating services in front of the cache or behind the cache. Currently the ProductItemManager and CategoryManager benefit from the caching architecture, as illustrated earlier in this chapter in Figure 6-1.

Replacing the JNDI name of a bean in the CatalogManager's deployment descriptor will replace a service in front of the cache. The service will have to implement its own caching mechanism or forgo the benefits of caching.

The services defined by BEA, specified in the deployment descriptor for the CatalogManager, implement the caching for access to items and categories. The following beans query the cache and returned cached data if available; otherwise they delegate to the beans specified in their deployment descriptors:

com.beasys.commerce.ebusiness.catalog.service.item.ProductItemManager 
com.beasys.commerce.ebusiness.catalog.service.category.CategoryManager

By editing the deployment descriptors for the ProductItemManager and CategoryManager beans, the functionality of the product catalog can be extended behind the cache. This enables developers to concentrate on the persistence model for the catalog without worrying about the caching architecture. For example, in Listing 6-2, you could replace the current delegate service provider class (JdbcCategoryManager) with the name of a new session bean that implements the CategoryManager interface. This listing is from the ejb-jar.xml deployment descriptor file (platform independent).

Listing 6-2 CategoryManager Deployment Descriptor


<session>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.service.category.CategoryManager
</ejb-name>
<home>
com.beasys.commerce.ebusiness.catalog.service.category.CategoryManagerHome
</home>
<remote>com.beasys.commerce.ebusiness.catalog.service.category.CategoryManager
</remote>
<ejb-class>
com.beasys.commerce.ebusiness.catalog.service.category.CategoryManagerImpl
</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>

  <!--  one specifies the delegateName to tell the Bridge component (the one
used by the catalog manager which ejb to delegate to. That way, one
can change delegates by changing the env-entry...
-->

  <env-entry>
<env-entry-name>delegateName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>ejb/JdbcCategoryManager</env-entry-value>
</env-entry>

  
<ejb-ref>
<ejb-ref-name>ejb/JdbcCategoryManager</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>
com.beasys.commerce.ebusiness.catalog.service.category.JdbcCategoryManagerHome
</home>
<remote>
com.beasys.commerce.ebusiness.catalog.service.category.JdbcCategoryManager
</remote>
</ejb-ref>

  <ejb-ref>
<ejb-ref-name>ejb/CatalogManager</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>

    <home>
com.beasys.commerce.ebusiness.catalog.CatalogManagerHome
</home>
<remote>
com.beasys.commerce.ebusiness.catalog.CatalogManager
</remote>
</ejb-ref>
</session>

Again, the previous listing is from the ejb-jar.xml deployment descriptor file. You would need to make corresponding changes in the weblogic-ejb-jar.xml file. The ejb-jar.xml file (platform independent) and weblogic-ejb-jar.xml file (platform specific) file are packaged in the ebusiness.jar file. (This JAR file can be found in the WL_COMMERCE_HOME\lib directory, where WL_COMMERCE_HOME is the directory in which you installed WebLogic Commerce Server.) For related information, see the WebLogic Server EJB Reference documentation at http://www.weblogic.com/docs51/classdocs/API_ejb/EJB_reference.html, and the WebLogic Server Deployment Guides at http://www.weblogic.com/docs51/techdeploy/index.html.

 


Writing Your Own Catalog Service

This section describes the steps required to implement Product Catalog services, by way of an example. In this example, we replace the JdbcProductItemManager and the JdbcCatalogQueryManager with non-JDBC based implementations. Both provide simple (that is, not suitable for production) implementations based around storing items in memory and serializing them to (and from) disk.

Also outlined in this section are the changes to the Catalog Services deployment description that are required to plug in the new service implementation. Because these new services reside "behind" the catalog caching mechanism (see the Tier 2 portion of Figure 6-1), the new services can take advantage of the powerful caching features of the WLCS catalog.

To implement the new services, the general steps are as follows:

  1. Create the new services

  2. Compile the new services

  3. Adjust the service deployment descriptor

  4. Deploy the new services

    Note: Steps 1 and 3 are described in the remainder of this chapter. For information about steps 2 and 4, please refer to the BEA WebLogic Server Deployment Guides at http://www.weblogic.com/docs51/techdeploy/index.html.

The following topics are covered in this section:

The ejb-jar.xml and weblogic-ejb-jar.xml files are packaged in the ebusiness.jar file, which can be found in the WL_COMMERCE_HOME\lib directory, where WL_COMMERCE_HOME is the directory in which you installed WebLogic Commerce Server.

You can find all the source code shown in this section in the WL_COMMERCE_HOME/src/examples/catalog/file directory. (The updated deployment descriptors are not in this directory, however.)

Warning: This section assumes that you are familiar with building and deploying EJBs. This section also describes modifications to WebLogic Commerce Server deployment JAR files; therefore, it is important that you first back up all files and JAR libraries that you intend to modify. You should work in a new directory, such as WL_COMMERCE_HOME/src/myexamples/, and when you are ready to deploy, change the path to the weblogic.ejb.deploy value in the weblogic.properties file. For example, in the following:

weblogic.ejb.deploy=\
D:/WebLogicCommerceServer3.1/lib/foundation.jar,\
D:/WebLogicCommerceServer3.1/lib/axiom.jar,\
D:/WebLogicCommerceServer3.1/lib/ebusiness.jar,\
.
.
.

You could change this in WL_COMMERCE_HOME/weblogic.properties to:

weblogic.ejb.deploy=\
D:/WebLogicCommerceServer3.1/lib/foundation.jar,\
D:/WebLogicCommerceServer3.1/lib/axiom.jar,\
D:/WebLogicCommerceServer3.1/lib/my-ebusiness.jar,\
.
.
.

Note: BEA may post build scripts for the examples in this section on the BEA Developer Center at http://developer.bea.com/, after the 3.1 release. Please check the BEA Developer Center periodically for news about downloading the build scripts. Any announcement about the build scripts will also be posted on the WebLogic Commerce Server documentation Web site at http://download.oracle.com/docs/cd/E13210_01/wlcs/index.html.

Create New Services

The first step in creating a new catalog service is to implement the corresponding Stateless Session EJB service API. Some of the files are optional, as explained in the following summary. After the summary, sample source code is provided for the implementation files, FileCatalogQueryManagerImpl.java and FileProductItemManagerImpl.java. Again, you can find this source code in the following directory:

WL_COMMERCE_HOME/src/examples/catalog/file

Sample Source Code

Listing 6-3 show sample implementation source code for:

After you install WebLogic Commerce Server, these files can be found in the WL_COMMERCE_HOME/src/examples/catalog/file directory.

In the following listing, the bold typeface is used to direct your attention to the most relevant lines of code.

Listing 6-3 FileProductItemManagerImpl.java


/*                 
* B E A S Y S T E M S
*
* C O M M E R C E C O M P O N E N T S
*
* Copyright (c) 1997-2000 BEA Systems, Inc.
*
* All Rights Reserved. Unpublished rights reserved under the copyright laws
* of the United States. The software contained on this media is proprietary
* to and embodies the confidential technology of BEA Systems, Inc. The
* possession or receipt of this information does not convey any right to disclose
* its contents, reproduce it, or use, or license the use, for manufacture or
* sale, the information or anything described therein. Any use, disclosure, or
* reproduction without BEA System's prior written permission is strictly
* prohibited.
*
*
* $Header:$
*/

package com.beasys.commerce.ebusiness.catalog.examples.file;
import com.beasys.commerce.foundation.*;
import com.beasys.commerce.util.*;
import java.util.*;
import java.rmi.*;
import javax.ejb.*;
import javax.naming.*;
//$Import$_Begin ------------ CUSTOM CODE ---------------
import com.beasys.commerce.ebusiness.catalog.*;
import com.beasys.commerce.ebusiness.catalog.service.*;
import com.beasys.commerce.ebusiness.catalog.service.item.*;
import java.io.*;
//$Import$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/**
*
*
* @see com.beasys.commerce.ebusiness.catalog.service.item.FileProductItemManager
* @see com.beasys.commerce.ebusiness.catalog.service.item.FileProductItemManagerHome
*/
public class FileProductItemManagerImpl extends com.beasys.commerce.ebusiness.catalog.service.CatalogServiceImpl
//$Implements$_Begin ------------ CUSTOM CODE ---------------
// USER CHANGES: Add interfaces that are implemented here
//$Implements$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{

//$AdditionalAttributeDeclarations$_Begin ------------ CUSTOM CODE
// ---------------
private Hashtable itemTable = null;
private Hashtable keywordTable = null;

//$AdditionalAttributeDeclarations$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
public FileProductItemManagerImpl( )
{
super( );
//$Constructor$_Begin ------------ CUSTOM CODE ---------------
//$Constructor$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
private void loadData()
{
if( itemTable == null || keywordTable == null )
{
try
{
FileInputStream istream = new FileInputStream( "items.bin" );
ObjectInputStream objIn = new ObjectInputStream( istream );
itemTable = (Hashtable) objIn.readObject();
keywordTable = (Hashtable) objIn.readObject();
}
catch( Exception e )
{
e.printStackTrace();
}

if( itemTable == null )
itemTable = new Hashtable();

if( keywordTable == null )
keywordTable = new Hashtable();
}
}
private void saveData()
{
try
{
FileOutputStream ostream = new FileOutputStream( "items.bin" );
ObjectOutputStream objOut = new ObjectOutputStream( ostream );
objOut.writeObject( itemTable );
objOut.writeObject( keywordTable );
}
catch( Exception e )
{
e.printStackTrace();
}
}
public void ejbCreate( ) throws Creat

Listing 6-4 shows the source code for FileCatalogQueryManagerImpl.java.

Listing 6-4 FileCatalogQueryManagerImpl.java


/*                 

* B E A S Y S T E M S
*
* C O M M E R C E C O M P O N E N T S
*
* Copyright (c) 1997-2000 BEA Systems, Inc.
*
* All Rights Reserved. Unpublished rights reserved under the copyright laws
* of the United States. The software contained on this media is proprietary
* to and embodies the confidential technology of BEA Systems, Inc. The
* possession or receipt of this information does not convey any right to disclose
* its contents, reproduce it, or use, or license the use, for manufacture or
* sale, the information or anything described therein. Any use, disclosure, or
* reproduction without BEA System's prior written permission is strictly prohibited.
*
*
* $Header:$
*/


package com.beasys.commerce.ebusiness.catalog.examples.file;

import com.beasys.commerce.foundation.*;
import com.beasys.commerce.util.*;

import java.util.*;
import java.rmi.*;
import javax.ejb.*;
import javax.naming.*;

//$Import$_Begin ------------ CUSTOM CODE ---------------
import java.sql.Connection;
import java.sql.SQLException;
import com.beasys.commerce.ebusiness.catalog.*;
import com.beasys.commerce.foundation.expression.Criteria;
import com.beasys.commerce.foundation.expression.Logical;
import com.beasys.commerce.foundation.expression.Expression;
import com.beasys.commerce.util.ExpressionHelper;
import com.beasys.commerce.util.TypesHelper;
import com.beasys.commerce.ebusiness.catalog.service.query.*;
import com.beasys.commerce.ebusiness.catalog.service.item.*;
// USER CHANGES: Place additional import statements here
//$Import$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/**
*
*
* @see com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManager
* @see com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManagerHome
*/
public class FileCatalogQueryManagerImpl extends com.beasys.commerce.ebusiness.catalog.service.CatalogServiceImpl
//$Implements$_Begin ------------ CUSTOM CODE ---------------
// USER CHANGES: Add interfaces that are implemented here
//$Implements$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{

//$AdditionalAttributeDeclarations$_Begin ------------ CUSTOM CODE ---------------

//$AdditionalAttributeDeclarations$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



public FileCatalogQueryManagerImpl()
{
super();
//$Constructor$_Begin ------------ CUSTOM CODE ---------------
// USER CHANGES: Add constructor code here
//$Constructor$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

public void ejbCreate() throws CreateException
{
super.ejbCreate();



//$EjbCreate$_Begin ------------ CUSTOM CODE ---------------
//$EjbCreate$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

public void ejbPostCreate() throws CreateException
{
super.ejbPostCreate();



//$EjbPostCreate$_Begin ------------ CUSTOM CODE ---------------
// USER CHANGES: Add custom code here
//$EjbPostCreate$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

public void ejbActivate() throws EJBException
{
super.ejbActivate();

//$EjbActivate$_Begin ------------ CUSTOM CODE ---------------
// USER CHANGES: Add custom code here
//$EjbActivate$_End ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

public void ejbPassivate() throws EJBException
{
super.ejbPassivate();

//$EjbPassivate$_Begin ------------ CUSTOM CODE --------


Changes to ejb-jar.xml

In ejb-jar.xml, the first step is to change the name of the delegate Session bean in the environment for the Tier 1 service providers. Occurrences of JdbcProductItemManager need to be changed to the name of the new Tier 2 service provider: FileProductItemManager. This step is done by modifying the Tier 1 service provider to delegate to the new service implementation by adjusting several EJB deployment settings in the ejb-jar.xml and weblogic-ejb-jar.xml deployment descriptors. Finally, the modified Tier 1 service provider must be redeployed and the new service implementation deployed.

Warning: Create a backup copy of the file before you modify its contents.

Note: In Listing 6-5, lines that should be removed are shown in italics. Lines that should be added are shown in bold.

Listing 6-5 Changes to the ejb-jar.xml File


<session>
<ejb-name>com.beasys.commerce.ebusiness.catalog.service.data.CustomDataManager
</ejb-name>

  <env-entry>
<env-entry-name>delegateName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>ejb/JdbcProductItemManager</env-entry-value>
<env-entry-value>ejb/FileProductItemManager</env-entry-value>
</env-entry>
<ejb-ref>
<ejb-ref-name>ejb/JdbcProductItemManager</ejb-ref-name>
<ejb-ref-name>ejb/FileProductItemManager</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>
com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManagerHome
</home>
<remote>
com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManager
</remote>
<home>
com.beasys.commerce.ebusiness.catalog.examples.file.FileProductItemManagerHome
</home>
<remote>
com.beasys.commerce.ebusiness.catalog.examples.file.FileProductItemManager
</remote>
</ejb-ref>

<session>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.service.query.CatalogQueryManager
</ejb-name>
<env-entry>
<env-entry-name>delegateName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>ejb/JdbcCatalogQueryManager</env-entry-value>
<env-entry-value>ejb/FileCatalogQueryManager</env-entry-value>
</env-entry>
<ejb-ref>
<ejb-ref-name>ejb/JdbcCatalogQueryManager</ejb-ref-name>
<ejb-ref-name>ejb/FileCatalogQueryManager</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>
com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManagerHome
</home>
<remote>
com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManager
</remote>
<home>
com.beasys.commerce.ebusiness.catalog.examples.file.FileCatalogQueryManagerHome
</home>
<remote>
com.beasys.commerce.ebusiness.catalog.examples.file.FileCatalogQueryManager
</remote>
</ejb-ref>

<session>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManager
</ejb-name>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileProductItemManager
</ejb-name>
<home>
com.beasys.commerce.ebusiness.catalog.service.item.ProductItemManagerHome
</home>
<remote>
com.beasys.commerce.ebusiness.catalog.service.item.ProductItemManager
</remote>
<ejb-class>
com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManagerImpl
</ejb-class>
<ejb-class>
com.beasys.commerce.ebusiness.catalog.examples.file.FileProductItemManagerImpl
</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<env-entry>
<env-entry-name>SchemaFile</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>wlcs-catalog</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>SqlManagerClass</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>
com.beasys.commerce.ebusiness.catalog.sql.JdbcSqlManager
</env-entry-value>
</env-entry>

<session>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManager
</ejb-name>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileCatalogQueryManager
</ejb-name>
<home>
com.beasys.commerce.ebusiness.catalog.service.query.CatalogQueryManagerHome
</home>
<remote>
com.beasys.commerce.ebusiness.catalog.service.query.CatalogQueryManager
</remote>
<ejb-class>
com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManagerImpl
</ejb-class>
<ejb-class>
com.beasys.commerce.ebusiness.catalog.examples.file.FileCatalogQueryManagerImpl
</ejb-class>
<session-type>Stateless</session-type>
<!-- com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManager
-->
<!-- com.beasys.commerce.ebusiness.catalog.examples.file.FileProductItemManager
-->
<method>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManager
</ejb-name>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileProductItemManager
</ejb-name>
<method-name>getCatalogManager</method-name>
</method>

Changes to weblogic-ejb-jar.xml

Listing 6-6 shows the deletions and additions needed in the weblogic-ejb-jar.xml file. The weblogic-ejb-jar.xml files is packaged in the ebusiness.jar file, which can be found in the WL_COMMERCE_HOME\lib directory, where WL_COMMERCE_HOME is the directory in which you installed WebLogic Commerce Server.

Warning: Create a backup copy of the file before you modify its contents.

Note: In Listing 6-6, lines that should be removed are shown in italics. Lines that should be added are shown in bold.

Listing 6-6 Changes to the weblogic-ejb-jar.xml File


<weblogic-enterprise-bean>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.service.item.ProductItemManager
</ejb-name>
<caching-descriptor>
<initial-beans-in-free-pool>1</initial-beans-in-free-pool>
</caching-descriptor>
<reference-descriptor>
<ejb-reference-description>

      <ejb-ref-name>ejb/JdbcProductItemManager</ejb-ref-name>
<jndi-name>
com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManager
</jndi-name>
<ejb-ref-name>ejb/FileProductItemManager</ejb-ref-name>
<jndi-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileProductItemManager
</jndi-name>

     </ejb-reference-description>

<weblogic-enterprise-bean>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.service.query.CatalogQueryManager
</ejb-name>
<caching-descriptor> <!--
<initial-beans-in-free-pool>5</initial-beans-in-free-pool> -->
</caching-descriptor>
<reference-descriptor>
<ejb-reference-description>

    <ejb-ref-name>ejb/JdbcCatalogQueryManager</ejb-ref-name>
<jndi-name>
com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManager
</jndi-name>
<ejb-ref-name>ejb/FileCatalogQueryManager</ejb-ref-name>
<jndi-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileCatalogQueryManager
</jndi-name>

   </ejb-reference-description>

   <weblogic-enterprise-bean>

   <ejb-name>
com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManager
</ejb-name>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileProductItemManager
</ejb-name>

   <jndi-name>
com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManager
</jndi-name>
<jndi-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileProductItemManager
</jndi-name>

   <ejb-name>
com.beasys.commerce.ebusiness.catalog.service.item.JdbcProductItemManager
</ejb-name>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.service.examples.file.FileProductItemManager
</ejb-name>

<weblogic-enterprise-bean>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManager
</ejb-name>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileCatalogQueryManager
</ejb-name>

   <jndi-name>
com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManager
</jndi-name>
<jndi-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileCatalogQueryManager
</jndi-name>

   <ejb-name>
com.beasys.commerce.ebusiness.catalog.service.query.JdbcCatalogQueryManager
</ejb-name>
<ejb-name>
com.beasys.commerce.ebusiness.catalog.examples.file.FileCatalogQueryManager
</ejb-name>